2

In beamer, I'm trying to create a row-by-row tabular set of slides: each slide exposes a new row. I've solved a lot of problems, but I'm still having issues with a extra partial row being generated. (See picture) If I comment out the invisible rows, no extra row is generated. But of course I lose the row-by-row display I'm after.

Thoughts?

enter image description here

3
  • 2
    Please help us to help you by providing a so called minimal working example (MWE) something that starts with \documentclass and ends with \end{document} and specially not a screenshot. Feb 13, 2019 at 17:56
  • You can't use only inside a tabular environment... You could cut the tabular into complete pieces (each one inside an \only command and being a complete tabular) instead and add an appropriate space (computed through a savebox by \ht\mybox and \dp\mybox and another \savebox of the whole tabular that will give the appropriate vertical space needed in each \only command)... It is somehow complicated but possible. Please follow the commant of @HafidBoukhoulda in order to get a possible answer that fit your needs.
    – koleygr
    Feb 13, 2019 at 18:51
  • So why can't \only be used in tabular environment? Feb 14, 2019 at 7:18

2 Answers 2

5

The following defines a command \tableonly that should work inside a tabular environment (it did for my small test file).

Have fun with it.

\documentclass[]{beamer}

\usepackage{array}
\newcolumntype\math[1]{>{\(}#1<{\)}}
\newcounter{iteration}
\makeatletter
\newcommand*\tableonly%>>>
  {%
    \omit\@ifnextchar<\table@only\table@@only
  }%<<<
\protected\long\def\table@only<#1>#2%>>>
  {%
    \gdef\beamer@doifnotinframe{\cr}%
    \def\beamer@doifinframe{\cr#2}%
    \beamer@masterdecode{#1}%
    \beamer@donow
  }%<<<
\protected\long\def\table@@only#1%>>>
  {%
    \beamer@ifnextcharospec{\table@@@only{#1}}{\cr#1}%
  }%<<<
\long\def\table@@@only#1<#2>%>>>
  {%
    \gdef\beamer@doifnotinframe{\cr}%
    \def\beamer@doifinframe{\cr#1}%
    \beamer@masterdecode{#2}%
    \beamer@donow
  }%<<<
\makeatother
\begin{document}
\begin{frame}{table}{example}% >>>
  \only<1->
    {%
      \begin{tabular}[]{|\math{c}||*3{\math{c}|}}
        \hline
        \multicolumn{1}{|c||}{Iteration} & x & d & s \\
        \hline
        \hline
        \tableonly<2->{0 & 1 & 2 & 3 \\\hline}
        \tableonly<3->{1 & 1 & 2 & 3 \\\hline}
        \tableonly<4->{2 & 1 & 2 & 3 \\\hline}
        \tableonly<5->{3 & 1 & 2 & 3 \\\hline}
      \end{tabular}%
    }%
\end{frame}% <<<

\end{document}

enter image description here

6
  • +1 but it has problems if a word in second line fore example is longer that the word in the word of the same column before it appears...
    – koleygr
    Feb 13, 2019 at 19:14
  • 1
    @koleygr that's naturally, \only does never preserve the space.
    – Skillmon
    Feb 13, 2019 at 19:21
  • Thanks @Skillmon... I forgot that because I supposed the op would like to show the tabular part by part without "jumbs" through slides
    – koleygr
    Feb 13, 2019 at 19:23
  • Thanks for the answer- but this will take me about 4 hours of study to understand :-) Feb 14, 2019 at 7:24
  • @theHampster all it does is add \omit and \cr to the code of \only, the rest is copy paste of beamer's code.
    – Skillmon
    Feb 14, 2019 at 10:21
2

Here is the way in my comment:

\documentclass{beamer}

\newsavebox\wholeTabular
\newsavebox\partTabular
\newsavebox\fullPartTabular
\newsavebox\LongerWordBox
\newcommand\readWhole[2]{\savebox\wholeTabular{\vbox{\begin{center}\begin{tabular}{#1}#2\end{tabular}\end{center}}}}
\newcommand\readPart[2]{\savebox\partTabular{\vbox{\begin{center}\begin{tabular}{#1}#2\end{tabular}\end{center}}}\savebox\fullPartTabular{\vbox{\begin{center}\begin{tabular}{#1}#2\end{tabular}\vspace*{\dimexpr\ht\wholeTabular+\dp\wholeTabular-\ht\partTabular-\dp\partTabular}\end{center}}}}


\begin{document}
\begin{frame}{Title}

\readWhole{lll}{%
First & 1-1 & 1-2\\
Second & 2-1 & 2-2\\
Third & 3-1 & 3-2
}

\savebox\LongerWordBox{Second}

\readPart{lll}{%
\parbox[t]{\wd\LongerWordBox}{First\hfill} & 1-1 & 1-2\\}

\only<1>{\usebox\fullPartTabular}

\readPart{lll}{%
First & 1-1 & 1-2\\
Second & 2-1 & 2-2\\}

\only<2>{\usebox\fullPartTabular}

\only<3>{\usebox\wholeTabular}


\end{frame}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .