Graphics, Figures & Tables[Beamer] \pause before \multicolumn

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
teddom
Posts: 2
Joined: Sun Feb 13, 2011 3:30 pm

[Beamer] \pause before \multicolumn

Post by teddom »

Hello everybody

I want to create a latex beamer presentation containing a table. Because everything at once would be too much, I split them into different slades using the \pause command. No problem, this works.

But if I set a \pause before a \multicolumn, I get an error ("Misplaced \omit"), which is not that surprise, because the \multicolumn should be the the first command in the cell.

MWE:

Code: Select all

\documentclass{beamer}
\begin{document}
\frame{\begin{tabular}{ll}\hline
    \multicolumn{2}{l}{}\\
    \pause
    \multicolumn{2}{l}{}\\
  \end{tabular}}
\end{document}
When commenting line five (the \pause), the error disappears, but I really want a pause there.

Maybe a more evident example:

Code: Select all

\documentclass{beamer}
\usepackage{colortbl}
\begin{document}
\frame{
  \begin{tabular}{ll}\hline
    \multicolumn{2}{l}{\cellcolor{gray}Sec I}\\ 
    A & 1\\\hline
    \pause
    \multicolumn{2}{l}{\cellcolor{gray}Sec II}\\ 
    B & 2 \\\hline
  \end{tabular}}
\end{document}
Neither A & 1\pause\\\hline nor \multicolumn{2}{l}{\pause\cellcolor{gray}Sec II}\\ produces what I want:
The desired two slides
The desired two slides
mwe.png (5.12 KiB) Viewed 10360 times
Has anybody an idea how to get the expected output?
Last edited by teddom on Tue Feb 15, 2011 7:13 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

[Beamer] \pause before \multicolumn

Post by frabjous »

You can put the \pause before the linebreak:

Code: Select all

\documentclass{beamer}
\usepackage{colortbl}
\begin{document}
\frame{
  \begin{tabular}{ll}\hline
    \multicolumn{2}{l}{\cellcolor{gray}Sec I}\\
    A & 1 \pause \\\hline
    \multicolumn{2}{l}{\cellcolor{gray}Sec II}\\
    B & 2 \\\hline
  \end{tabular}}
\end{document}
The downside is that you don't then get the line underneath the previous row.

There is a discussion of this in section II.23.5 of the Beamer User's Guide ("Uncovering a Table Row-wise"), which you may want to read.

Probably it's best to use other overlay commands like \onslide, \only, \visible, \uncover, etc, from section II.9 of the user's guide. I'm sure you can get what you want. Here's one possibility:

Code: Select all

\documentclass{beamer}
\usepackage{colortbl}
\begin{document}
\frame{
  \begin{tabular}{ll}\hline
    \multicolumn{2}{l}{\cellcolor{gray}Sec I}\\
    A & 1 \\\hline
    \multicolumn{2}{l}{\only<2->{\cellcolor{gray}Sec II}}\\
    \uncover<2->{B} & \uncover<2->{2} \pause \\
     \hline
  \end{tabular}}
\end{document}
At the very worst, you could always put completely different tables inside \only specifications.
teddom
Posts: 2
Joined: Sun Feb 13, 2011 3:30 pm

[Beamer] \pause before \multicolumn

Post by teddom »

Hello frabjous, thank you for your reply. Beside the first suggestion - which was already included in my first post - and the second one - in my opinion not applicable for me, your third was an interesting option. Interesting and complex... To be honest, I don't get them to work properly (*damn colored multicolumn*), but I it must be possible in such a fundamental way.

Doubling/Tripling/Quadrupling the table would be a possibility without any restrictions, but finally, I've found a better way:

I simply split the table for each section. No line is ugly, but two lines between the sections is quite cute (regarding my case). My solution looks like:

Code: Select all

\documentclass{beamer}
\usepackage{colortbl}
\begin{document}
\frame{
  \begin{tabular}{ll}\hline
    \multicolumn{2}{l}{\cellcolor{gray}Sec I}\\ 
    A & 1\\\hline
  \end{tabular}\pause\\
  \begin{tabular}{ll}\hline
    \multicolumn{2}{l}{\cellcolor{gray}Sec II}\\ 
    B & 2 \\\hline
  \end{tabular}}
\end{document}
In reality, I need to create a macro to provide a uniform-looking table (size, color, etc.) so the code is ugly too, but at least not duplicated.

Greets
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

[Beamer] \pause before \multicolumn

Post by frabjous »

teddom wrote: and the second one - in my opinion not applicable for me, your third was an interesting option.
I don't understand. The output is exactly what you asked for. Do you just mean it's too much of a hassle to put in the extra commands in each cell? I could understand that, I guess.
Post Reply