I'm struggling with a seemingly trivial case of vertical alignment in a tabular
. Consider 3 columns: two columns contain text that is supposed to be soft-wrapped and should be aligned at the top of the cells. The third column (the middle column in my example) should be vertically centered within the row.
Example:
\documentclass{scrartcl}
\usepackage{lipsum}
\usepackage{array}
\begin{document}
\begin{tabular}{m{4cm} m{1cm} m{4cm}}
\lipsum[1][1] & x & \lipsum[1][1]
\end{tabular}
\end{document}
This looks as expected, but only if the two texts occupy the same height. Otherwise (just changing the second \lipsum[1][1]
to \lipsum[1][1-2]
, the result is:
Problem: The content of column 1 is not aligned at the top of the cell.
Of course, changing the alignment of the two "long" columns to p{4cm}
does not help:
\documentclass{scrartcl}
\usepackage{lipsum}
\usepackage{array}
\begin{document}
\begin{tabular}{p{4cm} m{1cm} p{4cm}}
\lipsum[1][1] & x & \lipsum[1][1-2]
\end{tabular}
\end{document}
Problem: Now the column in the middle is not vertically centered anymore.
I think I understand why this is happening: All these alignments are relative to the first "line" of the current cell, not relative to the cell itself. (How) Is this possible? I'm looking for a column specification that allows me to produce:
In the best case, I wouldn't even have to specify a width for the column in the middle.
multirow
. However, not ideal since you have to count the lines of the larger cell:\documentclass{scrartcl} \usepackage{lipsum} \usepackage{array} \usepackage{multirow} \begin{document} \begin{tabular}{p{4cm} l p{4cm}} \lipsum[1][1] & \multirow{6}{*}{x} & \lipsum[1][1-2] \end{tabular} \end{document}