summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_tikzexternal.sty
blob: eefc385245e8f27f48937d874cd3ae846679c817 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% This file is a copy of some part of PGF/Tikz.
%%% It has been copied here to provide :
%%%  - compatibility with older PGF versions
%%%  - availability of PGF contributions by Christian Feuersaenger
%%%    which are necessary or helpful for pgfplots.
%%%
%%% For reasons of simplicity, I have copied the whole file, including own contributions AND
%%% PGF parts. The copyrights are as they appear in PGF.
%%%
%%% Note that pgfplots has compatible licenses.
%%% 
%%% This copy has been modified in the following ways:
%%%  - nested \input commands have been updated
%%%  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Date of this copy: Di 29. Dez 22:11:16 CET 2009 %%%



% Copyright 2008 by Christian Feuersaenger
%
% 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.
%
% In addition to the above licenses, this particular file may also be
% directly inlined into other documents and this copyright notice may
% be removed. Additionally, when you inline this file, you may modify
% it as needed and you may remove comments.
%
% This file is intended to be distributed or even inlined into a file
% when a document needs to be typeset on a system that does not have
% pgf/TikZ installed. 
%
% It replaces \tikzpicture/ \endtikzpicture and \tikz and invokes the
% \includegraphics with the correct file name instead.

\RequirePackage{graphicx}

\toksdef\t@tikzexternal@tmpa=0
\toksdef\t@tikzexternal@tmpb=1

\def\tikzexternalize{\@ifnextchar[{\tikzexternalize@opt}{\tikzexternalize@opt[]}}%
\def\tikzexternalize@opt[#1]#2{\def\tikzexternal@realjob{#2}}

\def\tikzsetnextfilename#1{\gdef\tikzexternal@nextfile{#1}}
\def\tikzsetexternalprefix#1{\def\tikzexternal@filenameprefix{#1}}
\def\tikzsetfigurename#1{\def\tikzexternal@figurename{#1}}%
\tikzsetnextfilename{}
\tikzsetexternalprefix{}
\tikzsetfigurename{\tikzexternal@realjob-figure}%

\long\def\tikzpicture#1\end#2{% collect every thing up to \end{tikzpicture}
	\def\tikzexternal@laTeX@collectpicture@@{#2}%
	\ifx\tikzexternal@laTeX@collectpicture@@\tikzexternal@laTeX@tikzpicturestring
		\tikzexternal@image
		\end{tikzpicture}%
	\else
		\expandafter
		\tikzpicture
	\fi
}%
\def\endtikzpicture{}
\def\tikzexternal@laTeX@tikzpicturestring{tikzpicture}%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Replacement for \tikz short command:
\def\tikz{\@ifnextchar[{\tikz@opt}{\tikz@opt[]}}
\def\tikz@opt[#1]{\@ifnextchar\bgroup{\tikz@opt@{#1}}{\tikz@opt@@{#1}}}
\def\tikz@opt@#1#2{\tikz@opt@process{#1}{#2}}
\def\tikz@opt@@#1{%
  \def\tikz@next{\tikz@collectnormalsemicolon{#1}}%
  \ifnum\the\catcode`\;=\active\relax%
    \def\tikz@next{\tikz@collectactivesemicolon{#1}}%
  \fi%
  \tikz@next}
\def\tikz@collectnormalsemicolon#1#2;{\tikz@opt@process{#1}{#2;}}
{
  \catcode`\;=\active
  \gdef\tikz@collectactivesemicolon#1#2;{%
	\tikz@opt@process{#1}{#2;}%
  }
}
\def\tikz@opt@process#1#2{\tikzexternal@image}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\tikzexternal@image{%
	\leavevmode
	\begingroup
	\t@tikzexternal@tmpa=\expandafter{\tikzexternal@filenameprefix}%
	\ifx\tikzexternal@nextfile\empty
		\expandafter\ifx\csname c@tikzext@no@\tikzexternal@figurename\endcsname\relax
			\expandafter\gdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{0}%
		\fi
		\t@tikzexternal@tmpb=\expandafter{\tikzexternal@figurename}%
		\count0=\csname c@tikzext@no@\tikzexternal@figurename\endcsname
		\xdef\tikzexternal@curfilename{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb\the\count0 }%
		\advance\count0 by1\relax
		\expandafter\xdef\csname c@tikzext@no@\tikzexternal@figurename\endcsname{\the\count0 }%
	\else
		\t@tikzexternal@tmpb=\expandafter{\tikzexternal@nextfile}%
		\xdef\tikzexternal@curfilename{\the\t@tikzexternal@tmpa\the\t@tikzexternal@tmpb}%
	\fi
	\endgroup
	\global\let\tikzexternal@nextfile=\empty
	\tikzexternalimage\tikzexternal@curfilename
}%
\def\tikzexternalimage#1{%
	% now check for (optional) .dpth files for the 'baseline' option:
	\begingroup
	\setbox1=\hbox{\includegraphics{#1}}%
	\openin1=#1.dpth
	\ifeof1	\box1 
	\else
		\read1 to\pgfincludeexternalgraphics@dp	\closein1
		\dimen0=\pgfincludeexternalgraphics@dp\relax
		\hbox{\lower\dimen0\box1}%
	\fi
	\endgroup
}
\def\tikzset#1{}\def\pgfkeys#1{}\def\pgfqkeys#1#2{}
\long\def\beginpgfgraphicnamed#1#2\endpgfgraphicnamed{\tikzexternalimage{#1}}