Debian Codegraph @

texmf-dist/tex/generic/pgfplots/oldpgfcompatib/pgfplotsoldpgfsupp_pgfmanual.pdflinks.code.tex

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 % Support for the contents of this file will NOT be done by the PGF/TikZ team.
18 % Please contact the author and/or maintainer of pgfplots (Christian Feuersaenger) if you need assistance in conjunction
19 % with the deployment of this patch or partial content of PGF. Note that the author and/or maintainer of pgfplots has no obligation to fix anything:
20 % This file comes without any warranty as the rest of pgfplots; there is no obligation for help.
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22 %%% Date of this copy: Sa 7. Dez 20:58:23 CET 2013 %%%
23
24
25
26 %--------------------------------------------
27 %
28 % Package pgfplots
29 %
30 % Provides a user-friendly interface to create function plots (normal
31 % plots, semi-logplots and double-logplots).
32 %
33 % It is based on Till Tantau's PGF package.
34 %
35 % Copyright 2007/2008/2009 by Christian Feuersänger.
36 %
37 % This program is free software: you can redistribute it and/or modify
38 % it under the terms of the GNU General Public License as published by
39 % the Free Software Foundation, either version 3 of the License, or
40 % (at your option) any later version.
41 %
42 % This program is distributed in the hope that it will be useful,
43 % but WITHOUT ANY WARRANTY; without even the implied warranty of
44 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 % GNU General Public License for more details.
46 %
47 % You should have received a copy of the GNU General Public License
48 % along with this program. If not, see <http://www.gnu.org/licenses/>.
49 %
50 %--------------------------------------------
51
52 % This file provides an interface to the
53 % pgfmanual.prettyprint.code.tex thing -- it allows to
54 % *generate pdf crossrefs inside of codeexamples automatically*
55 % without any user input.
56 %
57 % Thus, you write
58 % \begin{codeexample}[]
59 % \begin{tikzpicture}[options]
60 % \end{tikzpicture}
61 % \end{codeexample}
62 % and pdf cross references to the definitions of 'tikzpicture'
63 % and any options will be generated automatically.
64 %
65 % Furthermore, pdf cross references will be generated for everything
66 % within vertical bars, |....|.
67 %
68 %
69 %
70 %
71 %
72 % The only necessary thing is that \pgfmanualpdflabel has been called
73 % for every (fully qualified) key, control sequence, environment or
74 % whatever.
75
76 \newif\ifpgfmanualpdfwarnings
77 \pgfmanualpdfwarningstrue
78
79 \newif\ifpgfmanualshowlabels
80
81 \pgfkeys{%
82 /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1,
83 /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace},
84 %
85 /codeexample/prettyprint/autolinks/.style={%
86 /codeexample/prettyprint/key name/.code={\pgfmanualpdfref{##1}{##1}},
87 /codeexample/prettyprint/key name with handler/.code 2 args={\pgfmanualpdfref{##1}{##1}/\pgfmanualpdfref{/handlers/##2}{##2}},
88 /codeexample/prettyprint/key value display only/.code={\pgfmanualprettyprintcode{##1}},
89 /codeexample/prettyprint/cs/.code={\pgfmanualpdfref{##1}{##1}},
90 /codeexample/prettyprint/cs with args/.code 2 args={\pgfmanualpdfref{##1}{##1}\{\pgfmanualprettyprintcode{##2}\pgfmanualclosebrace},
91 /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1,
92 /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\pgfmanualpdfref{##1}{##1}\{\pgfmanualprettyprintpgfkeys{##2}\pgfmanualclosebrace},
93 /codeexample/prettyprint/cs arguments/begin/.initial=1,
94 /codeexample/prettyprint/cs/begin/.code 2 args={##1\{\pgfmanualpdfref{##2}{##2}\pgfmanualclosebrace},
95 /codeexample/prettyprint/cs arguments/end/.initial=1,
96 /codeexample/prettyprint/cs/end/.code 2 args={##1\{\pgfmanualpdfref{##2}{##2}\pgfmanualclosebrace},
97 /codeexample/prettyprint/word/.code={\begingroup\pgfkeyssetvalue{/pdflinks/search key prefixes in}{}\pgfmanualpdfref{##1}{##1}\endgroup},
98 /codeexample/prettyprint/point/.code={##1},%
99 /codeexample/prettyprint/point with cs/.code 2 args={(\pgfmanualpdfref{##1}{##1}:##2},%
100 },%
101 /codeexample/prettyprint/autolinks,
102 }%
103
104 \pgfkeys{
105 %
106 % Enables or disables the parsing of codeexamples.
107 /pdflinks/codeexample links/.is if=pgfmanualprettyenabled,
108 /pdflinks/codeexample links/.default=true,
109 %
110 % whenever an unqualified key is found, the following key prefix
111 % list is tried to find a match.
112 /pdflinks/search key prefixes in/.initial={/tikz/,/pgf/},
113 %
114 % Enables or disables warnings for failed auto links:
115 /pdflinks/warnings/.is if=pgfmanualpdfwarnings,
116 /pdflinks/warnings/.default=true,
117 %
118 % Shows the autogenerated labels. This is useful to check if the
119 % 'search key prefixes in' worked as it ought to.
120 /pdflinks/show labels/.is if=pgfmanualshowlabels,
121 /pdflinks/show labels/.default=true,
122 /pdflinks/show labels=false,
123 % will be invoked with '#1' set to the generated label.
124 /pdflinks/show labels code/.code={
125 \hbox to 0pt{%
126 \vbox to 0pt{\hsize=0pt
127 \vskip-\baselineskip
128 \hbox to \hsize{%
129 \hss
130 {\footnotesize\ttfamily\textcolor{red}{#1}}%
131 \hss
132 }%
133 \vss
134 }%
135 \vbox to 0pt{\hsize=0pt
136 \vss
137 \hbox to \hsize{%
138 \hss
139 {\footnotesize\ttfamily\textcolor{red}{$\vert$}}%
140 \hss
141 }%
142 }%
143 \vsize=0pt
144 }%
145 },
146 %
147 % the link prefix written to the pdf file:
148 /pdflinks/internal link prefix/.initial=pgf,
149 }
150
151 \begingroup
152 \catcode`\_=12
153 \gdef\pgfmanualpdf@underscore{_}%
154 \catcode`\ =13\relax\gdef\pgfmanualpdf@install@active@space{\def {\space}}%
155 \endgroup
156
157 \gdef\pgfmanualpdf@installreplacements{%
158 \def\marg##1{{##1}}%
159 \def\oarg##1{[##1]}%
160 \def\meta##1{<##1>}%
161 \def\x{x}%
162 \def\textbackslash{<CS>}%
163 \def\\{\textbackslash}%
164 \def\space{:}%
165 \edef\ {\space}%
166 \edef\SPACE{\` \relax}%
167 \ifnum\the\catcode`\ =13 %
168 \pgfmanualpdf@install@active@space
169 \fi
170 \edef\#{}%
171 \def\printanat{@}%
172 \def\protect{}%
173 \def\textasciicircum{o}%
174 \def\_{\pgfmanualpdf@underscore}%
175 \expandafter\edef\pgfmanual@verb@activebar{\pgfmanual@verb@bar}%
176 }%
177
178 % Defines a new pdf cross ref label for use with \pgfmanualpdfref.
179 %
180 % Usage:
181 % \pgfmanualpdflabel{<label>}{<text>}
182 % #1: the label.
183 % The text #2 will be shown in the resulting pdf (if it is not empty).
184 %
185 % There is also support for catcode changes if <label> contains
186 % something which shouldn't be written as-is into .aux files:
187 % \pgfmanualpdflabel[\catcode`\|=12 ]{|-}{}
188 % -> this will write
189 % \begingroup \catcode `\|=12
190 % <code to deal with the label |- >
191 % \endgroup
192 % into the .aux file.
193 %
194 \def\pgfmanualpdflabel{\pgfutil@ifnextchar[{\pgfmanualpdflabel@opt}{\pgfmanualpdflabel@opt[]}}%
195 \def\pgfmanualpdflabel@opt[#1]#2#3{%
196 \begingroup
197 %
198 \def\pgfmanualpdf@catcode{#1}%
199 \pgfmanualpdf@catcode
200 %
201 \pgfmanualpdflabel@generate{#2}{#3}%
202 %
203 % this is pgfplots-specific: pgfplots supports generic styles which
204 % contain '\x' where '\x' iterates through 'x,y,z'.
205 \pgfutil@in@\x{#2}%
206 \ifpgfutil@in@
207 \def\x{y}%
208 \pgfmanualpdflabel@generate{#2}{#3}%
209 \def\x{z}%
210 \pgfmanualpdflabel@generate{#2}{#3}%
211 \fi
212 \endgroup
213 }%
214 \def\pgfmanualpdflabel@generate#1#2{%
215 \pgfmanual@handlespeciallabeltokens@in{#1}%
216 %
217 \def\pgfmanualpdflabel@generateone{0}%
218 \pgfutil@ifundefined{pgfd@lbl@\pgfmanualpdflabel@@}{%
219 % ok, no such label is known.
220 \def\pgfmanualpdflabel@generateone{1}%
221 }{%
222 \if\csname pgfd@lbl@\pgfmanualpdflabel@@\endcsname a% "a"ux
223 % ah, it is "just" known from a previous run, but there is
224 % no code in the pdf! Write it!
225 \def\pgfmanualpdflabel@generateone{1}%
226 \else
227 % ok, we already wrote one before. Skip.
228 \fi
229 }%
230 \if\pgfmanualpdflabel@generateone1%
231 \ifpgfmanualshowlabels
232 \pgfkeysvalueof{/pdflinks/show labels code/.@cmd}{\pgfmanualpdflabel@@}\pgfeov
233 \fi
234 %
235 \if@filesw
236 \ifx\pgfmanualpdf@catcode\pgfutil@empty
237 \else
238 \toks0=\expandafter{\pgfmanualpdf@catcode}%
239 \immediate\write\@auxout{%
240 \noexpand\begingroup
241 \the\toks0
242 }%
243 \fi
244 \immediate\write\@auxout{%
245 \noexpand\expandafter\noexpand\gdef
246 \noexpand\csname pgfd@lbl@\pgfmanualpdflabel@@\noexpand\endcsname{a}% a = known in "a"ux file
247 }%
248 \ifx\pgfmanualpdf@catcode\pgfutil@empty
249 \else
250 \immediate\write\@auxout{\noexpand\endgroup}%
251 \fi
252 \fi
253 \expandafter\gdef\csname pgfd@lbl@\pgfmanualpdflabel@@\endcsname{w}% 1. remember the label AND remember that we "w"rote it into the pdf.
254 \edef\pgfmanualpdflabel@@{\pgfkeysvalueof{/pdflinks/internal link prefix}.\pgfmanualpdflabel@@}%
255 \expandafter\hypertarget\expandafter{\pgfmanualpdflabel@@}{#2}%
256 \else
257 #2%
258 \fi
259 }%
260
261 % A pdf reference to label `#1' with (TeX) text `#2'.
262 % @see also \verbpdfref.
263 \def\pgfmanualpdfref#1#2{%
264 \begingroup
265 \pgfmanual@handlespeciallabeltokens@in{#1}%
266 %
267 \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname
268 \else
269 \global\let\pgfmanual@glob=\pgfmanualpdflabel@@
270 \def\pgfmanual@tempa{\foreach \prefix in }%
271 \pgfkeysgetvalue{/pdflinks/search key prefixes in}\pgfmanual@tempb
272 \expandafter\pgfmanual@tempa\expandafter{\pgfmanual@tempb}{%
273 \edef\pgfmanualpdflabel@@{\prefix\pgfmanualpdflabel@@}%
274 \expandafter\pgfmanual@handlespeciallabeltokens@in\expandafter{\pgfmanualpdflabel@@}%
275 \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname
276 \xdef\pgfmanual@glob{\pgfmanualpdflabel@@}%
277 \breakforeach
278 \fi
279 }%
280 \let\pgfmanualpdflabel@@=\pgfmanual@glob
281 \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname
282 \else
283 \ifpgfmanualpdfwarnings
284 \begingroup
285 \toks0={#1}%
286 \pgfmanual@warning{pgfmanualpdfref{\the\toks0 }: target label does not exist.}%
287 \endgroup
288 \fi
289 #2%
290 \let\pgfmanualpdflabel@@=\pgfutil@empty
291 \fi
292 \fi
293 \ifx\pgfmanualpdflabel@@\pgfutil@empty
294 \else
295 \expandafter\pgfmanualpdfref@\expandafter{\pgfmanualpdflabel@@}{#2}%
296 \fi
297 \endgroup
298 }%
299 \def\pgfmanualpdfref@#1#2{%
300 \pgfkeysgetvalue{/pdflinks/internal link prefix}\pgfmanual@temp
301 \expandafter\hyperlink\expandafter{\pgfmanual@temp.#1}{#2}%
302 \ifpgfmanualshowlabels
303 \pgfkeysvalueof{/pdflinks/show labels code/.@cmd}{#1}\pgfeov
304 \fi
305 }%
306
307 % Handles special tokens in a pdf label which should be treated with
308 % care.
309 %
310 % For example, backslashes might produce problems.
311 % This occurs quite frequently with automatically generated hyperrefs
312 % inside of codeexamples where \pgfmanualpdfref will be invoked -
313 % there, we get the catcode 12 backslashes.
314 % Check for them!
315 %
316 % #1: a token list which shall be used either as cross ref or as
317 % label.
318 %
319 % On output, the macro \pgfmanualpdflabel@@ will be '\edef'ed to the
320 % new, possibly modified value.
321 \def\pgfmanual@handlespeciallabeltokens@in#1{%
322 \begingroup
323 \pgfmanualpdf@installreplacements
324 \expandafter\pgfutil@in@\pgfmanual@pretty@backslash{#1}%
325 \ifpgfutil@in@
326 % assume the backslash is the first char and substitute it:
327 \pgfmanualpdfref@substitute@backslash#1\relax
328 \else
329 \edef\pgfmanualpdflabel@@{#1}%
330 \fi
331 \def\pgfmanual@tmp{\pgfutilstrreplace{ }{\space}}%
332 \expandafter\pgfmanual@tmp\expandafter{\pgfmanualpdflabel@@}%
333 \edef\pgfmanualpdflabel@@{\pgfretval}%
334 \pgfmath@smuggleone\pgfmanualpdflabel@@
335 \endgroup
336 }%
337
338 \expandafter\def\expandafter\pgfmanualpdfref@substitute@backslash\expandafter#\expandafter1\pgfmanual@pretty@backslash#2\relax{%
339 \edef\pgfmanualpdflabel@@{#1\textbackslash #2}%
340 }%
341
342 % Typesets '#1' in red,\texttt like every declaration. It will also
343 % generate a pdf cross ref anchor for #1.
344 %
345 % WARNING: this changes catcodes! In case this is not acceptable in
346 % your context, you will need to generate a \pgfmanualpdflabel
347 % manually.
348 %
349 % \declareandlabel{\controlsequence} can be used as |\controlsequence|
350 \def\declareandlabel{%
351 \begingroup
352 \pgfmanual@verb@preparecatcodes@
353 \def\pgfmanualprettyprinterhandlecollectedargs##1{%
354 \pgfmanualpdflabel##1{\texttt{\declare##1}}% mark: '##1' contains already braces.
355 \endgroup
356 }%
357 \pgfmanualprettyprintercollectargcount1{\relax}%
358 }
359
360 %
361 % \verbpdfref{\controlsequence more stuff}
362 % is the same as writing |\controlsequence more stuff|, but the
363 % *complete* argument is supposed to be one label.
364 %
365 % The difference to \pgfmanualpdfref{...}{} is that the argument is
366 % supposed to be verbatim text.
367 \def\verbpdfref{%
368 \begingroup
369 \pgfmanual@verb@preparecatcodes@
370 \def\pgfmanualprettyprinterhandlecollectedargs##1{%
371 \pgfmanualpdfref##1{\texttt{##1}}% mark: '##1' contains already braces.
372 \endgroup
373 }%
374 \pgfmanualprettyprintercollectargcount1{\relax}%
375 }
376
377 % Prepare active vertical bars, |....| for auto-pretty cross
378 % referencing.
379 %
380 % Example:
381 % |\pgfkeys| -> will generate a hyperref!
382 {
383 \catcode`\|=12
384 \gdef\pgfmanual@verb@bar{|}%
385 % \gdef\pgfmanual@verb@collect#1|{%
386 % % this command will also handle control sequences.
387 % \texttt{\pgfmanualprettyprintpgfkeys{#1}}%
388 % \endgroup
389 % }%
390 \catcode`\|=13
391 \gdef\pgfmanual@verb@activebar{|}%
392 }
393 \def\pgfmanual@verb{%
394 \begingroup
395 \pgfmanual@verb@preparecatcodes@
396 \toksdef\t@pgfmanual@verb=0
397 \t@pgfmanual@verb={}%
398 \pgfmanual@verb@collect
399 }
400 % this version of \pgfmanual@verb@collect is less efficient than the
401 % one uncommented above. BUT: it can auto-detect the case when
402 % |...| has been provided somewhere where I can't change catcodes!
403 % The other one would simply fail to compile.
404 \def\pgfmanual@verb@collect#1{%
405 \def\pgfmanual@temp{#1}%
406 \ifx\pgfmanual@temp\pgfmanual@verb@bar
407 % ok, finish:
408 \edef\pgfmanual@verb@collect@next{%
409 % this command will also handle control sequences.
410 \noexpand\endgroup
411 \noexpand\texttt{\noexpand\pgfmanualprettyprintpgfkeys{\the\t@pgfmanual@verb}}%
412 }%
413 \else
414 \ifx\pgfmanual@temp\pgfmanual@verb@activebar
415 % ohoh... that should not happen! It means someone invoked
416 % |...| within an argument; I couln't change catcodes.
417 % Ok, resort to a simple fallback solution.
418 % FIXME : I have just realized that THIS DOESN'T PRESERVE SPACES
419 \edef\pgfmanual@verb@collect@next{%
420 \noexpand\endgroup
421 \noexpand\texttt{\the\t@pgfmanual@verb}%
422 }%
423 \else
424 \t@pgfmanual@verb=\expandafter{\the\t@pgfmanual@verb #1}%
425 \let\pgfmanual@verb@collect@next=\pgfmanual@verb@collect
426 \fi
427 \fi
428 \pgfmanual@verb@collect@next
429 }%
430
431 \AtBeginDocument{%
432 \ifpgfmanualprettyenabled
433 \catcode`\|=13
434 \expandafter\let\pgfmanual@verb@activebar=\pgfmanual@verb
435 \fi
436 }%
437
438 \def\pgfmanual@verb@preparecatcodes@{%
439 \let\do\@makeother%
440 \dospecials%
441 \catcode`\%=12 % THATS IMPORTANT! Do *not* handle comments!
442 % these catcodes are expected by the pretty printer...
443 %\catcode`\^^M=13
444 \catcode`\ =13
445 \catcode`\^^I=13
446 \expandafter\def\pgfmanual@pretty@activespace{\space}%
447 \expandafter\def\pgfmanual@pretty@activetab{\space\space\space\space}%
448 }%
449 \endinput
450 % vi: ts=4 sw=4