3

In the following MWE I have to frames with the same figure and some stuff below. It works but when switching from frame 1 to frame 2 the tikzpicture element is shifted producing a bad visual effect. How can I remove this shift ?

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{frame}
  \frametitle{FRAME 1}
  \centering
  \begin{tikzpicture}
    \node[draw=black] (a) {A};
    \node[draw=black, right=of a] (b) {B};
    \draw (a) -- (b);
  \end{tikzpicture}
  \begin{block}{Block on frame 1}
    \begin{itemize}
    \item Itemize 1 on frame 1
    \item Itemize 2 on frame 2
    \end{itemize}
  \end{block}
\end{frame}

\begin{frame}
  \frametitle{FRAME 2}
  \centering
  \begin{tikzpicture}
    \node[draw=black] (a) {A};
    \node[draw=black, right=of a] (b) {B};
    \draw (a) -- (b);
  \end{tikzpicture}
  \begin{block}{Block on frame 1}
    \begin{itemize}
    \item Itemize 1 on frame 2
    \item Itemize 2 on frame 2
    \item Itemize 3 on frame 2
    \end{itemize}
  \end{block}
\end{frame}

\end{document}
2

Two options:

  1. Use t as optional argument for both frames; in this way, the frames' content will be top aligned:

    \documentclass{beamer}
    \usepackage{tikz}
    \usetikzlibrary{positioning}
    
    \begin{document}
    
    \begin{frame}[t]
      \frametitle{FRAME 1}
      \centering
      \begin{tikzpicture}
        \node[draw=black] (a) {A};
        \node[draw=black, right=of a] (b) {B};
        \draw (a) -- (b);
      \end{tikzpicture}
      \begin{block}{Block on frame 1}
        \begin{itemize}
        \item Itemize 1 on frame 1
        \item Itemize 2 on frame 1
        \end{itemize}
      \end{block}
    \end{frame}
    
    \begin{frame}[t]
      \frametitle{FRAME 2}
      \centering
      \begin{tikzpicture}
        \node[draw=black] (a) {A};
        \node[draw=black, right=of a] (b) {B};
        \draw (a) -- (b);
      \end{tikzpicture}
      \begin{block}{Block on frame 2}
        \begin{itemize}
        \item Itemize 1 on frame 2
        \item Itemize 2 on frame 2
        \item Itemize 3 on frame 2
        \end{itemize}
      \end{block}
      \begin{tikzpicture}
        \node[draw=cyan,fill=orange!30] (c) {C};
        \node[draw=cyan,fill=orange!30,below=of c] (d) {D};
        \draw (c) -- (d);
      \end{tikzpicture}
    \end{frame}
    
    \end{document}
    

    enter image description here

  2. Use an overlayarea environment (adjust the height of the environment according to your needs). This allows you to have other kinds of objects at the end in the second frame and will still preserve vertical position of the common ones:

    \documentclass{beamer}
    \usepackage{tikz}
    \usetikzlibrary{positioning}
    
    \begin{document}
    
    \begin{frame}
      \frametitle{FRAME 1}
    \begin{overlayarea}{\textwidth}{.6\textheight}
      \centering
      \begin{tikzpicture}
        \node[draw=black] (a) {A};
        \node[draw=black, right=of a] (b) {B};
        \draw (a) -- (b);
      \end{tikzpicture}
      \begin{block}{Block on frame 1}
        \begin{itemize}
        \item Itemize 1 on frame 1
        \item Itemize 2 on frame 1
        \end{itemize}
      \end{block}
    \end{overlayarea}
    \end{frame}
    
    \begin{frame}
      \frametitle{FRAME 2}
    \begin{overlayarea}{\textwidth}{.6\textheight}
      \centering
      \begin{tikzpicture}
        \node[draw=black] (a) {A};
        \node[draw=black, right=of a] (b) {B};
        \draw (a) -- (b);
      \end{tikzpicture}
      \begin{block}{Block on frame 2}
        \begin{itemize}
        \item Itemize 1 on frame 2
        \item Itemize 2 on frame 2
        \item Itemize 3 on frame 2
        \end{itemize}
      \end{block}
    \end{overlayarea}
    \end{frame}
    
    \end{document}
    

    An animation of the result:

    enter image description here

    And with some more objects in the second frame:

    \documentclass{beamer}
    \usepackage{tikz}
    \usetikzlibrary{positioning}
    
    \begin{document}
    
    \begin{frame}
      \frametitle{FRAME 1}
    \begin{overlayarea}{\textwidth}{.6\textheight}
      \centering
      \begin{tikzpicture}
        \node[draw=black] (a) {A};
        \node[draw=black, right=of a] (b) {B};
        \draw (a) -- (b);
      \end{tikzpicture}
      \begin{block}{Block on frame 1}
        \begin{itemize}
        \item Itemize 1 on frame 1
        \item Itemize 2 on frame 1
        \end{itemize}
      \end{block}
    \end{overlayarea}
    \end{frame}
    
    \begin{frame}
      \frametitle{FRAME 2}
    \begin{overlayarea}{\textwidth}{.6\textheight}
      \centering
      \begin{tikzpicture}
        \node[draw=black] (a) {A};
        \node[draw=black, right=of a] (b) {B};
        \draw (a) -- (b);
      \end{tikzpicture}
      \begin{block}{Block on frame 2}
        \begin{itemize}
        \item Itemize 1 on frame 2
        \item Itemize 2 on frame 2
        \item Itemize 3 on frame 2
        \end{itemize}
      \end{block}
      \begin{tikzpicture}
        \node[draw=cyan,fill=orange!30] (c) {C};
        \node[draw=cyan,fill=orange!30,below=of c] (d) {D};
        \draw (c) -- (d);
      \end{tikzpicture}
    \end{overlayarea}
    \end{frame}
    
    \end{document}
    

    The result:

    enter image description here

