动画中的文本被“剪切”

动画中的文本被“剪切”

我想在 LaTeX 中为文本和公式(无图片)添加动画效果。我尝试了动画包,但我发现我的文本经常在顶部和底部被截断。

这是一个最小的例子。

\documentclass{article}
\usepackage{animate}

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

当我使用 pdflatex 编译它并在 Adob​​e Reader XI 中查看结果时,数字在顶部和底部被剪裁,如您在此处看到的数字 8(缩放@800%):

8号头顶缺失的图片

有没有什么方法可以防止这种情况发生?或者 animate 包不是适合这项工作的工具?

答案1

TeX 的字形框通常比字形的实际尺寸要小。不知道为什么 TeX 会这样设计。为了避免字形被裁剪,请\strut在文本前面放置一个。据我所知,一个的高度和深度之和\strut等于\baselineskip当前字体的高度和深度之和:

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

还要将文本放在每个框架的相同宽度的框中。否则,如果您从一位数开始,较大的数字就会被挤压。

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

相关内容