diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/pgf/utilities/pgfwriteexternal.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/pgf/utilities/pgfwriteexternal.sty | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/pgf/utilities/pgfwriteexternal.sty b/Master/texmf-dist/tex/latex/pgf/utilities/pgfwriteexternal.sty new file mode 100644 index 00000000000..5170982fdfa --- /dev/null +++ b/Master/texmf-dist/tex/latex/pgf/utilities/pgfwriteexternal.sty @@ -0,0 +1,111 @@ +% Copyright 2006 by Till Tantau +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. +% +% See the file doc/generic/pgf/licenses/LICENSE for more details. + +\ProvidesPackage{pgfwriteexternal}[2006/03/13 ver 0.01] + + +% Modes of operation: +% +% Set \pgfexternalcurrent to empty, relax or undefined and all +% \pgfexternal... are ignored +% +% Set \pgfexternalcurrnet to anything else and all text will be thrown +% away, except the text in the \pgfexternalbegin...\pgfexternalend +% with the right name. + +\AtBeginDocument{ + \ifx\pgfexternalcurrent\relax + \let\pgfexternalcurrent=\@empty + \fi + \ifx\pgfexternalcurrent\@undefined + \let\pgfexternalcurrent=\@empty + \fi + \ifx\pgfexternalcurrent\@empty + \else + \pgf@externalgrabshipout + \fi +} + + +\newwrite\pgfexternal@caller + +% Environment for an external graphic. +% +% #1 = suffix +% +% Example: +% +% \pgfexternalbegin{mygraph} +% \begin{tikzpicture} +% ... +% \end{tikzpicture} +% \pgfextenalend + +\def\pgfexternalbegin#1{% + \IfFileExists{#1.tex}{}{% + \immediate\openout\pgfexternal@caller #1.tex% + \immediate\write\pgfexternal@caller{\noexpand\def\noexpand\pgfexternalcurrent{#1}\noexpand\input \jobname.tex}% + \immediate\closeout\pgfexternal@caller% + }% + \edef\pgf@test{#1}% + \edef\pgfeeext{\pgfexternalcurrent}% + \expandafter\scantokens\expandafter{\expandafter\edef\expandafter\pgfeeext\expandafter{\pgfeeext}}\unskip% + \ifx\pgfeeext\pgf@test% + \global\let\pgfexternalend=\pgf@externalend% + \expandafter\pgf@externalprepareshipout% + \fi% + \ignorespaces% +} + +\let\pgfexternalend=\unskip + + + +\newbox\pgfexternal@ignorebox +\newbox\pgfexternal@box + +\def\pgf@externalgrabshipout{% + \global\let\pgfexternal@originalshipout=\shipout% + \global\def\shipout{\setbox\pgfexternal@ignorebox=} +} + +\def\pgf@externalprepareshipout{% + \setbox\pgfexternal@box=\hbox\bgroup\bgroup% +} + +\def\pgf@externalend{% + \unskip\egroup\egroup% + {% + \parindent0pt% + \leftmargin0pt% + \dimen0\ht\pgfexternal@box% + \advance\dimen0\dp\pgfexternal@box% + \pgfsys@papersize{\the\wd\pgfexternal@box}{\the\dimen0}% + \setbox0=\vbox{% + \kern -1truein% + \hbox{% + \kern -1truein% + \hbox to0pt{\pgfsys@atbegindocument}% + \box\pgfexternal@box% + \kern 1truein}% + \kern1truein}% + \pgfexternal@originalshipout\box0% + }% + \global\let\pgfexternalend=\unskip% +} + +\ifx\pdfoutput\undefined + \newcount\pdfoutput +\fi + + + + +\endinput + |