# Aligning multiple tabu tables

In the example code below we have two one-row tables (in reality there would be more rows and colors and other formatting) and we would like to align then so that the vertical line after the second column in the first table is aligned with the vertical line after the first column in the second table.

In another post someone suggested using p when trying to align columns in different tables but I find this approach very time consuming since it means fiddling with the numbers in the p specification.

It almost works the way we have it below and if we fiddle with the numbers in the p specifications we could likely get it more precise but I was hoping there would be a solution that would do the positioning for me. Also the widths of columns 3, 4 and 5 of the first table don't really look so great. I would prefer if all the extra space from these three columns were put at the end of column 5.

I would like to stick to using tabu, if possible.

\documentclass{article}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage[linegoal]{tabu}\tracingtabu=2

\begin{document}

\begin{center}\small
\begin{tabu} to\textwidth{*{2}{ p{.15\textwidth} | } p{.2\textwidth} | p{.1\textwidth} | X }
\rowfont\bfseries aaaaaaaaaaaaaa & bbbbbbbbbbb & ccccccccccccccccc & dddddddd & eeeeeeeeeeeeeeee \\
\end{tabu}
\end{center}

Various text.

\begin{center}\small
\begin{tabu} to\textwidth{>{\bfseries}p{.32\textwidth} | X[l,m]}
\everyrow{\tabucline-}
ffffffffffffffffffffffffff  & ggggggggggggggggg \\
\end{tabu}
\end{center}

\end{document}
-
In your real case are the entries single line. If you use l columns the columns naturally are tight to the natural width of the columns, If you use p (or X) columns the cell entry is set in a parbox, and so determining the natural width of the entyu is considerably harder. However it is of course necessary if you need to allow linebreaking within the cell. – David Carlisle Jul 8 '12 at 11:35
@David Carlisle, Thanks. The l works. – user1189687 Jul 8 '12 at 14:09

You can get the columns precisely aligned if you take into account the separation between the columns. Instead of .30\textwidth (since your first two columns are each p{.15\textwidth}), use:

\dimexpr.30\textwidth+2\tabcolsep\relax

which yields:

## Code:

\documentclass{article}
\usepackage[top=1in,bottom=1in,left=0.5in,textwidth=7.5in]{geometry}
\usepackage[linegoal]{tabu}\tracingtabu=2

\begin{document}

\begin{center}\small
\begin{tabu} to\textwidth{*{2}{ p{.15\textwidth} | } p{.2\textwidth} | p{.1\textwidth} | X }
\rowfont\bfseries aaaaaaaaaaaaaa & bbbbbbbbbbb & ccccccccccccccccc & dddddddd & eeeeeeeeeeeeeeee \\
\end{tabu}
\end{center}

Various text.

\begin{center}\small
\begin{tabu} to\textwidth{>{\bfseries}p{\dimexpr.30\textwidth+2\tabcolsep\relax} | X[l,m]}
\everyrow{\tabucline-}
ffffffffffffffffffffffffff  & ggggggggggggggggg \\
\end{tabu}
\end{center}
\end{document}
-
The intercolumn spacing in your answer nicely addresses this. Thanks. – user1189687 Jul 8 '12 at 14:10