1

I have a TikZ picture that is animated. Unfortunately, that causes jumps in the content, as the centering is apparently not considering the animation.

I resize the picture with an adjustbox, so it fits the page nicely.

Is there a way to avoid page jumps in such a setup?

MWE:

\documentclass{beamer}
\usetheme{metropolis}
\usepackage{adjustbox}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{frame}{Demo}
    \begin{adjustbox}{max width=\textwidth}
        \begin{tikzpicture}[node distance=40pt]
            \node<+-> [draw] (one) {One};
            \node<+-> [draw,below=of one] (two) {Two};
        \end{tikzpicture}
    \end{adjustbox}
\end{frame}
\end{document}
clel
  • 325
  • Potentially scaling elements which contain text is not the best of ideas, see e.g. https://tex.stackexchange.com/questions/425453/why-not-scale-elements-that-contain-text – samcarter_is_at_topanswers.xyz Jun 27 '23 at 20:57
  • Thanks for the link. Currently, the approach seems to be the most forward one, though. That way, it can be easily ensured that all content fits the page. As long as the scaling is not applied with too high factors, I think that should be a good tradeoff. Still, it is good to be aware of the side effects! – clel Jun 27 '23 at 21:07
  • Even if the scaling factors are not too big, you get a mixture of many different sizes in your presentation. This can make it more like a ransom letter than a thought through presentation. – samcarter_is_at_topanswers.xyz Jun 27 '23 at 21:22
  • You might find this question helpful: https://tex.stackexchange.com/q/18704/86 – Andrew Stacey Jun 28 '23 at 05:58

1 Answers1

1

You can avoid the jumping if the elements are present (but not visible) on all overlays, e.g. with the overlay-beamer-styles library:

\documentclass{beamer}
\usetheme{moloch}% modern fork of the metropolis theme
\usepackage{adjustbox}
\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
\usetikzlibrary{positioning}
\begin{document}
\begin{frame}{Demo}
    \begin{adjustbox}{max width=\textwidth}
        \begin{tikzpicture}[node distance=40pt]
            \node[visible on=<+->] [draw] (one) {One};
            \node[draw,below=of one,visible on=<+->] (two) {Two};
        \end{tikzpicture}
    \end{adjustbox}
\end{frame}
\end{document}

enter image description here

  • Awesome, I wasn't aware of that library! Thanks so much. Apparently, this requires a specific format for the overlays (inside the brackets)? I am fine with that, just curious. – clel Jun 27 '23 at 20:51
  • @clel Almost all of the normal beamer overlay syntax will work for the overlay-beamer-styles library (there are some edge cases, but unlikely you will run into them) – samcarter_is_at_topanswers.xyz Jun 27 '23 at 20:55
  • Hm, the \node<+-> [draw] (one) {One}; syntax from my MWE didn't work for me, as that still had the jumps. I also looked for documentation of the library, but couldn't find any, unfortunately. If you have hints to both problems, that'd be very appreciated. – clel Jun 27 '23 at 21:01
  • @clel You can get the doc if you run texdoc aobs or from https://texdoc.org/serve/aobs-tikz/0 if you don't have the docs installed – samcarter_is_at_topanswers.xyz Jun 27 '23 at 21:18
  • 1
    @clel With \node<+-> the node is not present on earlier overlays. With visible on=<+-> it is present, just not visible – samcarter_is_at_topanswers.xyz Jun 27 '23 at 21:19
  • Docs: Are you sure? I also found that package, but it states, that it makes use of the library; so sounds like it is not the library doc itself. Also, reading further through the docs didn't give any helpful information about the library. – clel Jun 28 '23 at 09:31
  • The library is part of the package. Basically everything in the doc reveres to the library. The package version is just a wrapper which loads tikz and the library. – samcarter_is_at_topanswers.xyz Jun 28 '23 at 09:34
  • Really? Then the options that the library provides (like visible on=) seem not documented well. – clel Jun 28 '23 at 09:36
  • Makes sense that this option then doesn't cause page jumps. Alright. I just checked and it seems that the library provides the option, so basically both are needed in combination to make it work as intended. – clel Jun 28 '23 at 09:37