11

I have a table with 7 columns and want to show the first 5 at once, and then the 6th and 7th on consecutive slides.

This is the code I have for now:

\begin{frame}{Наслов}
    \begin{itemize}
        \item Ставка.
    \end{itemize}
        \begin{tabular}{ccccc<{\onslide<2->}c<{\onslide}c}
            $p_1$ & $p_2$ & $\ldots$ & $p_{9}$ & $p_{10}$ & $W$  & $D$\\
            $1$   & $1$   & $\ldots$ & $1$      & $1$     & $w_1$& $d_1$\\
            $1$   & $1$   & $\ldots$ & $1$      & $0$     & $w_2$& $d_2$\\
            $1$   & $1$   & $\ldots$ & $0$      & $1$     & $w_3$& $d_3$\\
            $1$   & $1$   & $\ldots$ & $0$      & $0$     & $w_4$& $d_4$\\
            $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$\\
            $0$   & $0$   & $\ldots$ & $0$      & $1$     & $w_{1023}$& $d_{1023}$\\
            $1$   & $1$   & $\ldots$ & $0$      & $0$     & $w_{1024}$& $d_{1024}$
        \end{tabular}
\end{frame}

This produces 2 slides: the first one with p1, p2, ..., p9, p10 and D columns, and the second with W added, while I want them to appear in the following order:

  • 1st slide: p1, p2, ..., p9, p10
  • 2nd slide: p1, p2, ..., p9, p10, W
  • 3rd slide: p1, p2, ..., p9, p10, W, D

I looked in the manual and found this example:

\begin{frame}
    \begin{tabular}{l!{\vrule}c<{\onslide<2->}c<{\onslide<3->}c<{\onslide<4->}c<{\onslide}c}
    Class & A & B & C & D \\
    217
    X & 1 & 2 & 3 & 4 \\
    Y & 3 & 4 & 5 & 6 \\
    Z & 5 & 6 & 7 & 8
    \end{tabular}
\end{frame}

which does what is supposed to. However, I don't seem to be able to apply its logic to my problem. :( Is anyone willing to help?

P.S. What are the meanings of < and ! in columns specification?

Milos
  • 391

1 Answers1

15

The following seems to do what you're asking for, after adding array to the preamble:

enter image description here

\documentclass{beamer}
\usepackage{array}
\begin{document}

\begin{frame}
  \begin{tabular}{ccccc<{\onslide<2->}c<{\onslide<3->}c<{\onslide}}
    $p_1$ & $p_2$ & $\ldots$ & $p_{9}$ & $p_{10}$ & $W$  & $D$\\
    $1$   & $1$   & $\ldots$ & $1$      & $1$     & $w_1$& $d_1$\\
    $1$   & $1$   & $\ldots$ & $1$      & $0$     & $w_2$& $d_2$\\
    $1$   & $1$   & $\ldots$ & $0$      & $1$     & $w_3$& $d_3$\\
    $1$   & $1$   & $\ldots$ & $0$      & $0$     & $w_4$& $d_4$\\
    $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$\\
    $0$   & $0$   & $\ldots$ & $0$      & $1$     & $w_{1023}$& $d_{1023}$\\
    $1$   & $1$   & $\ldots$ & $0$      & $0$     & $w_{1024}$& $d_{1024}$
  \end{tabular}
\end{frame}

\end{document}
Werner
  • 603,163
  • 1
    It seems that setting \setbeamercovered{dynamic} prevents this from working. Putting \setbeamercovered{invisible} inside the frame fixes the issue. – Miguel Dec 12 '16 at 16:54
  • 1
    It worked here even without the collcell package. This doesn't work with \hline, does it? – Waldir Leoncio May 17 '17 at 08:09
  • @WaldirLeoncio: You need at least the array package which supports the >{..} and <{..} notation. collcell loads array. You might be interested in Easiest way to delete a column? – Werner May 17 '17 at 18:48
  • I am trying to do this with the separation bars in between columns and it is giving me an error -- i.e., if I change the tabular definition to \begin{tabular}{c|c|c|c|c|<{\onslide<2->}c|<{\onslide<3->}c<{\onslide}|}. Any way to fix that? – ozsu Jan 03 '18 at 16:21
  • @ozsu: See this paste. You can only insert content immediately before or after the column, not the vertical rules. If you want to have an \onslide rule, then you have to insert it using \vrule. – Werner Jan 03 '18 at 17:10
  • @Werner Thanks very much; that works and I've learned something new. Is there a way to put \hline (or equivalent) to show the line progressively? I can put \hline, but it shows it across the entire set of columns from the beginning rather than revealing progressively. – ozsu Jan 03 '18 at 17:42
  • @ozsu: One thing to consider here is that you're creating a presentation... and in a presentation you're trying to introduce a flow of the information, which might not follow the convention of the coding. So, in such a case, how about this? It creates separate tabulars that are displayed next to one another. Without spaces between then (due to %), you can display them as needed and everything will line up (rule-wise). If not, you could introduce \phantoms to ensure this. Here is such a paste, just to show what I mean. – Werner Jan 03 '18 at 18:36
  • @Werner Thanks much; I will study both of these. – ozsu Jan 03 '18 at 21:05