
我有以下程式碼:
\documentclass{article}
\usepackage{animate}
\listfiles
\begin{document}
\animategraphics[palindrome,autoplay,width=\textwidth,controls]{5}{Testsaves}{0}{1}
\end{document}
它需要同一資料夾中的兩個影像(Testsaves0 和 Testsaves1)。如果我用 pdflatex 編譯它,一切正常,並且當我打開它時,它會在 Adobe Acrobat 中呈現動畫。按鈕也能工作。
如果我用 LuaLaTeX 編譯相同的程式碼,它只包含 pdf 中的第一個圖像,並且什麼都沒有發生。
從日誌檔:
pdf乳膠:
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
)) <./Testsaves0.png> <./Testsaves1.png>
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 6.
LuaLaTeX:
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
))<./Testsaves0.png>
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 6.
系統是Windows 7 PC,TeXLive 2014已完全更新至今天。我認為它以前有效,但我不是 100% 確定。我嘗試將 animate 包回滾到我最早備份的修訂版 (35387),但這並沒有改變任何內容。
文件列表:
article.cls 2014/09/29 v1.4h Standard LaTeX document class
size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
animate.sty 2014/12/04 PDF animations from files and inline graphics
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
ifthen.sty 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
ifpdf.sty 2011/01/30 v2.3 Provides the ifpdf switch (HO)
atbegshi.sty 2011/10/05 v1.16 At begin shipout hook (HO)
infwarerr.sty 2010/04/08 v1.3 Providing info/warning/error messages (HO)
ltxcmds.sty 2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
ifluatex.sty 2010/03/01 v1.3 Provides the ifluatex switch (HO)
ifdraft.sty 2008/08/11 v1.3 Detect class options draft and final (HO)
calc.sty 2014/10/28 v4.3 Infix arithmetic (KKT,FJ)
atenddvi.sty 2007/04/17 v1.1 At end DVI hook (HO)
zref-abspage.sty 2012/04/04 v2.24 Module abspage for zref (HO)
zref-base.sty 2012/04/04 v2.24 Module base for zref (HO)
kvsetkeys.sty 2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty 2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
kvdefinekeys.sty 2011/04/07 v1.3 Define keys (HO)
pdftexcmds.sty 2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
luatex-loader.sty 2010/03/09 v0.4 Lua module loader (HO)
auxhook.sty 2011/03/04 v1.3 Hooks for auxiliary files (HO)
zref-lastpage.sty 2012/04/04 v2.24 Module lastpage for zref (HO)
atveryend.sty 2011/06/30 v1.8 Hooks at the very end of document (HO)
animfp.sty 2009/07/23 fixed point addition for animate.sty
graphics.sty 2014/10/28 v1.0p Standard LaTeX Graphics (DPC,SPQR)
trig.sty 1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg 2010/04/23 v1.9 graphics configuration of TeX Live
pdftex.def 2011/05/27 v0.06d Graphics/color for pdfTeX
supp-pdf.mkii
epstopdf-base.sty 2010/02/09 v2.5 Base part for package epstopdf
grfext.sty 2010/08/19 v1.1 Manage graphics extensions (HO)
kvoptions.sty 2011/06/30 v3.11 Key value format for package options (HO)
epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
***********
答案1
animate 測試圖形的同一性以避免兩次包含相同的文件。此測試對 lualatex 失敗: pdftexcmds
of中的 luatex 實作\pdf@filemdfivesum
似乎有錯誤。我使用 lualatex 得到的兩個圖形的值相同,但使用 pdflatex 編譯時得到的值不同。
您可以透過強制 animate 僅檢查檔案名稱來解決該問題。但我建議向 Heiko Oberdiek 發送錯誤報告。
\documentclass{article}
\usepackage{animate}
\makeatletter\def\@anim@pdfmdfivesum#1{#1}\makeatother
\begin{document}
\makeatletter
\pdf@filemdfivesum{gans1.png}
\pdf@filemdfivesum{gans2.png}
\makeatother
\animategraphics[palindrome,autoplay,width=\textwidth,controls]{5}{gans}{1}{2}
\end{document}
答案2
animate
使用套件\pdf@filemdfivesum
中的pdftexcmds
內容以避免多次包含相同文件。它計算要嵌入的文件的 MD5 校驗和。
報告的錯誤僅發生在 Windows 上。
原因是Windows區分以文字模式和二進位模式開啟檔案。 Cfopen()
對應到 Luaio.open()
並使用相同的參數列表。應將標誌b
(二進位模式)新增至io.open()
呼叫中,以確保在所有平台上正確讀取檔案。
該補丁解決了這個問題:
--- texmf-dist/scripts/oberdiek/pdftexcmds.lua.orig
+++ texmf-dist/scripts/oberdiek/pdftexcmds.lua
@@ -250,7 +250,7 @@
if not offset then
offset = 0
end
- local filehandle = io.open(foundfile, "r")
+ local filehandle = io.open(foundfile, "rb")
if filehandle then
if offset > 0 then
filehandle:seek("set", offset)
@@ -270,7 +270,7 @@
function filemdfivesum(filename)
local foundfile = kpse.find_file(filename, "tex", true)
if foundfile then
- local filehandle = io.open(foundfile, "r")
+ local filehandle = io.open(foundfile, "rb")
if filehandle then
local contents = filehandle:read("*a")
escapehex(md5.sum(contents))