1

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:

\documentclass{article}

\usepackage[pdf]{pstricks}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\tikzset{external/system call={xelatex --jobname="\image" 
"\texsource"}}
\tikzset{external/optimize=false}

\usepackage{environ}
\usepackage{xargs}

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

\NewEnvironx{mdpicture}[1][1=]{%
    %\begin{tikzpicture}
    \begin{pspicture}[#1]%
    }
    {%
    \end{pspicture}
    %\end{tikzpicture}
    }

\begin{document}

Some text and a picture
\ $\psset{unit=0.3cm}
\begin{mdpicture}[shift=-0.16](0,0)(1,1)
\pspolygon[fillstyle=solid,fillcolor=cyan,linewidth=.5pt](0,0)(0,1)(1,1)(1,0)
\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.
\end{document}

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

\NewEnvironx{mdpicture}[1][1=]{%
    \begin{tikzpicture}
    \node at (0,0) \bgroup\begin{pspicture}[#1]%
    }
    {%
    \end{pspicture}\egroup;
    \end{tikzpicture}
    }

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

2
  • 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

0

You must log in to answer this question.

Browse other questions tagged .