
我想用 LaTeX 製作文字和方程式(無圖片)的動畫。我嘗試了 animate 包,但我發現我的文字經常在頂部和底部被剪裁。
這是一個最小的例子。
\documentclass{article}
\usepackage{animate}
\begin{document}
\begin{animateinline}[autoplay,loop]{2}
\multiframe{10}{n=0+1}{
\n
}
\end{animateinline}
\end{document}
當我使用 pdflatex 編譯它並在 Adobe Reader XI 中查看結果時,數字在頂部和底部被剪裁,正如您在此處看到的數字 8(縮放 @ 800%):
有沒有辦法防止這種情況發生?或者 animate 包不是適合這項工作的工具嗎?
答案1
TeX 的字形框通常小於字形的實際尺寸。不知道TeX為什麼要這樣設計。為了避免字形被剪裁,請\strut
在文字前面添加一個。 Afaik,a 的高度和深度總和\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}