I'd like to externalize upwards of a thousand graphics using pstricks (these graphics are all internal between the body text), and decided the external library of the tikz package was the way to go. Naively I came up with code that reduces to the following MWE:


\tikzset{external/system call={xelatex --jobname="\image" 


  \expandafter\newcommandx\csname start#1\endcsname[#2][#3]{#4}%
  \NewEnviron{#1}{\csname start#1\expandafter\endcsname\BODY #5}}



Some text and a picture
\ $\psset{unit=0.3cm}
\psarc[linewidth=1 pt,linecolor=blue](1,0){.5}{90}{180}
\psarc[linewidth=1 pt,linecolor=blue](0,1){.5}{-90}{0}
\end{mdpicture}$\ \ and some more text.

which would then be compiled using xelatex with the shell escape option. This code works fine as it is, but uncommenting the tikzpicture part in the mdpicture environment defined above does not yield the expected behaviour: the tikzpictures are not typeset and take up the whole page, and the separate .pdf files generated using the procedure give errors when opening the file:

"The dimensions of this page are out of range. Page content might be truncated."

This lead me to believe that perhaps I should create a node inside the tikzpicture to place it at some position, e.g. with the code

    \node at (0,0) \bgroup\begin{pspicture}[#1]%

...but this unfortunately produces the same result: a completely empty page instead of the expected (inline) pspicture.

  • You are hiding a pspicture inside a node of a tikzpicture and this inside a mdpicture which is a environ-environment. Imho it would be quite a wonder if this works. Better check the preview package and avoid all this nesting. Mar 28, 2018 at 17:55
  • @UlrikeFischer How would that be automated? I know how to extract graphics using the preview package, but replacing a thousand graphics with those extracted graphics using pdf2ps etc. is an insane amount of work
    – user55789
    Mar 28, 2018 at 19:02


You must log in to answer this question.

Browse other questions tagged .