0

The problem is that the each frame is vertically centered. One way to fix it is to use \pause:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{frame}
  \frametitle{FRAME 1}
  \centering
  \begin{tikzpicture}
    \node[draw=black] (a) {A};
    \node[draw=black, right=of a] (b) {B};
    \draw (a) -- (b);
  \end{tikzpicture}
  \begin{block}{Block on frame 1}
    \begin{itemize}
    \item Itemize 1 on frame 1
    \item Itemize 2 on frame 2
  \pause
    \item Itemize 3 on frame 2
    \end{itemize}
  \end{block}
\end{frame}

\end{document}

Another is to add precisely the right amount of space to account for the difference in height. Alas, beamer does not make that easy. Frankly it is easier to fudge than compute (about 1.22\baselineskip).

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}

\newsavebox{\tempboxa}
\newsavebox{\tempboxb}

\begin{document}

\makeatletter
\savebox{\tempboxa}{\begin{minipage}{\textwidth}%
\let\beamer@cramped=\medskip
  \begin{itemize}
    \item Itemize 1 on frame 1
    \item Itemize 2 on frame 2
  \end{itemize}%
\end{minipage}}

\savebox{\tempboxb}{\begin{minipage}{\textwidth}%
\let\beamer@cramped=\medskip
  \begin{itemize}
    \item Itemize 1 on frame 1
    \item Itemize 2 on frame 2
    \item Itemize 3 on frame 2
  \end{itemize}%
\end{minipage}}
\makeatother

\begin{frame}
  \frametitle{FRAME 1}
  \centering
  \begin{tikzpicture}
    \node[draw=black] (a) {A};
    \node[draw=black, right=of a] (b) {B};
    \draw (a) -- (b);
  \end{tikzpicture}
  \begin{block}{Block on frame 1}

    \usebox{\tempboxa}

    \vspace{\dimexpr \ht\tempboxb+\dp\tempboxb-\ht\tempboxa-\dp\tempboxa}
  \end{block}
\end{frame}

\begin{frame}
  \frametitle{FRAME 2}
  \centering
  \begin{tikzpicture}
    \node[draw=black] (a) {A};
    \node[draw=black, right=of a] (b) {B};
    \draw (a) -- (b);
  \end{tikzpicture}
  \begin{block}{Block on frame 2}

    \usebox{\tempboxb}
  \end{block}
\end{frame}

\end{document}
  • Thank you for the answer, but in practice the itemize are totally different and I really want to have 2 different frames (i.e with a different number) – Manuel Selva Jun 29 '15 at 20:05

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.