[Tex/LaTex] What’s wrong with this table code in beamer

beamertables

I've been struggling for a long while with this code trying to solve the problem there apparently is. I basically copied the code from this page http://en.wikibooks.org/wiki/LaTeX/Tables in the "Spanning in both directions simultaneously" section, and I just modified it a bit:

\begin{frame}
\begin{center}
\onslide<1->\begin{tabular}{c|c|c|c}
\cline{1-4}
\multicolumn{4}{c}{Matemáticas} \pause\\
\cline{1-4}
\multicolumn{2} {c}{Cantidad}& \multicolumn{2} {c}{Magnitud} \pause \\ 
\cline{1-4}
\multicolumn{1}{c} {Aritmética} & \multicolumn{1}{c}{Música} & \multicolumn{1}c}{Geometría}  & \multicolumn{1}{c}{Astronomía} \pause\\
\cline{1-4}
\multicolumn{4}{c}{Quatrivium}
\end{tabular}
\end{center}
\end{frame}

TeXStudio keeps saying:

Misplaced \omit \cline{1-4} 
Missing \endgroup inserted \cline{1-4}
Missing } inserted \cline{1-4}
Missing \cr inserted \cline{1-4}

I would like that the table ends up looking like this

enter image description here

Best Answer

Your basic problem is that your table contains for columns, but you have placed \pause after \multicolumn{4}{...}{...}. At this point, there is no cell. \pause can be put at the end of the last argument of \multicolumn:

\multicolumn{4}{...}{...\pause}

But then the bottom line of the row is omitted. The following example smuggles \pause after the line:

\hline % \cline{1-4}
\noalign{\hbox{\pause}}

Remarks:

  • \hline is better than \cline{1-<max column>}, because then the space for the line is taken into account. This is not possible for \cline. Otherwise several \cline in a row would be vertically shifted.

  • \noalign allows to put material in vertical mode outside of the alignment.

  • I have wrapped \pause into \hbox, because \pause does not seem to like vertical mode here.

There are many ways to get to the wanted table layout, e.g.:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{array}
\begin{document}

\newcommand*{\tabstack}[4]{%
  \begingroup
    \setlength{\extrarowheight}{0pt}%
    \begin{tabular}[t]{@{}c@{}}%
      \textcolor{#1}{#2}\tabularnewline
      \textcolor{#3}{#4}%
    \end{tabular}%
  \endgroup
}

\begin{frame}
\begin{center}
\color{blue}
\setlength\extrarowheight{.7ex}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{4}{|c|}{
  \tabstack {blue}  {\Large Matemáticas}
            {black} {(el estudio de lo inmutable)}
}\\
\hline
\noalign{\hbox{\pause}}
\multicolumn{2}{|c|}{
  \tabstack {red}   {\Large Cantidad}
            {black} {(lo discreto)}
} &
\multicolumn{2}{c|}{
  \tabstack {red}   {\Large Magnitud}
            {black} {(lo continuo)}
}\\
\hline
\noalign{\hbox{\pause}}
\tabstack {black} {absoluta}
          {red}   {\Large Aritmética}
&
\tabstack {black} {relativa}
          {green} {\Large Música}
&
\tabstack {black} {en reposo}
          {red}   {\Large Geometría}
&
\tabstack {black} {enmovimiento}
          {red}   {\Large Astronomía}
\\
\hline
\noalign{\hbox{\pause}}
\multicolumn{4}{|c|}{
  \Large \textcolor{blue}{Quatrivium}
} \\
\hline
\end{tabular}
\end{center}
\end{frame}
\end{document}

Result

Remarks:

  • For the cells with two lines, I have used a nested tabular. @{} removes the space that separates columns, because this space is already added by the outer tabular.

  • The lines of the tabular are colored by setting the default color for the whole table to the color of the lines.

  • The textured background is omitted, because this is much more complicate:

    • The table could be put into a box and an image could be scaled to this dimensions and put behind the table box. But this causes trouble with \pause.

    • A monochrome background should be easier, package like colortbl allows the setting of a background color, e.g. via \rowcolor. The package has also commands for colorizing the lines. However there might be problems with partial overwritten lines by the "background" color.

Related Question