Skip to main content
spelling
Source Link
Schweinebacke
  • 26.9k
  • 71
  • 104

The global options of \documentclass are not only interpreted by standalone but all classes and packages. So they also can be expanded several times. As long as the class and the packages do not process key-value options this is not a big problem. But KOMA-Script classes and several packages loaded by theses classes do process such options. So in this case \CONVERTCOMMAND is expanded by at least one of the packages while \infile is undefined.

To avoid this, you can use \standaloneconfig to add the convert option. But this has to be done either in standalone.cfg or at least before the conversationconversion is done. Usually there is already a standalone.cfg that is loaded. But maybe you don't want to change it. The following solution uses scrlfile to add the \standaloneconfig command just after reading this configuration file. And for the case there is not any standalone.cfg it make one.

\def\CONVERTCOMMAND{pdf2svg \infile\space \inname .svg
&&
inkscape -z -f \inname .svg --export-emf=\outfile\space
&& del \inname .svg || rm \inname .svg%
}
\RequirePackage{scrlfile}
% If there is already a `standalone.cfg` we add one command.
\AfterFile{standalone.cfg}{%
  \standaloneconfig{%
    convert={
      command={\CONVERTCOMMAND},
      outext=.emf %damit Output erkannt wird
    }
  }
}
% If their isn't any `standaline`standalone.cfg` we make a dummy one.
\IfFileExists{standalone.cfg}{}{% works also wiewith package filecontents
\begin{filecontents*}{standalone.cfg}
\relax
\end{filecontents*}
}

\documentclass[11pt,
 class=scrartcl,
]{standalone}
\begin{document}
test
\end{document}

BTW: I've reduced the usage of not needed \space commands and added rm to remove the SVG-file if defdel fails. So this version works on my linux machine.

Here is a snapshot from the log-file:

\sa@box=\box29
runsystem(pdflatex  -shell-escape  -jobname 'test' '\expandafter\def\csname sa@
internal@run\endcsname{1}\input{test}')...executed.

\sa@read=\read1
runsystem(pdf2svg test.pdf test.svg && inkscape -z -f test.svg --export-emf=tes
t.emf && del test.svg || rm test.svg)...executed.

The global options of \documentclass are not only interpreted by standalone but all classes and packages. So they also can be expanded several times. As long as the class and the packages do not process key-value options this is not a big problem. But KOMA-Script classes and several packages loaded by theses classes do process such options. So in this case \CONVERTCOMMAND is expanded by at least one of the packages while \infile is undefined.

To avoid this, you can use \standaloneconfig to add the convert option. But this has to be done either in standalone.cfg or at least before the conversation is done. Usually there is already a standalone.cfg that is loaded. But maybe you don't want to change it. The following solution uses scrlfile to add the \standaloneconfig command just after reading this configuration file. And for the case there is not any standalone.cfg it make one.

\def\CONVERTCOMMAND{pdf2svg \infile\space \inname .svg
&&
inkscape -z -f \inname .svg --export-emf=\outfile\space
&& del \inname .svg || rm \inname .svg%
}
\RequirePackage{scrlfile}
% If there is already a `standalone.cfg` we add one command.
\AfterFile{standalone.cfg}{%
  \standaloneconfig{%
    convert={
      command={\CONVERTCOMMAND},
      outext=.emf %damit Output erkannt wird
    }
  }
}
% If their isn't any `standaline.cfg` we make a dummy one.
\IfFileExists{standalone.cfg}{}{% works also wie package filecontents
\begin{filecontents*}{standalone.cfg}
\relax
\end{filecontents*}
}

\documentclass[11pt,
 class=scrartcl,
]{standalone}
\begin{document}
test
\end{document}

BTW: I've reduced the usage of not needed \space commands and added rm to remove the SVG-file if def fails. So this version works on my linux machine.

Here is a snapshot from the log-file:

\sa@box=\box29
runsystem(pdflatex  -shell-escape  -jobname 'test' '\expandafter\def\csname sa@
internal@run\endcsname{1}\input{test}')...executed.

\sa@read=\read1
runsystem(pdf2svg test.pdf test.svg && inkscape -z -f test.svg --export-emf=tes
t.emf && del test.svg || rm test.svg)...executed.

The global options of \documentclass are not only interpreted by standalone but all classes and packages. So they also can be expanded several times. As long as the class and the packages do not process key-value options this is not a big problem. But KOMA-Script classes and several packages loaded by theses classes do process such options. So in this case \CONVERTCOMMAND is expanded by at least one of the packages while \infile is undefined.

To avoid this, you can use \standaloneconfig to add the convert option. But this has to be done either in standalone.cfg or at least before the conversion is done. Usually there is already a standalone.cfg that is loaded. But maybe you don't want to change it. The following solution uses scrlfile to add the \standaloneconfig command just after reading this configuration file. And for the case there is not any standalone.cfg it make one.

\def\CONVERTCOMMAND{pdf2svg \infile\space \inname .svg
&&
inkscape -z -f \inname .svg --export-emf=\outfile\space
&& del \inname .svg || rm \inname .svg%
}
\RequirePackage{scrlfile}
% If there is already a `standalone.cfg` we add one command.
\AfterFile{standalone.cfg}{%
  \standaloneconfig{%
    convert={
      command={\CONVERTCOMMAND},
      outext=.emf %damit Output erkannt wird
    }
  }
}
% If their isn't any `standalone.cfg` we make a dummy one.
\IfFileExists{standalone.cfg}{}{% works also with package filecontents
\begin{filecontents*}{standalone.cfg}
\relax
\end{filecontents*}
}

\documentclass[11pt,
 class=scrartcl,
]{standalone}
\begin{document}
test
\end{document}

BTW: I've reduced the usage of not needed \space commands and added rm to remove the SVG-file if del fails. So this version works on my linux machine.

Here is a snapshot from the log-file:

\sa@box=\box29
runsystem(pdflatex  -shell-escape  -jobname 'test' '\expandafter\def\csname sa@
internal@run\endcsname{1}\input{test}')...executed.

\sa@read=\read1
runsystem(pdf2svg test.pdf test.svg && inkscape -z -f test.svg --export-emf=tes
t.emf && del test.svg || rm test.svg)...executed.
Source Link
Schweinebacke
  • 26.9k
  • 71
  • 104

The global options of \documentclass are not only interpreted by standalone but all classes and packages. So they also can be expanded several times. As long as the class and the packages do not process key-value options this is not a big problem. But KOMA-Script classes and several packages loaded by theses classes do process such options. So in this case \CONVERTCOMMAND is expanded by at least one of the packages while \infile is undefined.

To avoid this, you can use \standaloneconfig to add the convert option. But this has to be done either in standalone.cfg or at least before the conversation is done. Usually there is already a standalone.cfg that is loaded. But maybe you don't want to change it. The following solution uses scrlfile to add the \standaloneconfig command just after reading this configuration file. And for the case there is not any standalone.cfg it make one.

\def\CONVERTCOMMAND{pdf2svg \infile\space \inname .svg
&&
inkscape -z -f \inname .svg --export-emf=\outfile\space
&& del \inname .svg || rm \inname .svg%
}
\RequirePackage{scrlfile}
% If there is already a `standalone.cfg` we add one command.
\AfterFile{standalone.cfg}{%
  \standaloneconfig{%
    convert={
      command={\CONVERTCOMMAND},
      outext=.emf %damit Output erkannt wird
    }
  }
}
% If their isn't any `standaline.cfg` we make a dummy one.
\IfFileExists{standalone.cfg}{}{% works also wie package filecontents
\begin{filecontents*}{standalone.cfg}
\relax
\end{filecontents*}
}

\documentclass[11pt,
 class=scrartcl,
]{standalone}
\begin{document}
test
\end{document}

BTW: I've reduced the usage of not needed \space commands and added rm to remove the SVG-file if def fails. So this version works on my linux machine.

Here is a snapshot from the log-file:

\sa@box=\box29
runsystem(pdflatex  -shell-escape  -jobname 'test' '\expandafter\def\csname sa@
internal@run\endcsname{1}\input{test}')...executed.

\sa@read=\read1
runsystem(pdf2svg test.pdf test.svg && inkscape -z -f test.svg --export-emf=tes
t.emf && del test.svg || rm test.svg)...executed.