1

I'm trying to show alternative column configurations on a beamer slide, as shown in this example:

\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
     \begin{columns}
        \begin{column}{0.3\textwidth}
            \tikz{\draw (0,0) rectangle (\textwidth, 1cm);}
        \end{column}
        \only<1>{\begin{column}{0.6\textwidth}
            \tikz{\draw (0,0) rectangle (\textwidth, 1cm);}
        \end{column}}
        \only<2>{\begin{column}{0.6\textwidth}
            \tikz{\draw (0,0) rectangle (\textwidth, 1cm);}
        \end{column}}
    \end{columns}
\end{frame}
\end{document}

Here, I create two identical columns right of a column that stays the same during all slides. However, it is positioned differently on slide 1 and 2. What am I doing wrong?

1

Your code introduces an unwanted space at the end of second column which moves them between first and second slide. If you add % at the end of \end{colum}} lines, your problem will be solved.

\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
     \begin{columns}
        \begin{column}{0.3\textwidth}
            \tikz{\draw (0,0) rectangle (\textwidth, 1cm);}
        \end{column}
        \only<1>{\begin{column}{0.6\textwidth}
            \tikz{\draw (0,0) rectangle (\textwidth, 1cm);}
        \end{column}}% <--- comment here
        \only<2>{\begin{column}{0.6\textwidth}
            \tikz{\draw (0,0) rectangle (\textwidth, 1cm);}
        \end{column}}% <--- comment here
    \end{columns}
\end{frame}
\end{document}

Some more information about about unwanted spaces:

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.