\standaloneconfig doesn't work for setting the conversion program

Create issue
Issue #37 new
Enrico Gregorio created an issue

The following test file, compiled with pdflatex -shell-escape

\documentclass[tikz,convert]{standalone}
\standaloneconfig{
  multi=false,
  crop,
  convert={
    convertexe=magick,
    density=200,
    outext=.png,
    command={%
      echo \outfile;
      \convertexe\space
      -density \density\space
      \infile\space
      -alpha remove\space
      \outfile
    }
  }
}

\begin{document} 

\begin{tikzpicture}
\draw (0,0) rectangle (2,1) node [midway] {Example};
\end{tikzpicture}

\end{document}

results in the log file containing

runsystem(convert -density 300 testconf.pdf  -quality 90 testconf.png)...executed.

showing the setting is not honored. If the \standaloneconfig command is moved into a standalone.cfg file in the working directory, then the call is correct (at least on Unix boxes):

runsystem(echo testconf.png; magick -density 200 testconf.pdf -alpha remove testconf.png)...executed.

Note also that multi=false and crop are needed in the .cfg file, notwithstanding they should be the default.

Comments (4)

  1. Martin Scharrer repo owner

    The reason while this does not work lies in the fact how the he convert option works: It does the convertion call directly in the class file, i.e. when it is loaded by \documentclass. It calls a second LaTeX run which builds the PDF and then calls the conversion command on the PDF. Finally it aborts the compilation of the main compilation before that one creates any output file (in order not to rebuild or blank the already build PDF file). Therefore the \standaloneconfig command after \documentclass is never seen by the conversion call. Placing it in the config file works because it is loaded by the class quite at the beginning.

    I would suggest the following solutions: 1. Use the config file 2. Use the convert option as a class option. Downside is that you need to escape all command using \noexpand.

  2. Martin Scharrer repo owner

    Also note that multi-false is indeed the default, but you are using the tikz option, which is short for multi=tikzpicture,varwidth=false and then \usepackage{tikz}. If you don't want multiple Tikz pictures then drop the class option and load the package manually.

    The crop option is always the default as it is used in the global config file. You only need to repeat it if the global config file is not read because there is a local one.

  3. Enrico Gregorio reporter

    I can understand the explanation, but don't agree with the conclusions. I don't think this is a minor issue.

  4. Log in to comment