9

In this answer the following code appears. The idea is that the initial table sets up the column widths used by the subsequent tables. The initial table itself is not supposed to be shown. Its only there to set up the widths which \usetabu retrieves. Unresolved from that post is whether there is any way to generate the first table but not have it visible or take up any space.

\documentclass{article}
\usepackage{tabu}
\begin{document}

\begin{center}
\begin{tabu} spread 0pt  {|X[-1]|X[-1]|}\savetabu{mytabu2}
1 & 2 \\
3 & 4 \\
abcdefghijklmnopqrstuvwxyz & 10 \\
5 & 6 \\
\end{tabu}
\end{center}

\begin{center}
\begin{tabu}{\usetabu{mytabu2}}
1 & 2 \\
3 & 4 \\
\end{tabu}
\end{center}

\begin{center}
\begin{tabu}{\usetabu{mytabu2}}
abcdefghijklmnopqrstuvwxyz & 10 \\
5 & 6 \\
\end{tabu}
\end{center}

\end{document}

Output (this shows the three tables but what is desired is that only the last two are shown and the first runs so that it sets up the column widths but is not visible).

enter image description here

user1189687
  • 1,953

1 Answers1

10

Put it in a box, but don't use the box.

\documentclass{article}
\usepackage{tabu}
\newbox\mybox %New
\begin{document}

\sbox\mybox{ %New
\begin{tabu} spread 0pt  {|X[-1]|X[-1]|}\savetabu{mytabu2}
1 & 2 \\
3 & 4 \\
abcdefghijklmnopqrstuvwxyz & 10 \\
5 & 6 \\
\end{tabu}
}

\begin{center}
\begin{tabu}{\usetabu{mytabu2}}
1 & 2 \\
3 & 4 \\
\end{tabu}
\end{center}

\begin{center}
\begin{tabu}{\usetabu{mytabu2}}
abcdefghijklmnopqrstuvwxyz & 10 \\
5 & 6 \\
\end{tabu}
\end{center}

\end{document}
David Carlisle
  • 757,742
Ian Thompson
  • 43,767