4

Why this MWE does never stop compiling generating tons of pdf pages ?

\documentclass[french,xcolor=dvipsnames,9pt]{beamer}
\usepackage{tikz}
\usetheme{Warsaw}\usecolortheme{wolverine}

\setbeamersize{text margin left=.4cm}
\setbeamersize{text margin right=.4cm}

\newcommand{\Rect}[2][blue]{%
    \begin{scope}[#2]
        \draw[draw=#1,fill=#1!25,join=round]
            (0,0) -- (2,0) -- (0,1) -- cycle ;
        \filldraw[#1] (0,0) rectangle (.2,.2) ; 
    \end{scope}
    }

\begin{document}

\begin{frame}
\begin{center}

\begin{tikzpicture}

\only<1->{\Rect{}}

\foreach \i [evaluate=\i as \j using \i+2] in {1,...,2} {%
    \only<\j>{
    \begin{scope}[shift={(3*\i/20,0)}]
        \Rect{}
    \end{scope}
    }
    }


\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
2
  • 3
    I'm guessing but try with int(\i+2) in the evaluate of foreach. I don't think \only is that smart.
    – percusse
    Sep 29 '14 at 10:18
  • Bingo ! fill free to write an answer. If not \only, what else ?
    – Tarass
    Sep 29 '14 at 10:41
5

I didn't check it but it might happen that the argument of \only macro is compared to the framecounter value and since TikZ arithmetic \i+2 returns a decimal point such as 3.0 this comparison never gets satisfied. Hence you need to convert the result to integer to make it 3. So

\foreach \i [evaluate=\i as \j using int(\i+2)] in {1,...,2} {%

does it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.