1

I have a document using the package xsim for creating exercises and corresponding solutions. The solutions are printed in the back of the document so students do not directly skip forward to the solution while reading the exercise.

For some solutions I would like to use tikz pictures. That went well until the size of the tikzpictures made \tikzexternalize necessary. Now the tikzpictures are not generated anymore.

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

When I try to create the document by first running lualatex (I also tried pdflatex, makes no difference) and the running the make command for the tikzpictures I get the following error message:

! 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 .

When using the 'convert with system call' mode I get the following error message.

! 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 .

The image is correctly generated when placed in the either in the exercise or just in the document.

For me it looks like the problem is that tikz cannot find the picture in the solution section of xsim. I already tried some different settings for the externalization command but that made no difference.

Does anybody know how to tell tikz, that the pictures exist in the document?

2
  • If I'm seeing this right xsim also writes plenty to external files which might conflict with TikZ' external on some level. Can you test with \usepackage[no-files]{xsim}? There's also this issue on the package's repo's tracker but I can't make heads or tails of it. Luckily, the maintainer of that package is active here, too. Sep 14, 2022 at 11:03
  • @Qrrbrbirlbel Thanks for the idea, but \usepackage[no-files]{xsim} sadly does not solve the issue.
    – asekno
    Sep 14, 2022 at 12:16

0

You must log in to answer this question.

Browse other questions tagged .