# manipulate table row spacing to match up two adjacent tables

Suppose I have two tables next to one another, with a different number of rows, and also different heights in the body cells like this:

\documentclass{article}
\begin{document}
\begin{table}
\begin{tabular}[t]{c c}
\hline
hello & world\\
\hline
a \\
b \\
c \\
d \\
\hline
\end{tabular}
\begin{tabular}[t]{c c}
\hline
lorem & ipsum\\
\hline
$A_{\left(1\right)}^2$ \\
$B_{\left(2\right)}^2$ \\
$C_{\left(3\right)}^2$ \\
\hline
\end{tabular}
\end{table}
\end{document}


Now, I'd like to have it such that the lines in the body of the right table are spread out so that the bottom lines of the two tables line up perfectly, while still keeping the top and bottom lines of the first row aligned as well.

I've tried playing with \arraystretch and other things, but of course, I can never have both at the same time.

Any suggestions on how to monkeypatch the spacing of a table in such a way would be highly appreciated!

• putting some \vspace in the cells? Oct 13 '20 at 18:48
• sounds good, but how can I (programmatically) figure out what is the correct amount of vspace to put? I don't want to have to fiddle with the numbers manually too much (it's a long table) Oct 13 '20 at 18:56
• Make a single tabular with an empty column in between the left and right parts of this tabular. Oct 13 '20 at 19:56

You can use the tabularht package which allows you to specify the desired table height and to add extra space between rows:

\documentclass{article}
\usepackage{tabularht}
\begin{document}
\begin{table}
\begin{tabularht}{1in}{cc}
\hline
hello & world\\
\hline
\interrowfill
a \\
\interrowfill
b \\
\interrowfill
c \\
\interrowfill
d \\
\interrowfill
\hline
\end{tabularht}
\begin{tabularht}{1in}{cc}
\hline
lorem & ipsum\\
\hline
\interrowfill
$A_{\left(1\right)}^2$ \\
\interrowfill
\
$B_{\left(2\right)}^2$ \\
\interrowfill
$C_{\left(3\right)}^2$ \\
\interrowfill
\hline
\end{tabularht}
\end{table}
\end{document}


The result:

Apparently you can calculate the height of objects (found here: https://stackoverflow.com/questions/2939450/get-height-on-a-block-of-latex-output) And so you could calculate the height of the tables, and divide the remainder onto the rows in the smaller table:

\documentclass{article}

\begin{document}

\section{Table measurements}

\newdimen\height
\setbox0=\vbox{
\begin{tabular}{c}
\hline
a \\
\hline
b \\
c \\
d \\
\hline
\end{tabular}
}

The height is: \the\height

\newdimen\height
\setbox0=\vbox{
\begin{tabular}{c}
\hline
A \\
\hline
B \\
C \\
\end{tabular}
}
The height is: \the\height

\section{The Tables}

\begin{tabular}{c}
\hline
a \\
\hline
b \\
c \\
d \\
\hline
\end{tabular}
\begin{tabular}{c}
\hline
A \\
\hline
B \\
C \\
\hline
\end{tabular}

\section{Corrected table}

\begin{tabular}{c}
\hline
a \\
\hline
b \\
c \\
d \\
\hline
\end{tabular}
\begin{tabular}{c}
\hline
A \vspace{4pt} \\
\hline
B \vspace{4pt} \\
C \vspace{4pt} \\
\hline
\end{tabular}

\end{document}


You would have to count the rows in the shorter table and divide, but at least you wouldn't have to fiddle with each and every row.