1

I try to show frame in 4 slides. First 2 are fine, but I fail in showing a table using two slides. Content of first column appears correctly - only on slide 4, but borders around this column are still shown

\documentclass[12pt]{beamer}
%\documentclass[12pt,handout]{beamer}
\usepackage{multirow} %Used for tables with merged cells
\usepackage{collcell} %pdflatex.exe hangs without this one

\begin{document}
  \begin{frame}{Communication Models}

  \begin{itemize}[<+->]
    \item OSI
    \item TCP/IP
  \end{itemize}

  \onslide<3->
  \begin{center}
  %Works almost fine, but first column should disappear fully (not just text)
  \begin{tabular}{|>{\onslide<4->}l<{\onslide<3->}|l|l|l|}
    \hline
    \textbf{Mnemonic}&  \textbf{\#} & \textbf{OSI} & \textbf{TCP/IP}              \\ \hline
    All              &  7           & Application  & \multirow{3}{*}{Application} \\ \cline{1-3}
    People           &  6           & Presentation &                              \\ \cline{1-3}
    Seem             &  5           & Session      &                              \\ \hline
    To               &  4           & Transport    & Transport                    \\ \hline
    Need             &  3           & Network      & Internet                     \\ \hline
    Data             &  2           & Data Link    & \multirow{2}{*}{Link Access} \\ \cline{1-3}
    Processing       &  1           & Physical     &                              \\ \hline
  \end{tabular}
  \end{center}
  \end{frame}
\end{document}

Instead of:

\begin{tabular}{|>{\onslide<4->}l<{\onslide<3->}|l|l|l|}

I tried to use:

\begin{tabular}{>{\onslide<4->}|l<{\onslide<3->}|l|l|l|}
\begin{tabular}{ \ifnum\slideno>3 | \fi >{\onslide<4->}l<{\onslide<3->}|l|l|l|}

but first version gives:

! Package array Error: >{..} at wrong position: token ignored.

and second:

! Package array Error: Illegal pream-token (\ifnum): `c' used.

Is it possible to make first column to be hidden on several slides completely (including borders)?



Solution, based on Piet's answer (UPD2)

Updated solution (UPD3) uses page-independent slideinframe counter, which is counted for each frame separately

This solution uses \newcolumntype{G} for first column, which does not appear at slide 3, but appears at slide 4 and handouts.

% Add line below to preamble
\def\Gobble#1\EndGobble{}
% UPD3: 3 lines below define slide counter within a frame (found here: http://tex.stackexchange.com/a/120940/119704)
\makeatletter
\def\c@slideinframe{\beamer@slideinframe}
\makeatother
...
% Add lines below to body (before tabular, and edit tabular definition)
% Next line is to show first column on handouts
\newcolumntype{G}{|l}
% Rules below hide first column on first 3 slides of beamer presentation, no influence on handouts
\only{beamer}{
  % UPD3: Change "page" to "slideinframe"
  %\ifnum\value{page}>3 \newcolumntype{G}{|l}\else
  \ifnum\value{slideinframe}>3 \newcolumntype{G}{|l}\else
  % I would be grateful if someone could describe the magic below :)
  \newcolumntype{G}{@{}>{\Gobble}l<{\EndGobble}@{}}\fi
}
% Apply newcolumntype
\begin{tabular}{G|l|l|l|}

Solution based on samcarter's workaround (UPD1)

Draw a rectangle with color, equal to background color This solution needs fine tuning (position and size of the rectangle)

% Add line below to preamble:
\usepackage{tikz}
...
% Add lines to the end of frame:
  \only<beamer>{
    \vspace*{-4.7cm}
    \begin{tikzpicture}
      \begin{onlyenv}<3>
        \draw [color=bg, fill=bg] (0,0) rectangle (3.67,4.3); 
      \end{onlyenv}
    \end{tikzpicture}
  }
\end{frame}
\end{document}
1

Edit: I have changed this to a slightly cleaner solution with \newcolumntype.

You cannot put macros in a tabular spec that have to be expanded at definition time. You you must make the whole begin{tabular}{...} line conditional. And then you still have the first column text that must be swallowed up.

Alternatively, define a new columntype, conditional on the slide number. Here is an example:

\documentclass[12pt]{beamer}
\usepackage{multirow} %Used for tables with merged cells
\usepackage{collcell} %pdflatex.exe hangs without this one

\def\Gobble#1\EndGobble{}
\begin{document}
  \begin{frame}{Communication Models}

  \begin{itemize}[<+->]
    \item OSI
    \item TCP/IP
  \end{itemize}

  \onslide<3-4>
  \begin{center}
  \only<3> {\newcolumntype{G}{@{}>{\Gobble}l<{\EndGobble}@{}}}
  \only<4> {\newcolumntype{G}{|l}}

   \begin{tabular}{G|l|l|l|}
    \hline
    \textbf{Mnemonic}&  \textbf{\#} & \textbf{OSI} & \textbf{TCP/IP}              \\ \hline
    All              &  7           & Application  & \multirow{3}{*}{Application} \\ \cline{1-3}
    People           &  6           & Presentation &                              \\ \cline{1-3}
    Seem             &  5           & Session      &                              \\ \hline
    To               &  4           & Transport    & Transport                    \\ \hline
    Need             &  3           & Network      & Internet                     \\ \hline
    Data             &  2           & Data Link    & \multirow{2}{*}{Link Access} \\ \cline{1-3}
    Processing       &  1           & Physical     &                              \\ \hline
  \end{tabular}
  \end{center}
  \end{frame}
\end{document}
  • Cool! That works much cleaner, compared to workaround with rectangle. Unfortunately, I cannot understand how this works (could you please explain Gobble trick?) and [therefore?] cannot make this column appear on handout slides \documentclass[12pt,handout]{beamer}, is this possible? – aleksashka Nov 27 '16 at 15:43
  • The slide 3 G column places \Gobble before the entry and \EndGobble after the entry, so it processes \Gobble your entry \EndGobble, which is defined by the \def to produce nothing. – Piet van Oostrum Nov 27 '16 at 15:55
  • Yeees! I did it! Now handouts do not hide the column! Thanks a lot @Piet I added \newcolumntype{G}{|l} and enclosed your \if\else\fi solution in \only<beamer>{} – aleksashka Nov 27 '16 at 16:48
  • Could you please help again, @Piet? The solution above doesn't work (doesn't hide a column) if I add (even an empty) frame before the one with your answer. Everything is fine if there are frames after, despite the same trick doesn't work again (I made another copy of the same frame with your trick and it works for the first frame, but not the second). – aleksashka Nov 29 '16 at 11:29
  • If you add a frame then the numbers must be changed. The 3 must become 4. – Piet van Oostrum Nov 29 '16 at 11:34
1

Workaround: place a rectangle with the same colour as the background over the table.

EDIT: now with relative overlay instructions - so it should not matter how many slides are inserted before the table.

\documentclass[12pt]{beamer}
\usepackage{multirow} %Used for tables with merged cells
\usepackage{collcell} %pdflatex.exe hangs without this one

\usepackage{tikz}

\begin{document}
  \begin{frame}{Communication Models}

          \pause

      \begin{tabular}{|l|l|l|l|}
        \hline
        \textbf{Mnemonic}&  \textbf{\#} & \textbf{OSI} & \textbf{TCP/IP}              \\ \hline
        All              &  7           & Application  & \multirow{3}{*}{Application} \\ \cline{1-3}
        People           &  6           & Presentation &                              \\ \cline{1-3}
        Seem             &  5           & Session      &                              \\ \hline
        To               &  4           & Transport    & Transport                    \\ \hline
        Need             &  3           & Network      & Internet                     \\ \hline
        Data             &  2           & Data Link    & \multirow{2}{*}{Link Access} \\ \cline{1-3}
        Processing       &  1           & Physical     &                              \\ \hline
      \end{tabular}

      \vspace*{-4.21cm}
      \begin{tikzpicture}
          \begin{onlyenv}<.(1)>
              \draw [color=bg, fill=bg] (0,0) rectangle (2.42,4.2); 
          \end{onlyenv}
      \end{tikzpicture}
      \pause
  \end{frame}
\end{document}

enter image description here

  • Well, at least this works :). I just had to add \only<beamer>{} around a rectangle, so that it is not shown on handouts. – aleksashka Nov 27 '16 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.