一张幻灯片中包含文本和 tikz 动画

一张幻灯片中包含文本和 tikz 动画

我找到了一个 TikZ 动画示例这里

下一步我尝试将文本放在动画旁边,执行以下操作:

\documentclass{beamer}
\usepackage{tikz}
\usepackage{animate}
\usepackage{ifthen}
\definecolor{darkgreen}{RGB}{10,90,10}

\begin{document}
    \begin{frame}
        \begin{columns}
        \begin{column}{0.5\textwidth}
            some text here some text here some text here some text here some text here
        \end{column}
        \begin{column}{0.5\textwidth}
            \begin{animateinline}[controls,loop]{50}
                \multiframe{180}{rt=-45+1}{%
                    \begin{tikzpicture}
                    \ifthenelse{\rt < 45}
                    {\draw[rounded corners,fill=cyan,rotate around={180-\rt:(2,0.2)}] (0,0) rectangle (4,0.4);\draw [fill=white] (2,0.2) circle (1mm);\draw[fill=darkgreen] (2,0.2) circle (0.5mm);}
                    {\draw[rounded corners,fill=darkgreen,rotate around={90+\rt:(2,0.2)}] (0,0) rectangle (4,0.4);\draw [fill=white] (2,0.2) circle (1mm);\draw[fill=cyan] (2,0.2) circle (0.5mm);};
        %               \draw [fill=black] (2,0.2) circle (1mm);
                    %the following lines are not meant to be on the animation
                    \draw [>=stealth,->,very thick] ([shift=(175:2.15)]2,0.2) arc (175:135:2.15) node[xshift=-5pt,left] {$+45^\circ$};
                    \draw [>=stealth,->,very thick] ([shift=(185:2.15)]2,0.2) arc (185:225:2.15) node[xshift=-5pt,left] {$-45^\circ$};
                    \node at (4.0,4.0) {}; %phantom node
                    \node at (-4.0,-4.0) {}; %phantom node
                    \end{tikzpicture}}%
            \end{animateinline}
        \end{column}
        \end{columns}
    \end{frame} 
\end{document}

我该如何更改代码,使文本位于第一列而动画完全位于第二列内?

答案1

就目前而言,它tikzpicture太宽了,无法放入右列。幻影节点在可见图形对象周围添加了太多空白。

动画的垂直延伸和左侧边界由文本标签“+45°”和“-45°”决定。只有右侧边界需要修复,这确实可以通过幻影节点或其他不可见对象来完成。

修复后的代码可能如下所示:

\documentclass{beamer}
\usepackage{tikz}
\usepackage{animate}
\usepackage{ifthen}
\definecolor{darkgreen}{RGB}{10,90,10}

\begin{document}
    \begin{frame}
        \begin{columns}
        \begin{column}{0.5\textwidth}
            some text here some text here some text here some text here some text here
        \end{column}
        \begin{column}{0.5\textwidth}
            \begin{animateinline}[controls,loop]{50}
                \multiframe{180}{rt=-45+1}{%
                    \begin{tikzpicture}
                    \ifthenelse{\rt < 45}
                    {\draw[rounded corners,fill=cyan,rotate around={180-\rt:(2,0.2)}] (0,0) rectangle (4,0.4);\draw [fill=white] (2,0.2) circle (1mm);\draw[fill=darkgreen] (2,0.2) circle (0.5mm);}
                    {\draw[rounded corners,fill=darkgreen,rotate around={90+\rt:(2,0.2)}] (0,0) rectangle (4,0.4);\draw [fill=white] (2,0.2) circle (1mm);\draw[fill=cyan] (2,0.2) circle (0.5mm);};
        %               \draw [fill=black] (2,0.2) circle (1mm);
                    %the following lines are not meant to be on the animation
                    \draw [>=stealth,->,very thick] ([shift=(175:2.15)]2,0.2) arc (175:135:2.15) node[xshift=-5pt,left] {$+45^\circ$};
                    \draw [>=stealth,->,very thick] ([shift=(185:2.15)]2,0.2) arc (185:225:2.15) node[xshift=-5pt,left] {$-45^\circ$};
                    \node at (4.0,0) {}; % phantom node to mark right horiz. extension
                    \end{tikzpicture}}%
            \end{animateinline}
        \end{column}
        \end{columns}
    \end{frame} 
\end{document}

相关内容