4

My purpose to use beamer class is not to make a presentation, instead I just want to make gifs. Like using standalone for make pngs.

However, when beamer is used, seems the page width is fixed. If I draw too many things, the element may go out of the paper. Using the following example, element D comes out of visible area

\documentclass[border=5mm, usenames, dvipsnames]{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning, calc, arrows.meta, matrix, chains, scopes, fit}
\usetikzlibrary{overlay-beamer-styles}
\begin{document}
    \tikzset{myrect/.style n args = {4}{font=\footnotesize \ttfamily, align=left, rounded corners, rectangle, minimum width=#1cm, minimum height=#2cm, fill=#3, draw=#4}}
    \tikzset{myrect/.default={3}{1}{white}{black}}
    \tikzset{mycon/.style = {rounded corners}}
    \begin{frame}[t,fragile]
        \begin{tikzpicture}
            \matrix (layer1) [matrix of nodes, nodes={myrect}, column sep=1cm] {
                A&
                |[visible on=<2->]| B&
                |[visible on=<3->]| C&
                |[visible on=<4->]| D\\
            };
            {
                [start chain,every on chain/.style={join}, every join/.style={->}]
                \chainin (layer1-1-1) [];
                \only<5->{\chainin (layer1-1-2) [];}
                \only<6->{\chainin (layer1-1-3) [];}
                \only<7->{\chainin (layer1-1-4) [];}
            }
        \end{tikzpicture}
    \end{frame}
\end{document}

enter image description here

I tried the shrink option for frame, it can take some effect, but not quite adaptive, have to specify the resize percentage manually. Is there ways to make beamer page width infinite so that I don't need to worry about the draw area?

  • Have a look at this nice solution by @Daniel to combine standalone and overlays – BambOo Aug 21 '18 at 9:17
  • What is the conceptual difference between producing PNGs and GIF? – AlexG Aug 23 '18 at 10:46
  • @AlexG, I want to generate animations using gif. So I use beamer instead of standalone – Eric Sun Aug 31 '18 at 8:48
4

Beamer use the geometry package to set the page size. As default is uses 12.80 cm x 9.60 cm, but you can change it:

\documentclass[border=5mm, usenames, dvipsnames]{beamer}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning, calc, arrows.meta, matrix, chains, scopes, fit}
\usetikzlibrary{overlay-beamer-styles}

\makeatletter
\geometry{papersize={32cm,\beamer@paperheight}}
\makeatother
\begin{document}
    \tikzset{myrect/.style n args = {4}{font=\footnotesize \ttfamily, align=left, rounded corners, rectangle, minimum width=#1cm, minimum height=#2cm, fill=#3, draw=#4}}
    \tikzset{myrect/.default={3}{1}{white}{black}}
    \tikzset{mycon/.style = {rounded corners}}
    \begin{frame}[t,fragile]
        \begin{tikzpicture}
            \matrix (layer1) [matrix of nodes, nodes={myrect}, column sep=1cm] {
                A&
                |[visible on=<2->]| B&
                |[visible on=<3->]| C&
                |[visible on=<4->]| D\\
            };
            {
                [start chain,every on chain/.style={join}, every join/.style={->}]
                \chainin (layer1-1-1) [];
                \only<5->{\chainin (layer1-1-2) [];}
                \only<6->{\chainin (layer1-1-3) [];}
                \only<7->{\chainin (layer1-1-4) [];}
            }
        \end{tikzpicture}
    \end{frame}
\end{document}

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.