Debian Codegraph @

texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %%% This file is a copy of some part of PGF/Tikz.
3 %%% It has been copied here to provide :
4 %%% - compatibility with older PGF versions
5 %%% - availability of PGF contributions by Christian Feuersaenger
6 %%% which are necessary or helpful for pgfplots.
7 %%%
8 %%% For reasons of simplicity, I have copied the whole file, including own contributions AND
9 %%% PGF parts. The copyrights are as they appear in PGF.
10 %%%
11 %%% Note that pgfplots has compatible licenses.
12 %%%
13 %%% This copy has been modified in the following ways:
14 %%% - nested \input commands have been updated
15 %%%
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 %%% Date of this copy: Di 25. Dez 18:14:20 CET 2012 %%%
18
19
20
21 % Copyright 2008 by Christian Feuersaenger
22 %
23 % This file may be distributed and/or modified
24 %
25 % 1. under the LaTeX Project Public License and/or
26 % 2. under the GNU Public License.
27 %
28 % See the file doc/generic/pgf/licenses/LICENSE for more details.
29 %
30 % In addition to the above licenses, this particular file may also be
31 % directly inlined into other documents and this copyright notice may
32 % be removed. Additionally, when you inline this file, you may modify
33 % it as needed and you may remove comments.
34 %
35 % This file is intended to be distributed or even inlined into a file
36 % when a document needs to be typeset on a system that does not have
37 % pgf/TikZ installed.
38 %
39 % It replaces \tikzpicture/ \endtikzpicture and \tikz and invokes the
40 % \includegraphics with the correct file name instead.
41
42 \RequirePackage{graphicx}
43
44 \toksdef\t@tikzexternal@tmpa=0
45 \toksdef\t@tikzexternal@tmpb=1
46
47 \def\tikzexternalize{\@ifnextchar[{\tikzexternalize@opt}{\tikzexternalize@opt[]}}%
48 \def\tikzexternalize@opt[#1]{\@ifnextchar\bgroup{\def\tikzexternal@realjob}{\let\tikzexternal@realjob=\jobname}}%
49
50 \def\tikzsetnextfilename#1{\gdef\tikzexternal@nextfile{#1}}
51 \def\tikzsetexternalprefix#1{\def\tikzexternal@filenameprefix{#1}}
52 \def\tikzsetfigurename#1{\def\tikzexternal@figurename{#1}}%
53 \def\tikzappendtofigurename#1{\expandafter\def\expandafter\tikzexternal@figurename\expandafter{\tikzexternal@figurename #1}}%
54 \tikzsetnextfilename{}
55 \tikzsetexternalprefix{}
56 \tikzsetfigurename{\tikzexternal@realjob-figure}%
57
58 \long\def\tikzpicture#1\end#2{% collect every thing up to \end{tikzpicture}
59 \def\tikzexternal@laTeX@collectpicture@@{#2}%
60 \ifx\tikzexternal@laTeX@collectpicture@@\tikzexternal@laTeX@tikzpicturestring
61 \tikzexternal@image
62 \end{tikzpicture}%
63 \else
64 \expandafter
65 \tikzpicture
66 \fi
67 }%
68 \def\endtikzpicture{}
69 \def\tikzexternal@laTeX@tikzpicturestring{tikzpicture}%
70
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 % Replacement for \tikz short command:
73 \def\tikz{\@ifnextchar[{\tikz@opt}{\tikz@opt[]}}
74 \def\tikz@opt[#1]{\@ifnextchar\bgroup{\tikz@opt@{#1}}{\tikz@opt@@{#1}}}
75 \def\tikz@opt@#1#2{\tikz@opt@process{#1}{#2}}
76 \def\tikz@opt@@#1{%
77 \def\tikz@next{\tikz@collectnormalsemicolon{#1}}%
78 \ifnum\the\catcode`\;=\active\relax%
79 \def\tikz@next{\tikz@collectactivesemicolon{#1}}%
80 \fi%
81 \tikz@next}
82 \def\tikz@collectnormalsemicolon#1#2;{\tikz@opt@process{#1}{#2;}}
83 {
84 \catcode`\;=\active
85 \gdef\tikz@collectactivesemicolon#1#2;{%
86 \tikz@opt@process{#1}{#2;}%
87 }
88 }
89 \def\tikz@opt@process#1#2{\tikzexternal@image}
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91
92 \def\tikzexternal@image{%
93 \leavevmode
94 \begingroup
95 \t@tikzexternal@tmpa=\expandafter{\tikzexternal@filenameprefix}%
96 \ifx\tikzexternal@nextfile\empty
97 \expandafter\ifx\csname c@tikzext@no@\tikzexternal@figurename\endcsname\relax
98 \expandafter\gdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{0}%
99 \fi
100 \t@tikzexternal@tmpb=\expandafter{\tikzexternal@figurename}%
101 \count0=\csname c@tikzext@no@\tikzexternal@figurename\endcsname
102 \xdef\tikzexternal@curfilename{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb\the\count0 }%
103 \advance\count0 by1\relax
104 \expandafter\xdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{\the\count0 }%
105 \else
106 \t@tikzexternal@tmpb=\expandafter{\tikzexternal@nextfile}%
107 \xdef\tikzexternal@curfilename{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb}%
108 \fi
109 \endgroup
110 \global\let\tikzexternal@nextfile=\empty
111 \pgfincludeexternalgraphics\tikzexternal@curfilename
112 }%
113 \def\tikzset#1{}\def\pgfkeys#1{}\def\pgfqkeys#1#2{}
114 \long\def\beginpgfgraphicnamed#1#2\endpgfgraphicnamed{\pgfincludeexternalgraphics{#1}}
115 \def\tikzifinpicture#1#2{#2}
116 \def\pgfincludeexternalgraphics#1{%
117 \begingroup
118 \pgfexternalreaddpth{#1}%
119 \setbox1=\hbox{\includegraphics{#1}}%
120 \ifdim\pgfretval=0pt
121 \box1
122 \else
123 \dimen0=\pgfretval\relax
124 \hbox{\lower\dimen0 \box1 }%
125 \fi
126 \endgroup
127 }
128 \newread\r@pgf@reada
129 \def\pgfexternalreaddpth#1{%
130 \edef\pgfexternalreaddpth@restore{%
131 \noexpand\endlinechar=\the\endlinechar\space
132 \noexpand\catcode`\noexpand\@=\the\catcode`\@\space
133 }%
134 \def\pgfretval{0pt}%
135 \endlinechar=-1 % suppress white space at end
136 \catcode`\@=11
137 \openin\r@pgf@reada=#1.dpth
138 \pgfincludeexternalgraphics@read@dpth
139 \pgfexternalreaddpth@restore
140 }%
141 \def\pgfincludeexternalgraphics@read@dpth{%
142 \ifeof\r@pgf@reada
143 \closein\r@pgf@reada
144 \else
145 \read\r@pgf@reada to\pgfincludeexternalgraphics@auxline
146 \ifx\pgfincludeexternalgraphics@auxline\empty
147 \else
148 \expandafter\pgfincludeexternalgraphics@read@dpth@line\pgfincludeexternalgraphics@auxline\pgfincludeexternalgraphics@read@dpth@line@EOI
149 \fi
150 \expandafter\pgfincludeexternalgraphics@read@dpth
151 \fi
152 }%
153 \long\def\pgfincludeexternalgraphics@read@dpth@line#1#2\pgfincludeexternalgraphics@read@dpth@line@EOI{%
154 \ifcat\noexpand#1\relax
155 \if@filesw
156 {\toks0={#1#2}%
157 \immediate\write\@auxout{\noexpand\def\noexpand\dpthimport{\the\toks0 }\noexpand\dpthimport }%
158 }%
159 \fi
160 \else%
161 \def\pgfretval{#1#2}%
162 \fi
163 }%