Animation 使用乳胶动画&;具有两个嵌套循环的Tikz

Animation 使用乳胶动画&;具有两个嵌套循环的Tikz,animation,latex,beamer,Animation,Latex,Beamer,我正在尝试使用带有两个嵌套循环的animate包在LaTeX中创建一个动画,其中我使用Tikz绘制图形。但是,在第一次和最后一次内部迭代中,图片会保持轻微的缩放。在下面的最小示例中,我想画两个移动箭头:一个在顶部表示外层,另一个在底部表示内层 值得注意的是,如果内层只有一次迭代,即变量\jlimit为1,则此问题将消失。这似乎表明内层出了问题 以前有人遇到过这个问题吗?或者你能想出解决办法吗 提前感谢:) \documentclass[10pt]{beamer} \usepackage[utf8

我正在尝试使用带有两个嵌套循环的animate包在LaTeX中创建一个动画,其中我使用Tikz绘制图形。但是,在第一次和最后一次内部迭代中,图片会保持轻微的缩放。在下面的最小示例中,我想画两个移动箭头:一个在顶部表示外层,另一个在底部表示内层

值得注意的是,如果内层只有一次迭代,即变量\jlimit为1,则此问题将消失。这似乎表明内层出了问题

以前有人遇到过这个问题吗?或者你能想出解决办法吗

提前感谢:)

\documentclass[10pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\使用包{ifthen}
\usepackage{animate}
\新计数器{i}%外部计数器
\设置计数器{i}{0}
\newcounter{j}%内部计数器
\def\i限制{3}%外部迭代限制
\def\jlimit{5}%内部迭代限制,如果为1,则不会重新缩放
\开始{document}
\开始{frame}[脆弱]{嵌套动画循环}
\开始{center}
\开始{animateinline}[循环,poster=first,控件]{2}

\问题在于未受保护的行尾,tex将其解释为空格。在行尾添加
%
符号以避免此问题:

\documentclass[10pt]{beamer}

\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{animate}

\newcounter{i}    % Outer counter
\setcounter{i}{0}   
\newcounter{j}    % Inner counter
\def\ilimit{3}    % Outer iteration limit
\def\jlimit{5}    % Inner iteration limit, rescaling doesn't happen if this is 1

\begin{document}

\begin{frame}[fragile]{Nested animated loops}
\begin{center}%
\begin{animateinline}[loop, poster = first, controls]{2}
    \whiledo{\thei<\ilimit} {%       % Starting outer loop
        \setcounter{j}{0}%           % Resetting inner counter
        \whiledo{\thej<\jlimit} {%   % Starting inner loop
        \begin{tikzpicture}%
            \draw [color=black] (-0.5,-1.5) rectangle (4.5, 0.5);   % Draw a bounding rectangle
            \node[shift={(\thei,0)}] at (0,0) {\Large $\downarrow$};% Draw the first level
            \node[shift={(\thej,0)}] at (0,-1) {\Large $\uparrow$}; % Draw the second level
        \end{tikzpicture}%
        \stepcounter{j}%                        % Increase the inner counter
        \ifthenelse{\thej<\jlimit} {%
            \newframe%                          % Draw a new inner frame
        }{}%
    }%
    \stepcounter{i}%                            % Increase the outer counter
    \ifthenelse{\thei<\ilimit} {%
        \newframe%                              % Draw a new outer frame
    }{%
            \end{animateinline}\relax% % BREAK  % End the animation
    }%
  }%
\end{center}
\end{frame}

\end{document}
\documentclass[10pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\使用包{ifthen}
\usepackage{animate}
\新计数器{i}%外部计数器
\设置计数器{i}{0}
\newcounter{j}%内部计数器
\def\i限制{3}%外部迭代限制
\def\jlimit{5}%内部迭代限制,如果为1,则不会重新缩放
\开始{document}
\开始{frame}[脆弱]{嵌套动画循环}
\开始{center}%
\开始{animateinline}[循环,poster=first,控件]{2}

然而,{非常好的TEX问题!为了有更多的听众来回答这样的问题,你应该考虑在TEX.STACKExchange .com上问他们。太谢谢你了,那真是太妙了!我一百万年后都不会猜到这一点。
\documentclass[10pt]{beamer}

\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{ifthen}
\usepackage{animate}

\newcounter{i}    % Outer counter
\setcounter{i}{0}   
\newcounter{j}    % Inner counter
\def\ilimit{3}    % Outer iteration limit
\def\jlimit{5}    % Inner iteration limit, rescaling doesn't happen if this is 1

\begin{document}

\begin{frame}[fragile]{Nested animated loops}
\begin{center}%
\begin{animateinline}[loop, poster = first, controls]{2}
    \whiledo{\thei<\ilimit} {%       % Starting outer loop
        \setcounter{j}{0}%           % Resetting inner counter
        \whiledo{\thej<\jlimit} {%   % Starting inner loop
        \begin{tikzpicture}%
            \draw [color=black] (-0.5,-1.5) rectangle (4.5, 0.5);   % Draw a bounding rectangle
            \node[shift={(\thei,0)}] at (0,0) {\Large $\downarrow$};% Draw the first level
            \node[shift={(\thej,0)}] at (0,-1) {\Large $\uparrow$}; % Draw the second level
        \end{tikzpicture}%
        \stepcounter{j}%                        % Increase the inner counter
        \ifthenelse{\thej<\jlimit} {%
            \newframe%                          % Draw a new inner frame
        }{}%
    }%
    \stepcounter{i}%                            % Increase the outer counter
    \ifthenelse{\thei<\ilimit} {%
        \newframe%                              % Draw a new outer frame
    }{%
            \end{animateinline}\relax% % BREAK  % End the animation
    }%
  }%
\end{center}
\end{frame}

\end{document}