6

I've encountered an unusual problem with the animate package and the use of math delimiters, like \left\{.

When compiling the MWE, I get the error Missing delimiter (. inserted). on the math line.

But: if I change the order -- putting the math line before animategraphics line -- it compiles with no problem.

Is there a known conflict between animategraphics and the later use of delimiters? Any thoughts about how to overcome this?

\documentclass{article}
\usepackage{amsmath}
\usepackage{animate}

\begin{document}
\animategraphics[scale=0.5]{6}{animfile}{}{}
\[\left\{\begin{array}{l}y=2x\\y=x+1\end{array}\right.\]
\end{document}
1
  • As of version 2014/08/06 of animate, the problem seems to be solved.
    – egreg
    Aug 7, 2014 at 10:07

2 Answers 2

5

It is a bug in animate. The macro \@anim@@sanitize is executed several times, one for each token in the list .:;?!/"'*+,->=<$&@][)(^_|~`, and each time it does

\global\let\@anim@leftbrace=\{\global\let\{=\@anim@lbr

The first time, \@anim@leftbrace saves the meaning of \{, but the second time it just saves the meaning of \@anim@lbr. Later, \@anim@endsanitize does \global\let\{=\@anim@leftbrace, restoring the wrong value.

The same happens for \\, \} and \%.

You can cure the bug by doing the loop in a different way:

\documentclass{article}
\usepackage{amsmath}
\usepackage{animate}

\makeatletter
\def\@anim@@sanitize#1\@nil{%
  \@tfor\next:=#1\do{%
    \expandafter\xdef\csname @anim@\number\expandafter`\next\endcsname{%
      \the\catcode\expandafter`\next
    }%
    \global\catcode\expandafter`\next=12
  }
  \global\catcode`\#=12
  \global\let\@anim@newline=\\\global\let\\=\@anim@bksl
  \global\let\@anim@leftbrace=\{\global\let\{=\@anim@lbr
  \global\let\@anim@rightbrace=\}\global\let\}=\@anim@rbr
  \global\let\@anim@percent=\%\global\let\%=\@anim@per
}
\def\@anim@@endsanitize#1\@nil{%
  \@tfor\next:=#1\do{%
    \global\catcode\expandafter`\next=\csname @anim@\number\expandafter`\next\endcsname
  }
  \global\let\%=\@anim@percent%
  \global\let\}=\@anim@rightbrace%
  \global\let\{=\@anim@leftbrace%
  \global\let\\=\@anim@newline%
  \global\catcode`\#=6%
}
\makeatother

\begin{document}

\animategraphics[scale=0.5]{6}{whatever}{}{}

\[\left\{\begin{array}{l}y=2x\\y=x+1\end{array}\right.\]

\end{document}

This should be brought to the attention of the package maintainer as soon as possible.

UPDATE

As of version 2014/08/06 of animate, the problem has been fixed along with the other bug noted in comments.

9
  • Thank you very much, @egreg. I will try to incorporate this asap.
    – AlexG
    Aug 6, 2014 at 7:31
  • I found another way for fixing it. I moved the lines with \global\let from the recursive macros \@anim@@sanitize and \@anim@@endsanitize to the ends of the calling macros \@anim@sanitize and \@anim@endsanitize.
    – AlexG
    Aug 6, 2014 at 9:01
  • @AlexG I don't understand why you want to use your own baked recursive call, when LaTeX provides \@tfor. But the package is yours. ;-)
    – egreg
    Aug 6, 2014 at 9:03
  • I just find recursive macro calls cool. Though without really mastering them ;).
    – AlexG
    Aug 6, 2014 at 9:06
  • @AlexG I'd also point out that globally redefining \\ is not really the best thing to do; if \animategraphics is called in a flushleft or center environment, one will end up with \\ having the wrong definition when the environment ends. Do you really need \global?
    – egreg
    Aug 6, 2014 at 9:15
2

use instead of \{ the macro \lbrace:

\[ \left\lbrace ....
1
  • What about \\? Sorry, but this just cures one of the symptoms.
    – egreg
    Aug 2, 2014 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .