blob: 5170982fdfaca0eb1a43b87fe8e56edeeecb19df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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
|