# Preserving table width and header, when using tables across multiple frames in Beamer

When using the beamer class, how can I create a table which preservers the contents of the header and the width of the columns across multiple pages, without naming this width explicitly?

longtable seems to preserve the width, but as already described in Same Header on different slides with beamer and longtable it seems not to preserve the header. xtab and supertabular on the other hand seem not to preserve the width.

-

\documentclass{beamer}
\begin{document}
\begin{frame}{My frame title}
\begin{tabular}{cc}
This is a very long header & Here is another header \\ \hline
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
\end{tabular}
\end{frame}
\begin{frame}{My frame title}
\begin{tabular}{cc}
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
\end{tabular}
\end{frame}
\end{document}

-

Your best bet here, in my opinion, is to duplicate the structure of your table on the frames that you need using a regular tabular environment.

In terms of headers, also duplicate the header but use \widthof{...} (from the calc package) to get the spacing right across frames. The argument of \widthof{...} should be the widest element within the column across all frames:

\documentclass{beamer}
\usepackage{lmodern}% http://ctan.org/pkg/lmodern
\usepackage{calc}% http://ctan.org/pkg/calc
\begin{document}
\begin{frame}{My frame title}
\begin{tabular}{cc}
This is a very long header & Here is another header \\ \hline
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
\end{tabular}
\end{frame}
\begin{frame}{My frame title}
\begin{tabular}{cc}
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
fooooooooooo & Bar\\
\end{tabular}
\end{frame}
\end{document}


\widthof{...} will ensure that the horizontal spacing is preserved without respecifying it (in the literal/length sense, as in 50pt, say).

-
it maybe a good idea to load the package calc which you already mentioned ... ;-) –  Herbert Sep 10 '11 at 20:09
@Herbert: Keen eye...! Thanks. –  Werner Sep 10 '11 at 20:09