xsim 解决方案中带有 externalize 的 Tikz 图片

xsim 解决方案中带有 externalize 的 Tikz 图片

我有一份使用 xsim 包创建练习和相应解决方案的文档。解决方案印在文档的背面,这样学生在阅读练习时就不会直接跳到解决方案。

对于某些解决方案,我想使用 tikz 图片。一切顺利,直到 tikzpictures 的大小使得 \tikzexternalize 成为必要。现在不再生成 tikzpictures。

\documentclass{scrreprt}

\usepackage{xsim}%

\usepackage{tikz}

\usepackage{shellesc}

\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/,shell escape=-enable-write18]
\tikzset{external/system call={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=scrollmode -jobname "\image" "\texsource"}}
\tikzset{external/mode=list and make}

\begin{document}
    \begin{exercise}[subtitle=Example Exercise]
        Draw a Line
    \end{exercise}
     
    \begin{solution}
        \begin{tikzpicture}
            \draw (0,0) -- (5,1) ;
        \end{tikzpicture}
    \end{solution}

    \printsolutions
\end{document}

当我尝试通过首先运行 lualatex(我也尝试了 pdflatex,没有什么区别)并运行 tikzpictures 的 make 命令来创建文档时,我收到以下错误消息:

! Package tikz Error: Sorry, image externalization failed: the resulting image 
was EMPTY. I tried to externalize 'tikz/MWE-figure0', but it seems there is 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 preceding it) was declared inside of a 
\label{} (i.e. in the .aux file): 'convert with system call' has no access to t
he main aux file.
   Possible solutions in this case:
   (a) Try using 'mode=list and make',
   (b) Issue the externalization command 'lualatex -enable-write18 -halt-on-err
or -interaction=scrollmode -jobname "tikz/MWE-figure0" "\def\tikzexternalrealjo
b{MWE}\input{MWE}"' *manually* (also check the preceding externalized images, p
erhaps the file name sequence is not correct).
   Repeat: the resulting image was EMPTY, your attention is required .

当使用“使用系统调用转换”模式时,我收到以下错误消息。

! Package tikz Error: Sorry, image externalization failed: the resulting image 
was EMPTY. I tried to externalize 'tikz/MWE-figure0', but it seems there is 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 preceding it) was declared inside of a 
\label{} (i.e. in the .aux file): 'convert with system call' has no access to t
he main aux file.
   Possible solutions in this case:
   (a) Try using 'mode=list and make',
   (b) Issue the externalization command 'lualatex -enable-write18 -halt-on-err
or -interaction=scrollmode -jobname "tikz/MWE-figure0" "\def\tikzexternalrealjo
b{MWE}\input{MWE}"' *manually* (also check the preceding externalized images, p
erhaps the file name sequence is not correct).
   Repeat: the resulting image was EMPTY, your attention is required .

无论放置在练习中还是文档中,图像都能正确生成。

对我来说,问题似乎是 tikz 无法在 xsim 的解决方案部分中找到图片。我已经尝试了一些不同的外部化命令设置,但没有什么区别。

有人知道如何告诉 tikz 图片存在于文档中吗?

相关内容