使用 tikzducks 时出现 Tikz 外部化错误

使用 tikzducks 时出现 Tikz 外部化错误

我将tikzducks其用作页脚,只是因为我认为它们很棒。因为我的文档包含许多其他 tikzpictures,所以我想使用\tikzexternalize。如果我不使用 ,这将完全正常工作tikzducks。使用tikzduckstikzexternalize在生成最终的鸭子时会失败。一个简单的解决方案是禁用tikzducks。但是是的……没有鸭子的报告,这太过分了。所以有人能帮帮我吗?

我的 MWE(document.tex):

\documentclass{article}
\usepackage{lipsum}                             %5 generate lorum ipsum text
\usepackage{fancyhdr}                           %% page headers and footers
\usepackage{tikzducks}                          %% ducks with tikz

\pagestyle{fancy}                               %% set page style
\renewcommand*{\headrulewidth}{0.0pt}           %% header line width
\fancyfoot[C]{\shuffleducks\tikz[scale=0.35]{\duck[signpost={\footnotesize\thepage},\randomhead]}}

\usetikzlibrary{external}                       %% Create pdf figures from TikZ. Use PDFTeXify ...
\tikzexternalize[prefix=tikz/]                  %% ... with --tex-option=--shell-escape switch.

\begin{document}

\lipsum[1-10]

\end{document}

我使用以下代码进行编译:

pdflatex.exe -synctex=1 -interaction=nonstopmode -shell-escape "document".tex

我收到以下错误:

! Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
rror -interaction=batchmode -jobname "tikz/document-figure1" "\def\tikzexternal
realjob{document}\input{document}"' did NOT result in a usable output file 'tik
z/document-figure1' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that
 you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'.
 Sometimes it is also named 'write 18' or something like that. Or maybe the com
mand simply failed? Error messages can be found in 'tikz/document-figure1.log'.
 If you continue now, I'll try to typeset the picture.

日志文件的内容如下:

! Package tikz Error: Sorry, image externalization failed: the resulting image 
was EMPTY. I tried to externalize 'tikz/document-figure1', but it seems there i
s no such image in the document!?  
You are currently using 'mode=convert with system call'. This problem can ha
ppen if the image (or one of the images preceeding it) was declared inside of a
\label{} (i.e. in the .aux file): 'convert with system call' has no access to 
the main aux file.
Possible solutions in this case:
(a) Try using 'mode=list and make',
(b) Issue the externalization command 'pdflatex -shell-escape -halt-on-error
-interaction=batchmode -jobname "tikz/document-figure1" "\def\tikzexternalreal
job{document}\input{document}"' *manually* (also check the preceeding externali
zed images, perhaps the file name sequence is not correct).
Repeat: the resulting image was EMPTY, your attention is required .

答案1

日志文件显示:

如果图像(或它前面的图像之一)在 \label{} 内部(即在 .aux 文件中)声明,则可能会发生此问题……

可能是最后一页的页脚在里面label{}?因为错误只出现在最后一页。由于可以使用引用键引用最后一页LastPage,所以我认为可能是这种情况。

编辑:根据下面的评论,情况并非如此。尽管如此,我们“正处于输出例程的中间,不应该在那里做像外部化这样复杂的事情”。

无论如何,由于它们tikzducks对文档的编译没有太大影响,因此“tikzeexternalize”鸭子并不重要。我找到了以下页脚解决方法(基于 cfr 的评论):

\fancyfoot[C]{%
    \tikzset{external/export=false}
    \shuffleducks\tikz[scale=0.35]{\duck[signpost={\footnotesize\thepage},\randomhead]}
}

这样,除了页脚中的 tikzducks 之外,所有 tikzpictures 都被外部化了。

相关内容