从投影仪幻灯片的开头开始逐步显示 tikzpicture

从投影仪幻灯片的开头开始逐步显示 tikzpicture

我编写了以下代码来在 beamer 中构建幻灯片。我希望tikzpicture右列中的图形从幻灯片开始就可见,除了我在 中定义的圆角蓝色矩形tikzpicture,它们应该出现在第二步。此外,到目前为止,当显示这些矩形时(从步骤 1 到步骤 2),我实现的结果是“移动”图形:这不应该发生!

你可以帮帮我吗?

\documentclass[10pt,xcolor={dvipsnames}]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{tikz}

\mode<presentation>{
    \usetheme{Frankfurt}
    \useinnertheme{default}
    \useoutertheme{default}
    \usecolortheme{default}
    \setbeamercovered{transparent}
    \setbeamercolor{block body example}{fg=black,bg=Blue!10}
    \setbeamercolor{postit}{fg=black,bg=OliveGreen!20}
    \setbeamercolor{postit2}{fg=yellow,bg=OliveGreen}
}

\setbeamersize{text margin left=2em, text margin right=2em}

\begin{document}
\begin{frame}{TITLE}
    \begin{columns}[c]
        \begin{column}{.75\textwidth}
        The black graph should already be visible...\\
        \smallskip
        \pause
        Here the blue rectangles should appear and remain visible until the end...\\
        \smallskip
        \pause
        Line 3...\\
        \smallskip
        \pause
        Line 4...\\
        \end{column}
        \begin{column}{.2\textwidth}
           \visible<1->{
            \begin{tikzpicture}[scale=.8,vertex/.style={
    circle,fill=black,minimum size=5pt,inner sep=0pt}]
                %% vertices
                \node[vertex] (V1) at (0,0) {};
                \node[vertex] (V2) at (.5,1) {};
                \node[vertex] (V3) at (1.5,1.5) {};
                \node[vertex] (V4) at (1,.5) {};
                \node[vertex] (V5) at (1,-1) {};
                \node[vertex] (V6) at (.75,-2) {};
                \node[vertex] (V7) at (1.25,-2) {};
                \node[vertex] (V8) at (-.75,-.75) {};
                %% vertex labels
                \node at (-.25,.25) {$a_1$};
                %% edges
                \draw[dashed] (.25,1.75) -- (V2) -- (.75,1.75);
                \draw[dashed] (1.75,.75) -- (V4) -- (1.75,.25);
                \draw[dashed] (V6) -- (.75,-2.5);
                \draw[dashed] (V7) -- (1.25,-2.5);
                \foreach \from/\to in {V1/V2,V2/V3,V3/V4,V4/V1,V1/V5,V5/V6,V5/V7,V1/V8}
                   \draw[thick] (\from) -- (\to);
               %% connected components
               \draw<2->[blue,thick,rounded corners] (.15,.15) rectangle (1.9,1.9) {};
               \draw<2->[blue,thick,rounded corners] (-1.25,-1.25) rectangle (-.25,-.25);
               \draw<2->[blue,thick,rounded corners] (.5,-3) rectangle (1.5,-.5);
            \end{tikzpicture}
            }
        \end{column}
    \end{columns}
\end{frame}
\end{document}

答案1

我想知道这是否是预期的行为投影机因为我认为要得到你想要的东西,用等包围相关代码就足够了,\uncover<1->{...}但这对我来说不起作用。问题似乎出在前面的\pause命令上,但我确信我以前做过这个。也许是环境columns阻碍了?

\pause[0]无论这是否是预期的行为,您都可以通过插入环境前的暂停计数器来“重置”该问题tikzpicture。一旦您这样做,它就会\uncover...按预期工作并产生:

在此处输入图片描述

如图所示,如果您在tikzpicture环境之后有想要逐步显示的材料,那么您需要添加\pause[5]重新同步暂停计数器。

完整代码如下:

\documentclass[10pt,xcolor={dvipsnames}]{beamer}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{tikz}

\mode<presentation>{
    \usetheme{Frankfurt}
    \useinnertheme{default}
    \useoutertheme{default}
    \usecolortheme{default}
    \setbeamercovered{transparent}
    \setbeamercolor{block body example}{fg=black,bg=Blue!10}
    \setbeamercolor{postit}{fg=black,bg=OliveGreen!20}
    \setbeamercolor{postit2}{fg=yellow,bg=OliveGreen}
}

\setbeamersize{text margin left=2em, text margin right=2em}

\begin{document}
\begin{frame}{TITLE}
    \begin{columns}[c]
        \begin{column}{.75\textwidth}
        The black graph should already be visible...\\
        \smallskip
        \pause
        Here the blue rectangles should appear and remain visible until the end...\\
        \smallskip
        \pause
        Line 3...\\
        \smallskip
        \pause
        Line 4...\\
        \end{column}
        \pause[0]
        \begin{column}{.2\textwidth}
            \begin{tikzpicture}[scale=.8,vertex/.style={
    circle,fill=black,minimum size=5pt,inner sep=0pt}]
                %% vertices
                \uncover<1->{
                  \node[vertex] (V1) at (0,0) {};
                  \node[vertex] (V2) at (.5,1) {};
                  \node[vertex] (V3) at (1.5,1.5) {};
                  \node[vertex] (V4) at (1,.5) {};
                  \node[vertex] (V5) at (1,-1) {};
                  \node[vertex] (V6) at (.75,-2) {};
                  \node[vertex] (V7) at (1.25,-2) {};
                  \node[vertex] (V8) at (-.75,-.75) {};
                  %% vertex labels
                  \node at (-.25,.25) {$a_1$};
                  %% edges
                  \draw[dashed] (.25,1.75) -- (V2) -- (.75,1.75);
                  \draw[dashed] (1.75,.75) -- (V4) -- (1.75,.25);
                  \draw[dashed] (V6) -- (.75,-2.5);
                  \draw[dashed] (V7) -- (1.25,-2.5);
                  \foreach \from/\to in {V1/V2,V2/V3,V3/V4,V4/V1,V1/V5,V5/V6,V5/V7,V1/V8}
                     \draw[thick] (\from) -- (\to);
                }
               %% connected components
               \uncover<2->{
                 \draw[blue,thick,rounded corners] (.15,.15) rectangle (1.9,1.9) {};
                 \draw[blue,thick,rounded corners] (-1.25,-1.25) rectangle (-.25,-.25);
                 \draw[blue,thick,rounded corners] (.5,-3) rectangle (1.5,-.5);
               }
            \end{tikzpicture}
        \end{column}
    \end{columns}
    \pause[5]
    Some stuff at the end
\end{frame}
\end{document}

相关内容