3

I want to animate text and equations (no pictures) in LaTeX. I tried out the animate package, but I find that my text is often clipped at the top and bottom.

Here is a minimal example.

\documentclass{article}
\usepackage{animate}

\begin{document}
\begin{animateinline}[autoplay,loop]{2}
\multiframe{10}{n=0+1}{
\n
}
\end{animateinline}
\end{document}

When I compile it with pdflatex and view the result in Adobe Reader XI, the numbers are clipped at the top and bottom, as you can see here with the number 8 (zoom @ 800%):

Picture of Number 8 missing the top of its head

Is there a method to prevent this? Or is the animate package not the right tool for this job?

1 Answer 1

2

The glyph boxes of TeX are often smaller than the real dimensions of the glyphs. Don't know why TeX is designed like this. To avoid clipping of the glyphs, put a \strut in front of the text. Afaik, the sum of height and depth of a \strut is equal to \baselineskip of the current font:

\documentclass{article}
\usepackage{calc}
\newlength\mytotalheight

\begin{document}
\verb+\normalsize+:
\settototalheight\mytotalheight{\strut}\the\mytotalheight$=$\the\baselineskip

\verb+\huge:+\huge
\settototalheight\mytotalheight{\strut}\the\mytotalheight$=$\the\baselineskip
\end{document}

Also put the text in a box of the same width for every frame. Otherwise larger numbers get squeezed if you start with a single digit number.

\documentclass{article}
\usepackage{animate}

\begin{document}
\begin{animateinline}[autoplay,loop]{2}
\multiframe{11}{n=0+1}{
\strut\makebox[2em][r]{\n}
}
\end{animateinline}
\end{document}
1
  • 1
    Thank you for warning me about the squeezing. I was unaware that "animate" uses the size of the animation's first frame for all subsequent frames. May 8, 2014 at 8:44

You must log in to answer this question.

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