# Multicolumn doesn't work well with onslide

I have the following code which works without error:

\documentclass{beamer}
\usepackage[frenchb]{babel}

\begin{document}
\begin{frame}
\begin{tabular}{ll|ll}
\onslide<1->{a & b & c & d}
\onslide<2->{
\\ \hline
\multicolumn{2}{l|}{Line 1}
\\
\multicolumn{2}{l|}{Line 2 left}
& Line 2 right
}
\\ \hline
\end{tabular}
\end{frame}
\end{document}


However, I changed Line 2 rightto \multicolumn{2}{l}{Line 2 right}, it didn't compile anymore. Then I removed onslide<2->, it compiled again, but without overlays effect. So it seems that the 3rd multicoulmn does not work well with onslide, does anyone know how to solve it?

...
\onslide<2->{
\\ \hline
\multicolumn{2}{l|}{Line 1}
\\
\multicolumn{2}{l|}{Line 2 left}
& \multicolumn{2}{l}{Line 2 right} \\\hline
}
\onslide<3->{
\multicolumn{2}{l|}{Line 1}
\\
\multicolumn{2}{l|}{Line 2 left}
& \multicolumn{2}{l}{Line 2 right} \\\hline
}


...

-

Add \\ (and \hline) at the end of the row inside \onslide:

\documentclass{beamer}
\usepackage[frenchb]{babel}

\begin{document}
\begin{frame}
\begin{tabular}{ll|ll}
\onslide<1->{a & b & c & d}
\onslide<2->{
\\ \hline
\multicolumn{2}{l|}{Line 1}
\\
\multicolumn{2}{l|}{Line 2 left}
& \multicolumn{2}{l}{Line 2 right} \\\hline
}
\end{tabular}
\end{frame}

\end{document}


However, read Section 23.5 Uncovering a Table Rowwise of the beamer manual; a little excerpt

When you wish to uncover a table line-by-line, you will run into all sorts of problems if there are vertical and horizontal lines in the table. The reason is that the first vertical line at the left end is drawn before the line is even read (and thus, in particular, before any \onslide command can be read). However, placing a \pause or \uncover at the end of the line before is also not helpful since it will then suppress the horizontal line below the last uncovered line.

(Then comes an example showing a possible way to uncover tables.)

With the new edit to the original question:

\documentclass{beamer}
\usepackage[frenchb]{babel}

\begin{document}
\begin{frame}
\begin{tabular}{ll|ll}
\onslide<1->{a & b & c & d}
\onslide<2->{
\\ \hline
\multicolumn{2}{l|}{Line 1}
\\
\multicolumn{2}{l|}{Line 2 left}
& \multicolumn{2}{l}{Line 2 right} \\\hline
}
\onslide<3->{\\[-\normalbaselineskip]
\multicolumn{2}{l|}{Line 1}
\\
\multicolumn{2}{l|}{Line 2 left}
& \multicolumn{2}{l}{Line 2 right} \\\hline
}
\end{tabular}
\end{frame}

\end{document}


The end of the second row is inside \onslide<2>, so \onslide<3> doesn't see it on time; add a new line with a negative spacing at the beginning of the row, as my example shows.

-
Thanks... but the problem is that I have \\ \hline afterwards, your solution gives an extra line. If I keep your solution and remove the \\ before \hline, it does not compile well. – SoftTimur Aug 21 '12 at 22:18
@SoftTimur that's no problem; see my updated answer for the solution (using \\\hline inside \only.) – Gonzalo Medina Aug 21 '12 at 22:21
Well, that is better, but what follows \onslide<2-> is actually \onslide<3->. It seems that without \\\hline or \\ in the beginning of \onslide<3->, it doesn't compile, but it results in an extra line... I have added the code which does not work in OP... – SoftTimur Aug 21 '12 at 22:44
@SoftTimur see my updated answer. – Gonzalo Medina Aug 21 '12 at 22:54
@SoftTimur it's all part of the problem with lines in a table that I mentioned; a better approach would be to consider not using lines in your tables if you are going to use overlays. – Gonzalo Medina Aug 21 '12 at 23:00