1

The following beamer MWE consists of 5 slides. I use nested overprint environments to achieve overlay effects without wobbling spacing. On slides 2 and 3, the text "two and three" should appear, on slide 3 there should be an additional "three". Similarly on slides 4 and 5.

However, the second nested overlay environment seems to break the first \onslide; it just does not appear. A single nested overprint in the first \onslide works fine (comment the second nested overprint to see this).

Is overprint just not designed to be nested (I didn't find anything about this in the documentation) or is this a bug? How can I get around this without duplicating code?

\documentclass{beamer}

\begin{document}

\begin{frame}
  Always

  \begin{overprint}
    \onslide<2-3>
      two and three

      \begin{overprint}
        \onslide<3>
          three
      \end{overprint}

    \onslide<4-5>
      four and five

      \begin{overprint}
        \onslide<5>
          five
      \end{overprint}
  \end{overprint}

  Always
\end{frame}

\end{document}
5
  • If I put braces around the \onslide arguments, I get a somewhat different result. Can you test this and if possible explicitely state the output you would like ? I am not sure it is required to nest the overprints here
    – BambOo
    May 17 '20 at 12:14
  • 1
    A side-note, overlayareas can seemingly be nestes see tex.stackexchange.com/questions/205177/nested-overlayareas for an example
    – BambOo
    May 17 '20 at 12:16
  • @BambOo The result obtained by adding spaces is not quite what I want (the different stages of overprint are not actually printed over each other, i.e. in the same place, with braces). overlayareas may be a workaround, though I would really prefer not having to specify the height of the area.
    – schtandard
    May 17 '20 at 13:34
  • So you want to print e.g. "two and three" and "four and five" on the same line, that's it ?
    – BambOo
    May 17 '20 at 13:44
  • I just posted an answer that seems to fit your description of the desired output
    – BambOo
    May 17 '20 at 14:21
0

After tweaking a bit the overlay specifications :

\documentclass{beamer}

\begin{document}

\begin{frame}
  Always

  \begin{overprint}
    \only<1-3>{
      \onslide<2-3>{two and three

      \begin{overprint}
        \onslide<3>{
          three}
      \end{overprint}
      }
    }
    \only<4-5>{
      four and five

      \begin{overprint}
        \onslide<5>{
          five}
      \end{overprint}
    }
  \end{overprint}
\end{frame}

\end{document}

enter image description here

EDIT : Correction of additional vertical spaces. These are likely due to inserted newlines by default. Adding the appropriate % as end of lines gives the expected result.

\documentclass{beamer}

\begin{document}

\begin{frame}
  Always

  \begin{overprint}
    \only<1-3>{%
      \onslide<2-3>{two and three

      \begin{overprint}
        \onslide<3>{three}%
      \end{overprint}%
      }%
    }%
    \only<4-5>{%
      four and five

      \begin{overprint}
        \onslide<5>{five}%
      \end{overprint}%
    }%
  \end{overprint}%

  Always
\end{frame}

\end{document}

enter image description here

4
  • While the output of this example looks like what I want at first glance, using \only in overprint instead of \onslide causes new problems. The height of the environment is the same as all of its content printed below each other. I added another line of text after the environment in the MWE to illustrate the problem.
    – schtandard
    May 17 '20 at 14:45
  • @schtandard It seems to be due to newline insertion, more than the height of the overprints. See the edit
    – BambOo
    May 17 '20 at 15:01
  • Thanks for the edit, but there are still problems with this. When the different overlays do not have the same height, this gets "wobbly". Try for example to replace five by five\\five\\five. As I understand it, overprint really is only meant to be used with \onslide and anything else will break its functionality.
    – schtandard
    May 17 '20 at 15:13
  • 1
    @schtandard Yes, unfortunately it seems you are right. The only way to go appears to be \overlayareas
    – BambOo
    May 17 '20 at 15:56
0

If I understand correctly using braces should solve your problem:

\documentclass{beamer}

\begin{document}

\begin{frame}
  Always

  \begin{overprint}
    \onslide<2-3>{
      two and three}

      \begin{overprint}
        \onslide<3>{
          three}
      \end{overprint}

    \onslide<4-5>{
      four and five}

      \begin{overprint}
        \onslide<5>{
          five}
      \end{overprint}
  \end{overprint}
\end{frame}

\end{document}

enter image description here

EDIT

Using the textpos package (absolute positioning)

\documentclass{beamer}
\usepackage[absolute,overlay
%,showboxes
]{textpos}
\TPGrid{3}{5}

\begin{document}

\begin{frame}
    \begin{textblock}{1}(0.5,2)
Always

\onslide<2-3>{two and three}

\onslide<3>{three}
    \end{textblock}

    \begin{textblock}{1}(0.5,2)
\invisible{Always}

\onslide<4-5>{four and five}

\onslide<5>{five}

Always
    \end{textblock}

\end{frame}


\end{document}

enter image description here

2
  • This is not quite what I wanted. The text "four and five \\ five" should occupy the same space as "two and three \\ three". (That's the point of the overprint environment.)
    – schtandard
    May 17 '20 at 13:32
  • @schtandard Oh sorry! When I want get the effect that you want I use the textpos package
    – vi pa
    May 18 '20 at 22:21

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.