4

With the following file I encounter an error when using both the convert option of standalone and lualatex. Switching either to pdflatex (which I cannot use for this drawing for other reasons) or converting by hand (which is inconvenient) does work.

\RequirePackage{luatex85}
%\documentclass{standalone}         % Does work but does not convert
\documentclass[convert]{standalone} % Does not work
\begin{document}
    MWE
\end{document}

How can I make lualatex work with the convert option?

I am using lualatex --shell-escape filename (or pdflatex --shell-escape filename) with an updates MikTeX.


Additional info as requested:

The error I get with lualatex --shell-escape is

\sa@box=\box37

! Bad number (18).
l.921     \ifeof18 
                 \else 3\fi
? 

Class standalone Warning: Shell escape disabled! Cannot convert file 'test.pdf'.

This is quite confusing to me as I explicitly used --shell-escale (and also --enable-write18 with no difference).

Adding \RequirePackage{shellesc} didn't help (I tried adding it before and after luatex85 as well as after \documentclass).


Further Info

The offending call stems form the file standalone.cls [2015/07/15 v1.2] within the following snippet starting at line 919:

\ifcase0%
    \expandafter\ifx\csname pdfshellescape\endcsname\relax
    \ifeof18 \else 3\fi
    \else\the\pdfshellescape\fi
\relax% 0
    \sa@convert@failuremsg
        {standalone}{Shell escape disabled! Cannot convert file '\infile'.}{}%
    \global\let\sa@convert@stop\relax
\or% 1
    \sa@convert{Conversion unsuccessful!\MessageBreak
                There might be something wrong with your\MessageBreak
                conversation software or the file permissions!}%
\else% 2 or 3
    \sa@convert{Conversion failed! Please ensure that shell escape\MessageBreak is enabled (e.g. use '-shell-escape').}%
\fi

Am I correct to assume that this tests for the availability of the \write18 (shellescape) feature which gets called because something's wrong with pdfshellescape?

2

The comment by ArTourter pointed me towards the following solution (i.e. workaround).

The problem seems twofold:

  1. The pdfTeX primitive \pdfshellescape is no longer defined in newer LuaTeX
  2. The \write18 feature is not implemented as standalone would expect.

Problem 1 can be solved with the package pdftexcmds which defines \pdf@shellescape which more or less implements what \pdfshellescape is expected to do. Thus we can use

\RequirePackage{pdftexcmds}
\makeatletter
  \let\pdfshellescape\pdf@shellescape
\makeatother

to define a working \pdfshellescape macro.

Problem 2 is already solved by the shellesc package which redefines \write to give access to the \write18 feature as standalone expects.

Together the following successfully circumvents the bug in standalone and produces a pdf as well as a converted bitmap.

\RequirePackage{shellesc}                % implement \write18

\RequirePackage{pdftexcmds}              % fake \pdfshellescape so
\makeatletter                            % standalone knows about it
  \let\pdfshellescape\pdf@shellescape
\makeatother

\RequirePackage{luatex85}
%\documentclass{standalone}
\documentclass[convert]{standalone}

\begin{document}

\begin{tikzpicture}
  MWE
\end{tikzpicture}

\end{document}

Call with lualatex --shell-escape.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.