如何将 beamer 的页面宽度更改为无限

如何将 beamer 的页面宽度更改为无限

我使用beamerclass 的目的不是制作演示文稿,而是制作 gif。就像使用standalone它制作 png 一样。

但是,beamer使用时,页面宽度似乎是固定的。如果我绘制太多东西,元素可能会超出纸张。使用以下示例,元素D超出可见区域

\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}

在此处输入图片描述

我尝试了shrink框架选项,它可以产生一些效果,但不太自适应,必须手动指定调整大小百分比。有没有办法让 beamer 页面宽度无限大,这样我就不用担心绘图区域了?

答案1

Beamer 使用geometry包来设置页面大小。默认使用 12.80 cm x 9.60 cm,但你可以更改它:

\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}

相关内容