I am wanting the ability to vertically align any cell within a table. This appears possible but only on a per column or row basis. At the moment I can horizontally align the contents of individual cells with the help of the \raggedleft
and \centering
commands. However, \multicolumn
applies vertical alignment for the whole row and the longtabu
environment can only specify the alignment type per column.
The following is an example of the table I want to create where both horizontal and vertical alignments need to be set for each cell instead of per row or column:
\documentclass[11pt,a4paper]{article}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{lipsum}
\usepackage{multirow}
\newcolumntype{M}{m{\dimexpr 1\tabucolX+1\tabcolsep+\arrayrulewidth\relax}}
\newcolumntype{P}{p{\dimexpr 1\tabucolX+1\tabcolsep+\arrayrulewidth\relax}}
\newcolumntype{B}{b{\dimexpr 1\tabucolX+1\tabcolsep+\arrayrulewidth\relax}}
\newcolumntype{H}{>{\begin{minipage}[b]{\hsize}}B<{\end{minipage}}}
\begin{document}
\begin{longtabu} to 150mm [l] {|X[l]|X[l]|X[l]|}
\hline
\multicolumn{1}{|P|}{ \lipsum[1]} & \multicolumn{1}{H|}{\centering H: Center, V:Center} & \multicolumn{1}{B|}{\raggedleft \multirow{1}{*}[-2\baselineskip]{H:Right, V:Bottom}} \tabularnewline
\hline
\multicolumn{1}{|P|}{\lipsum[1]} & \multicolumn{1}{P|}{H: Left, V:Top} & \multicolumn{1}{M|}{\centering H:Center, V:Center} \tabularnewline
\hline
\multicolumn{1}{|P|}{\lipsum[1]} & \multicolumn{1}{M|}{\raggedleft H: Right, V:Center} & \multicolumn{1}{B|}{H:Left, V:Bottom} \tabularnewline
\hline
\tabuphantomline
\end{longtabu}
\end{document}
Update:
Attempting the solutions presented in "Move tabular entry to bottom of row" won't work.
The first solution I believe simply adjusts the entire column by creating a new column type:
\newcolumntype{B}{>{\begin{minipage}[b]{\hsize}}X<{\end{minipage}}}
This doesn't help my problem where I need the vertical alignment applied to individual cells, not a whole column. Applying this column type to \multicolumn
doesn't appear to work.
The second solution places a \baselineskip
into the optional parameter of \multirow
which works initially but seems to become vertically centred as soon as the cell becomes a certain height.
I have updated my example above to show how it breaks.
Thanks
m
orb
columns fromarray
package.\multicolumn
only one column-spec is allowed.longtabu
. The developer has already said that he is going to make some major changes and it is not going to be backward compatible. You can find more about this in this question: tex.stackexchange.com/questions/106452/…