Vertical alignment in tabular cells with variable height
The vertical adjustment of the row "c" is related to the definition of the columntype X which uses the specifier p
.
You need m
for a centered adjustment and b
for bottom. This can be achieved by \multicolumn
, whereby the line width must be saved (I don't know a good solution).
Here is an example:
\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage{tabularx}
\usepackage{lipsum}
\begin{document}
\begin{tabularx}{\textwidth}{ | X | c | }
\hline
\lipsum*[1]\xdef\tempwidth{\the\linewidth} & top\\\hline
\multicolumn{1}{|m{\tempwidth}|}{\lipsum*[1]} & center\\\hline
\multicolumn{1}{|b{\tempwidth}|}{\lipsum*[1]} & bottom\\\hline
\end{tabularx}
\end{document}
\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage{tabularx}
\usepackage{lipsum}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{ | X | c | }
\hline
\lipsum[1] & top\\
\hline
\noindent\parbox[c]{\hsize}{\lipsum[1]} & center\\
\hline
\noindent\parbox[b]{\hsize}{\lipsum[1]} & bottom\\
\hline
\end{tabularx}
\end{document}
Another way, using a minipage
environment instead of a tabularx
package:
\documentclass{article}
\usepackage{lipsum}
\usepackage[a4paper]{geometry}
\begin{document}
\begin{tabular}{|l|c|}
\hline
\begin{minipage}[t]{0.85\textwidth}\lipsum[1]\end{minipage} & top\\
\hline
\begin{minipage}{0.85\textwidth}\lipsum[1]\end{minipage} & center\\
\hline
\begin{minipage}[b]{0.85\textwidth}\lipsum[1]\end{minipage} & bottom\\
\hline
\end{tabular}
\end{document}