# Extra space when using tabular and overlay

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:

• 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 May 18 '15 at 8:10

## 1 Answer

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}


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}


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