[Tex/LaTex] Table: Can I shift a column by half the height of a row

columnstablesvertical alignment

This question is best explained by giving the usecase:

I have a table where I list some data and I would like to add a column to the right which gives the ratio of two adjacent rows.
Now to make it more obvious the ratio of which rows this is I would like to shift the column which the ratios by half the height
of a row so that each of the ratio values sits to the right of the two columns which it was calculated from.

E.g. instead of this

 A    ratio
------------
 3      2
 6      3
18

imagine the same table but the numbers in the right column shifted down by half a row.

Is this even possible?

Best Answer

\documentclass[a4paper]{article}
\usepackage{collcell,array}
\newcommand{\shiftdown}[1]{\smash{\raisebox{-.5\normalbaselineskip}{#1}}}
\newcolumntype{C}{>{\collectcell\shiftdown}c<{\endcollectcell}}
\begin{document}
\begin{tabular}{cC}
A & \multicolumn{1}{c}{ratio}\\
\hline
3 &2\\
6 &3\\
18
\end{tabular}
\end{document}

The \multicolumn{1}{c}{...} is necessary to avoid applying the shift also to the heading.

Related Question