# Table inside table

Inside of a Beamer presentation, I want to put a graph side-by-side with a data table. Outline of the code:

\begin{tabular*}{l r}
\begin{center}\includegraphics{graph}\end{center}
&
\begin{tabular}{|p{1cm}|p{1cm}|p{1cm}|p{1cm}|}
1 & 2 & 3 & 4\\\hline
4 & 3 & 2 & 1\\\hline
\end{tabular}\\
\end{tabular*}


This gives the error Something's wrong, maybe a missing \item. Earlier in the presentation I used a tabular* environment to put a graph side-by-side with some bullet points, and in another slide, I used a tabular environment to display data under a graph. Is there a better way to do this? Why doesn't LaTeX allow a tabular inside a tabular*?

-
It does allow it. Remove the inner tabular: The error will stay. The problem is the \begin{center} which is not allowed in a column of type l as it is a list (and it doesn't make sense there anyway). –  Ulrike Fischer May 29 '11 at 14:10
Beamer's columns environment might be more stable for this sort of thing. –  Seamus May 29 '11 at 14:11

You can use the columns environment instead. You can use one column to place the image and another one for the table:

\PassOptionsToPackage{demo}{graphicx}
\documentclass{beamer}

\begin{document}

\begin{frame}
\begin{columns}
\column{.5\textwidth}
\centering
\includegraphics{graph}
\column{.5\textwidth}
\begin{tabular}{|p{1cm}|p{1cm}|p{1cm}|p{1cm}|}\hline
1 & 2 & 3 & 4\\\hline
4 & 3 & 2 & 1\\\hline
\end{tabular}
\end{columns}
\end{frame}

\end{document}


The line \PassOptionsToPackage{demo}{graphicx} was only included to make my example compilable for everyone; do not include it in your actual code.

-
Works very well, thanks. –  Andrew Buss May 29 '11 at 14:38

Do not use the center environment inside the table. IIRC it uses a trivlist internally and will add vertical spacing which is normally not wanted in this case. You could use \multicolumn{1}{c}{\includegraphics{graph}} instead.

The tabular inside a tabular or tabular* should be OK. When in doubt just wrap the inner one inside braces { }, but this should normally not be necessary.

The following minimal example works for me. However, centering the graph in such a table with only one row doesn't make sense. The cell is then anyway exactly the size of the graph. Only if there is more than one row it would make sense.

\documentclass{beamer}

\begin{document}

\frame{%
\begin{tabular*}{\textwidth}{l r}
\multicolumn{1}{c}{\includegraphics{graph}}
&
\begin{tabular}{|p{1cm}|p{1cm}|p{1cm}|p{1cm}|}
1 & 2 & 3 & 4\\\hline
4 & 3 & 2 & 1\\\hline
\end{tabular}\\
\end{tabular*}
}

\end{document}

-