0

I found a TikZ animation example here.

In the next step I tried to put text beside the animation, doing the following:

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

How do I have to change the code, that the text is in the first and the animation completeley within the second column?

projetmbc
  • 13,315
Arrow
  • 113

1 Answers1

1

As is, the tikzpicture is simply too wide to fit into the right column. The phantom nodes add too much white-space around the visible graphic objects.

The animation's vertical extension and the left-hand bounding edge are determined by the text labels "+45°" and "-45°". Only the right bounding edge needs to be fixed, which could indeed be done by means of a phantom node, or another invisible object.

The fixed code might look like this:

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

AlexG
  • 54,894