4

I am trying to make a simple animation to change rows of a tabular from normal text to bold text. I tried to do it with \only and \alt, but I end up getting an extra space in the beginning of the row.

My question is: Is there a way to apply overlay on the entire row and not have the extra space?

So far I have the following code:

\begin{tabular}{l l}
  \hline
  Foo & Bar\\
  \hline
  \alt<2>{
    \textbf{Foo} & \textbf{Bar}\\
  }{
    Foo & Bar\\
  }
  Foo & Bar\\
  \hline
\end{tabular}

And the result: Tabular with extra space (time 1) Tabular with extra space (time 2)

1
  • Welcome to TeX.SX! It should be }{%. You are inserting some spurious space in your seventh line of code. Please make your example compilable. This makes it easier for us to help. Thanks.
    – LaRiFaRi
    Commented May 18, 2015 at 8:10

1 Answer 1

5

You introduced some spurious space by adding new lines in your code. Just get rid of the new lines or use % at its end. The very problem here was your seventh line of code.

% arara: pdflatex

\documentclass{beamer}
\usepackage{booktabs}

\begin{document}
\begin{frame}
    \begin{tabular}{ll}
        \toprule
        Foo & Bar\\
        \midrule
        \alt<2>{\textbf{Foo} & \textbf{Bar}
        }{% % you had an extra space here introduced by the new line of code. Write it on one line or add an % at the end of it. 
        Foo & Bar}\\
        Foo & Bar\\
        \bottomrule
    \end{tabular}
\end{frame}
\end{document}

enter image description here


Apart from this, I would recommend to use \begin{tabular}{*{2}{p{.585cm}}}. Like this, your 'animation' will result better...

% arara: pdflatex

\documentclass{beamer}
\usepackage{booktabs}

\begin{document}
\begin{frame}
    \begin{tabular}{*{2}{p{.585cm}}}\toprule
        Foo & Bar\\\midrule
        \alt<2>{\textbf{Foo} & \textbf{Bar}}{Foo & Bar}\\
        Foo & Bar\\\bottomrule
    \end{tabular}

    \begin{tabular}{*{2}{l}}\toprule
        Foo & Bar\\\midrule
        \alt<2>{\textbf{Foo} & \textbf{Bar}}{Foo & Bar}\\
        Foo & Bar\\\bottomrule
    \end{tabular}
\end{frame}
\end{document}

enter image description here

enter image description here

2
  • Thank you very much for the answer and the recommendation!
    – mshcruz
    Commented May 18, 2015 at 8:22
  • @Unwise You are very welcome.
    – LaRiFaRi
    Commented May 18, 2015 at 8:24

You must log in to answer this question.

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