Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
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

2 Answers 2

up vote 15 down vote accepted

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.

share|improve this answer
    
Works very well, thanks. –  Andre Boos 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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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