9

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*?

  • 1
    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
15

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.

| improve this answer | |
6

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}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.