summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/pgfplots/pgfplots-macros.tex
blob: c018e43613a7dcb9fa7bb8f7230eb74cff4e7691 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830

\def\eps{\textsc{eps}}

\input pgfmanual-en-macros.tex


\def\pgfplotsifdocpackageuptodate#1#2{%
	\pgfkeysifdefined{/codeexample/prettyprint/word/.@cmd}{#1}{#2}
}%

\pgfplotsiffileexists{pgfmanual.sty}{%
	\RequirePackage{pgfmanual}
	\pgfplotsifdocpackageuptodate{}{%
		\makeatletter
		\input pgfplotsoldpgfsupp_pgfmanual.code.tex
		\makeatother
	}%
}{%
	\makeatletter
	\input pgfplotsoldpgfsupp_pgfmanual.code.tex
	\makeatother
}%

\makeatletter
\def\pgfplotsmakefilelinkifuseful#1#2{%
	\protect\pgfplotsmakefilelinkifuseful@{#1}{#2}%
}%
\def\pgfplotsmakefilelinkifuseful@#1#2{%
	\edef\temp{#1}%
	\edef\tempb{\jobname}%
	\edef\temp{\meaning\temp}% \meaning normalizes the catcodes.
	\edef\tempb{\meaning\tempb}%
	\ifx\temp\tempb
		% we are processing '#1'. Don't make a link.
		#2%
	\else
		\href{file:#1.pdf}{#2}%
	\fi
}%
\makeatother


\pgfkeys{
	/codeexample/prettyprint/cs arguments/pgfplotscreateplotcyclelist/.initial=2,
	/codeexample/prettyprint/cs/pgfplotscreateplotcyclelist/.code args={#1#2#3}{\pgfmanualpdfref{#1}{#1}\{#2\}\{\pgfmanualprettyprintpgfkeys{#3}\pgfmanualclosebrace},
	/codeexample/prettyprint/cs arguments/tikzset/.initial=1,
	/codeexample/prettyprint/cs/tikzset/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace},
	/codeexample/prettyprint/cs arguments/pgfplotsset/.initial=1,
	/codeexample/prettyprint/cs/pgfplotsset/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace},
	/codeexample/prettyprint/cs arguments/pgfplotstableset/.initial=1,
	/codeexample/prettyprint/cs/pgfplotstableset/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace},
	/codeexample/prettyprint/cs arguments/usepgfplotslibrary/.initial=1,
	/codeexample/prettyprint/cs/usepgfplotslibrary/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualpdfref{#2}{#2}\pgfmanualclosebrace},
	%
	%
	%/codeexample/prettyprint/key value/cycle list/.code 2 args={\pgfmanualprettyprintpgfkeys{#2}},
	/codeexample/prettyprint/key value/xticklabel/.code 2 args={\pgfmanualprettyprintcode{#2}},
	/codeexample/prettyprint/key value/yticklabel/.code 2 args={\pgfmanualprettyprintcode{#2}},
	/codeexample/prettyprint/key value/zticklabel/.code 2 args={\pgfmanualprettyprintcode{#2}},
	/codeexample/prettyprint/key value/includegraphics/.code 2 args={\pgfmanualprettyprintpgfkeys{#2}},
	%
	%
	% whenever an unqualified key is found, the following key prefix
	% list is tried to find a match.
	/pdflinks/search key prefixes in={/pgfplots/table/,/pgfplots/error bars/,/pgfplots/,/pgfplots/plot file/,/tikz/,/pgf/},
	%
	% the link prefix written to the pdf file:
	/pdflinks/internal link prefix=pgfp,
	%
	/pdflinks/warnings=false,
	/pdflinks/codeexample links=true,
	/pdflinks/show labels=false,
}%


% should be used to show something in red which doesn't need to get a
% hyper ref.
%
% Examples are descriptions of key labels.
\def\declaretext#1{\texttt{\declare{#1}}}

% To be used whenever something NEW has been declared.
% In this case, a \pgfmanualpdflabel will be generated using '#1'.
%
% Use '\declaretext' if you only describe something local (for example
% the documentation of key values).
\def\declarelabel#1{%
	\texttt{\declare{#1}}%
	\pgfmanualpdflabel{#1}{}%
}

\def\pgfmanualbar{\char`\|}
\makeatletter

\newif\ifpgfplotsmanualexternalexpensive
\let\pgfplotsmanualexternalexpensivetrue@orig=\pgfplotsmanualexternalexpensivetrue

% use \pgfplotsmanualexternalexpensivetrue to externalize expensive
% examples.
\def\pgfplotsmanualexternalexpensivetrue{%
	\usepgfplotslibrary{external}
	\pgfplotsmanualexternalexpensivetrue@orig
	\tikzexternalize[
		prefix=figures/expensiveexample,
		figure name={},
		export=false, % needs to be activated for single pictures (i.e. expensive ones)
		mode=list and make,
		verbose=false,
		%xport=true,% FASTER FOR DEBUGGING
	]
	\tikzifexternalizing{%
		\nofiles
		\pgfkeys{/pdflinks/codeexample links=false}%
	}{}%
}%
%\pgfkeys{/pgf/images/include external/.code={\href{file:#1}{\pgfimage{#1}}}} % FIXME : NOT FOR THE FINAL VERSION

\newif\ifpgfplots@example@is@expensive

\pgfkeys{
	/codeexample/every codeexample/.append code={%
		\ifpgfplots@example@is@expensive
			\pgfkeys{/tikz/external/export=true}%
			\global\pgfplots@example@is@expensivefalse
		\fi
	}
}

% Write this macro directly in front of \begin{codeexample} (without arguments):
\def\pgfplotsexpensiveexample{%
	\ifpgfplotsmanualexternalexpensive
		\pgfplots@example@is@expensivetrue
	\else
		\message{[NOTE: I am now about to typeset an expensive example. You will need to ENLARGE YOUR TeX MEMORY CAPACITIES if this fails.]}%
	\fi
}%


\newenvironment{addplotoperation}[3][]{
  \begin{pgfmanualentry}
  	{%
	\let\ltxdoc@marg=\marg
	\let\ltxdoc@oarg=\oarg
	\let\ltxdoc@parg=\parg
	\let\ltxdoc@meta=\meta
	\def\marg##1{{\normalfont\ltxdoc@marg{##1}}}%
	\def\oarg##1{{\normalfont\ltxdoc@oarg{##1}}}%
	\def\parg##1{{\normalfont\ltxdoc@parg{##1}}}%
	\def\meta##1{{\normalfont\ltxdoc@meta{##1}}}%
    \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\addplot\ }}%
      \declare{\texttt{#2}} \texttt{#3;}}%
	  \unskip
	 \nobreak
    \pgfmanualentryheadline{\textcolor{gray}{\texttt{\char`\\addplot}\oarg{options} }%
      \declare{\texttt{#2}} \texttt{#3} \textcolor{gray}{\meta{trailing path commands}}\texttt{;}}%
	  \unskip
	 \nobreak
    \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\addplot3}} $\dotsc$}%
    \def\pgfmanualtest{#1}%
    \ifx\pgfmanualtest\@empty%
      \index{#2@\protect\textcolor{gray}{\protect\texttt{plot}}\protect\texttt{ #2}}%
      \index{Plot operations!plot #2@\protect\texttt{plot #2}}%
    \fi%
	\pgfmanualpdflabel{\textbackslash addplot #2}{}%
	\pgfmanualpdflabel{plot #2}{}%
	\pgfmanualpdflabel{#2}{}%
	}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}

\newenvironment{addplot+}{
  \begin{pgfmanualentry}
  	{%
	\let\ltxdoc@marg=\marg
	\let\ltxdoc@oarg=\oarg
	\let\ltxdoc@parg=\parg
	\let\ltxdoc@meta=\meta
	\def\marg##1{{\normalfont\ltxdoc@marg{##1}}}%
	\def\oarg##1{{\normalfont\ltxdoc@oarg{##1}}}%
	\def\parg##1{{\normalfont\ltxdoc@parg{##1}}}%
	\def\meta##1{{\normalfont\ltxdoc@meta{##1}}}%
    \pgfmanualentryheadline{{\ttfamily\declare{\char`\\addplot+}\oarg{options} \textcolor{gray}{\dots};}}%
    \index{addplot+@\protect\texttt{\protect\textbackslash addplot+}}%
	\pgfmanualpdflabel{\textbackslash addplot+}{}%
	}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}
\newenvironment{addplot3generic}{
  \begin{pgfmanualentry}
  	{%
	\let\ltxdoc@marg=\marg
	\let\ltxdoc@oarg=\oarg
	\let\ltxdoc@parg=\parg
	\let\ltxdoc@meta=\meta
	\def\marg##1{{\normalfont\ltxdoc@marg{##1}}}%
	\def\oarg##1{{\normalfont\ltxdoc@oarg{##1}}}%
	\def\parg##1{{\normalfont\ltxdoc@parg{##1}}}%
	\def\meta##1{{\normalfont\ltxdoc@meta{##1}}}%
    \pgfmanualentryheadline{{\ttfamily\declare{\char`\\addplot3}\oarg{options} \meta{input data} \meta{trailing path commands};}}%
    \index{addplot3@\protect\texttt{\protect\textbackslash addplot3}}%
	\pgfmanualpdflabel{\textbackslash addplot3}{}%
	}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}
\newenvironment{addplot3operation}[3][]{
  \begin{pgfmanualentry}
  	{%
	\let\ltxdoc@marg=\marg
	\let\ltxdoc@oarg=\oarg
	\let\ltxdoc@parg=\parg
	\let\ltxdoc@meta=\meta
	\def\marg##1{{\normalfont\ltxdoc@marg{##1}}}%
	\def\oarg##1{{\normalfont\ltxdoc@oarg{##1}}}%
	\def\parg##1{{\normalfont\ltxdoc@parg{##1}}}%
	\def\meta##1{{\normalfont\ltxdoc@meta{##1}}}%
    \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\addplot3\ }}%
      \declare{\texttt{#2}} \texttt{#3;}}%
	  \unskip
	 \nobreak
    \pgfmanualentryheadline{\textcolor{gray}{\texttt{\char`\\addplot3}\oarg{options} }%
      \declare{\texttt{#2}} \texttt{#3} \textcolor{gray}{\meta{trailing path commands}}\texttt{;}}%
    \def\pgfmanualtest{#1}%
    \ifx\pgfmanualtest\@empty%
      \index{#2@\protect\texttt{#2}}%
      \index{Plot operations!addplot3 #2@\protect\texttt{#2}}%
    \fi%
	\pgfmanualpdflabel{\textbackslash addplot3 #2}{}%
	\pgfmanualpdflabel{plot3 #2}{}%
	}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}

\newenvironment{codekey}[1]{%
  \begin{pgfmanualentry}
 	\pgfmanualentryheadline{{\ttfamily\declarekey{#1}\textcolor{gray}{/\pgfmanualpdfref{/handlers/.code}{.code}}=\marg{...}}\hfill}%
	\def\mykey{#1}%
	\def\mypath{}%
	\def\myname{}%
	\firsttimetrue%
	\decompose#1/\nil%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}
\newenvironment{codeargskey}[2]{%
  \begin{pgfmanualentry}
  	{\toks0={#2}%
  	\xdef\argpattern{\the\toks0 }%
	}%
  	\pgfmanual@command@to@string\argpattern\argpattern
 	\pgfmanualentryheadline{{\ttfamily\declarekey{#1}\textcolor{gray}{/\pgfmanualpdfref{/handlers/.code}{.code args}}=\texttt{\{\argpattern\}}\marg{...}}\hfill}%
	\def\mykey{#1}%
	\def\mypath{}%
	\def\myname{}%
	\firsttimetrue%
	\decompose#1/\nil%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}
\def\pgfmanual@command@to@string#1#2{%
	\expandafter\pgfmanual@command@to@string@@\meaning#1\pgfmanual@EOI{#2}%
}%
\xdef\pgfmanual@glob@TMPa{\meaning\pgfutil@empty}%
\expandafter\def\expandafter\pgfmanual@command@to@string@@\pgfmanual@glob@TMPa#1\pgfmanual@EOI#2{%
	\def#2{#1}%
}%

\newenvironment{pgfplotscodekey}[1]{%
	\begin{codekey}{/pgfplots/#1}%
}
{
  \end{codekey}
}
\newenvironment{pgfplotscodetwokey}[1]{%
  \begin{pgfmanualentry}
 	\pgfmanualentryheadline{{\ttfamily\declarekey{/pgfplots/#1}\textcolor{gray}{/\pgfmanualpdfref{/handlers/.code 2 args}{.code 2 args}}=\marg{...}}\hfill}%
	\def\mykey{/pgfplots/#1}%
	\def\mypath{}%
	\def\myname{}%
	\firsttimetrue%
	\decompose/pgfplots/#1/\nil%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}

\newenvironment{pgfplotsxycodekeylist}[1]{%
	\begingroup
	\let\oldpgfmanualentryheadline=\pgfmanualentryheadline
	\def\pgfmanualentryheadline##1{%
		\pgfmanualentryheadline@##1\pgfplots@EOI
	}%
	\def\pgfmanualentryheadline@##1\hfill##2\pgfplots@EOI{%
		\oldpgfmanualentryheadline{{\ttfamily\declarekey{##1}\textcolor{gray}{/\pgfmanualpdfref{/handlers/.code}{.code}}=\marg{...}}\hfill}%
	}
	\begin{pgfplotsxykeylist}{#1}%
}
{
	\end{pgfplotsxykeylist}
	\endgroup
}

\newenvironment{pgfplotskey}[1]{%
  \begin{key}{/pgfplots/#1}%
}
{
  \end{key}
}

\def\choicesep{$\vert$}%
\def\choicearg#1{\texttt{#1}}

\newif\iffirstchoice
\newcommand\mchoice[1]{%
	\begingroup
	\let\margold=\marg
	\def\marg##1{{\normalfont\margold{##1}}}%
	\firstchoicetrue
	\foreach \mchoice@ in {#1} {%
		\iffirstchoice
			\global\firstchoicefalse
		\else
			\choicesep
		\fi
		\choicearg{\mchoice@}%
	}%
	\endgroup
}%




% \begin{xykey}{/path/\x label=value}
% \end{xykey}
%
% has same features with 'default', 'initially' etc as key environment
\newenvironment{xykey}[2][]{%
	\begin{pgfmanualentry}
    \def\extrakeytext{}
	\insertpathifneeded{#2}{#1}%
	\expandafter\pgfutil@in@\expandafter=\expandafter{\mykey}%
	\ifpgfutil@in@%
		\expandafter\xykey@eq\mykey\@nil
	\else
		\expandafter\xykey@noeq\mykey\@nil
	\fi
	\pgfmanualbody
}{%
	\end{pgfmanualentry}
}%

% \begin{xystylekey}{/path/\x label=value}
% \end{xystylekey}
%
% has same features with 'default', 'initially' etc as key environment
\newenvironment{xystylekey}[2][]{%
	\begin{pgfmanualentry}
    \def\extrakeytext{style, }
	\insertpathifneeded{#2}{#1}%
	\expandafter\pgfutil@in@\expandafter=\expandafter{\mykey}%
	\ifpgfutil@in@%
		\expandafter\xykey@eq\mykey\@nil
	\else
		\expandafter\xykey@noeq\mykey\@nil
	\fi
	\pgfmanualbody
}{%
	\end{pgfmanualentry}
}%

% \insertpathifneeded{a key}{/pgfplots} -> assign mykey={/pgfplots/a key}
% \insertpathifneeded{/tikz/a key}{/pgfplots} -> assign mykey={/tikz/a key}
%
% #1: the key
% #2: a default path (or empty)
\def\insertpathifneeded#1#2{%
	\def\insertpathifneeded@@{#2}%
	\ifx\insertpathifneeded@@\empty
		\def\mykey{#1}%
	\else
		\insertpathifneeded@#1\@nil
		\ifpgfutil@in@
			\def\mykey{#1}%
		\else
			\def\mykey{#2/#1}%
		\fi
	\fi
}%
\def\insertpathifneeded@#1#2\@nil{%
	\def\insertpathifneeded@@{#1}%
	\def\insertpathifneeded@@@{/}%
	\ifx\insertpathifneeded@@\insertpathifneeded@@@
		\pgfutil@in@true
	\else
		\pgfutil@in@false
	\fi
}%

% \begin{keylist}[default path]
% 	{/path/option 1=value,/path/option 2=value2}
% \end{keylist}
\newenvironment{keylist}[2][]{%
	\begin{pgfmanualentry}
    \def\extrakeytext{}%
	\foreach \xx in {#2} {%
		\expandafter\insertpathifneeded\expandafter{\xx}{#1}%
		\expandafter\extractkey\mykey\@nil%
	}%
	\pgfmanualbody
}{%
  \end{pgfmanualentry}
}%

\newenvironment{pgfplotskeylist}[1]{%
	\begin{keylist}[/pgfplots]{#1}%
}{%
	\end{keylist}%
}

\newenvironment{anchorlist}[1]{
  \begin{pgfmanualentry}
  	\foreach \xx in {#1} {%
		\pgfmanualentryheadline{Anchor {\ttfamily\declare{\xx}}}%
		\index{\xx @\protect\texttt{\xx} anchor}%
		\index{Anchors!\xx @\protect\texttt{\xx}}
		\expandafter\pgfmanualpdflabel\expandafter{\xx}{}
	}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}

\newenvironment{coordinatesystemlist}[1]{
  \begin{pgfmanualentry}
  	\foreach \xx in {#1} {%
		\pgfmanualentryheadline{Coordinate system {\ttfamily\declare{\xx}}}%
		\index{\xx @\protect\texttt{\xx} coordinate system}%
		\index{Coordinate systems!\xx @\protect\texttt{\xx}}
		\expandafter\pgfmanualpdflabel\expandafter{\xx}{}
	}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}
\renewenvironment{coordinatesystem}[1]{
  \begin{pgfmanualentry}
    \pgfmanualentryheadline{Coordinate system {\ttfamily\declare{#1}}}%
    \index{#1@\protect\texttt{#1} coordinate system}%
    \index{Coordinate systems!#1@\protect\texttt{#1}}
	\pgfmanualpdflabel{#1}{}
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}

% \begin{xykeylist}[default path]
% 	{/path/option \x1=value,/path/option \x2=value2,/path/option \x3=value}
% \end{xykeylist}
\newenvironment{xykeylist}[2][]{%
	\begin{pgfmanualentry}
    \def\extrakeytext{}
	\foreach \xx in {#2} {%
		\expandafter\insertpathifneeded\expandafter{\xx}{#1}%
		\expandafter\pgfutil@in@\expandafter=\expandafter{\mykey}%
		\ifpgfutil@in@%
			\expandafter\xykey@eq\mykey\@nil
		\else
			\expandafter\xykey@noeq\mykey\@nil
		\fi
	}%
	\pgfmanualbody
}{%
  \end{pgfmanualentry}
}%

\makeatother % FIXME this is almost surely a bug in pgfmanual-en-macros
% \begin{commandlist}
% 	{\command1{arg1},\command2{\arg2}}
% \end{commandlist}
\newenvironment{commandlist}[1]{%
	\begin{pgfmanualentry}
	\foreach \xx in {#1} {%
		\expandafter\extractcommand\xx\@@%
	}%
	\pgfmanualbody
}{%
  \end{pgfmanualentry}
}%

\newenvironment{texif}[1]{%
	\begin{pgfmanualentry}
	\pgfmanualentryheadline{\declare{\texttt{\textbackslash if#1}}\meta{true code}\texttt{\textbackslash else}\meta{else code}\texttt{\textbackslash fi}}%
	\index{if#1}%
	\pgfmanualpdflabel{\\if#1}{}%
	\pgfmanualbody
}{%
  \end{pgfmanualentry}
}%
\makeatletter

\newif\ifxykeyfound

\def\pgfmanual@xykey@install@replacements{%
	\def\ { }%
	\def\space{ }%
}%

\def\xykey@eq#1=#2\@nil{%
	\begingroup
	\pgfmanual@xykey@install@replacements
	\def\x{x}%
	\xdef\mykey{#1}%
	\def\xykey@@{#1}%
	\ifx\xykey@@\mykey
		\xykeyfoundfalse
	\else
		\xykeyfoundtrue
	\fi
    \expandafter\extractkey\mykey=#2\@nil%
	\ifxykeyfound
		\def\x{y}%
		\xdef\mykey{#1}%
		\expandafter\extractkey\mykey=#2\@nil%
		\def\x{z}%
		\xdef\mykey{#1}%
		\expandafter\extractkey\mykey=#2\@nil%
	\fi
	\endgroup
}
\def\xykey@noeq#1\@nil{%
	\begingroup
	\pgfmanual@xykey@install@replacements
	\def\x{x}%
	\xdef\mykey{#1}%
	\def\xykey@@{#1}%
	\ifx\xykey@@\mykey
		\xykeyfoundfalse
	\else
		\xykeyfoundtrue
	\fi
    \expandafter\extractkey\mykey\@nil%
	\ifxykeyfound
		\def\x{y}%
		\xdef\mykey{#1}%
		\expandafter\extractkey\mykey\@nil%
		\def\x{z}%
		\xdef\mykey{#1}%
		\expandafter\extractkey\mykey\@nil%
	\fi
	\endgroup
}

% \begin{pgfplotsxykey}{\x label=value}
% \end{pgfplotsxykey}
%
% It introduces the path /pgfplots/ automatically.
%
% has same features with 'default', 'initially' etc as key environment
\newenvironment{pgfplotsxykey}[1]{%
	\begin{xykey}[/pgfplots]{#1}%
}{%
	\end{xykey}%
}


\newenvironment{pgfplotsxykeylist}[1]{%
	\begin{xykeylist}[/pgfplots]{#1}%
}{%
	\end{xykeylist}%
}


% the first, optional argument is the default key path to insert.
\newenvironment{plottype}[2][/tikz]{%
	\begin{keylist}[#1]{#2}%
	\end{keylist}
  \begin{pgfmanualentry}
    \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\addplot+[\declare{#2}]}}}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}

\def\index@prologue{\section*{Index}\addcontentsline{toc}{section}{Index}
}

\newenvironment{pgfplotstablecolumnkey}{%
  \begin{pgfmanualentry}
 	\pgfmanualentryheadline{{\ttfamily\textcolor{gray}{/pgfplots/table/}\declare{columns/\meta{column name}}\textcolor{gray}{/.style}=\marg{key-value-list}}\hfill}%
	\pgfplotsmanualkeyindex{/pgfplots/table/columns}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}
\newenvironment{pgfplotstabledisplaycolumnkey}{%
  \begin{pgfmanualentry}
 	\pgfmanualentryheadline{{\ttfamily\textcolor{gray}{/pgfplots/table/}\declare{display columns/\meta{index}}\textcolor{gray}{/.style}=\marg{key-value-list}}\hfill}%
	\pgfplotsmanualkeyindex{/pgfplots/table/display columns}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}
\newenvironment{pgfplotstablealiaskey}{%
  \begin{pgfmanualentry}
 	\pgfmanualentryheadline{{\ttfamily\textcolor{gray}{/pgfplots/table/}\declare{alias/\meta{col name}}\textcolor{gray}{/.initial}=\marg{real col name}}\hfill}%
	\pgfplotsmanualkeyindex{/pgfplots/table/alias}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}


\def\pgfplotsmanualkeyindex#1{%
	\def\mypath{#1}%
	\def\myname{}%
	\firsttimetrue%
	\decompose#1/\nil%
}
\newenvironment{pgfplotstablecreateonusekey}{%
  \begin{pgfmanualentry}
 	\pgfmanualentryheadline{{\ttfamily\textcolor{gray}{/pgfplots/table/}\declare{create on use/\meta{col name}}\textcolor{gray}{/.style}=\marg{create options}}\hfill}%
	\def\mykey{/pgfplots/table/create on use}%
    \pgfmanualbody
	\pgfplotsmanualkeyindex{/pgfplots/table/create on use}%
}
{
  \end{pgfmanualentry}
}

\def\pgfplotsassertcmdkeyexists#1{%
	\pgfkeysifdefined{/pgfplots/#1/.@cmd}\relax{%
		\pgfplots@error{DOCUMENTATION ERROR: command key /pgfplots/#1 does not exist!}%
	}%
}%

{
\catcode`\ =12%
\gdef\makespaceexpandable{\def\ { }}}%

\def\pgfplotsassertXYcmdkeyexists#1{%
	{\makespaceexpandable\def\x{x}\edef\pgfplotsassertXYcmdkeyexists@tmp{#1}%
	\pgfkeysifdefined{/pgfplots/\pgfplotsassertXYcmdkeyexists@tmp/.@cmd}\relax{%
		\pgfplots@error{DOCUMENTATION ERROR: command key /pgfplots/#1 does not exist!}%
	}}%
	{\makespaceexpandable\def\x{y}\edef\pgfplotsassertXYcmdkeyexists@tmp{#1}%
	\pgfkeysifdefined{/pgfplots/\pgfplotsassertXYcmdkeyexists@tmp/.@cmd}\relax{%
		\pgfplots@error{DOCUMENTATION ERROR: command key /pgfplots/#1 does not exist!}%
	}}%
}%

\def\pgfplotsshortstylekey #1=#2\pgfeov{%
	\pgfplotsassertcmdkeyexists{#1}%
	\pgfplotsassertcmdkeyexists{#2}%
	\begin{pgfplotskey}{#1=\marg{key-value-list}}
		An abbreviation for \texttt{\pgfmanualpdfref{#2}{#2}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}\marg{key-value-list}.

		It appends options to the already existing style \texttt{\pgfmanualpdfref{#2}{#2}}.
	\end{pgfplotskey}
}
\def\pgfplotsshortxystylekey #1=#2\pgfeov{%
	\pgfplotsassertXYcmdkeyexists{#1}%
	\pgfplotsassertXYcmdkeyexists{#2}%
	\begin{pgfplotsxykey}{#1=\marg{key-value-list}}
		An abbreviation for {\def\x{x}\texttt{\pgfmanualpdfref{#2}{#2}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}}\marg{key-value-list} 
		(or the respective styles for $y$, 
			{\def\x{y}\texttt{\pgfmanualpdfref{#2}{#2}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}}\marg{key-{}value-{}list},
		and the $z$--axis, 
			{\def\x{z}\texttt{\pgfmanualpdfref{#2}{#2}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}}\marg{key-{}value-{}list}).

		It appends options to the already existing style {\def\x{x}\texttt{\pgfmanualpdfref{#2}{#2}}}.
	\end{pgfplotsxykey}
}
\def\pgfplotsshortstylekeys #1,#2=#3\pgfeov{%
	\pgfplotsassertcmdkeyexists{#1}%
	\pgfplotsassertcmdkeyexists{#2}%
	\pgfplotsassertcmdkeyexists{#3}%
	\begin{pgfplotskeylist}{%
		#1=\marg{key-value-list},
		#2=\marg{key-value-list}}
		Different abbreviations for \texttt{\pgfmanualpdfref{#3}{#3}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}\marg{key-value-list}.
	\end{pgfplotskeylist}
}
\def\pgfplotsshortxystylekeys #1,#2=#3\pgfeov{%
	\pgfplotsassertXYcmdkeyexists{#1}%
	\pgfplotsassertXYcmdkeyexists{#2}%
	\pgfplotsassertXYcmdkeyexists{#3}%
	\begin{pgfplotsxykeylist}{%
		#1=\marg{key-value-list},
		#2=\marg{key-value-list}}
		Different abbreviations for {\def\x{x}\texttt{\pgfmanualpdfref{#3}{#3}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}}\marg{key-value-list}
		(or the respective styles for $y$, 
			{\def\x{y}\texttt{\pgfmanualpdfref{#3}{#3}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}\marg{key-{}value-{}list}}, and $z$,
			{\def\x{z}\texttt{\pgfmanualpdfref{#3}{#3}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}\marg{key-{}value-{}list}}%
			).
	\end{pgfplotsxykeylist}
}


%
% For using the correct form of including libraries in the manual.
% 
\newenvironment{pgfplotslibrary}[1]{%
  \begin{pgfmanualentry}
    \pgfmanualentryheadline{{\ttfamily\char`\\usepgfplotslibrary\char`\{\declare{#1}\char`\}\space\space \char`\%\space\space  \LaTeX\space and plain \TeX}}%
    \index{#1@\protect\texttt{#1} library}%
    \index{Libraries!#1@\protect\texttt{#1}}%
    \pgfmanualentryheadline{{\ttfamily\char`\\usepgfplotslibrary[\declare{#1}]\space \char`\%\space\space Con\TeX t}}%
    \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary\char`\{\declare{pgfplots.#1}\char`\}\space\space \char`\%\space\space \LaTeX\space and plain \TeX}}%
    \pgfmanualentryheadline{{\ttfamily\char`\\usetikzlibrary[\declare{pgfplots.#1}]\space \char`\%\space\space Con\TeX t}}%
	\pgfmanualpdflabel{#1}{}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}


%
% Creates and shows a colormap with specification '#1'.
\def\pgfplotsshowcolormapexample#1{%
	\pgfplotscreatecolormap{tempcolormap}{#1}%
	\pgfplotsshowcolormap{tempcolormap}%
}

% Shows the colormap named '#1'.
\def\pgfplotsshowcolormap#1{%
	\pgfplotscolormapifdefined{#1}{\relax}{%
		\pgfplotsset{colormap/#1}%
	}%
	\pgfplotscolormaptoshadingspec{#1}{8cm}\result
	\def\tempb{\pgfdeclarehorizontalshading{tempshading}{1cm}}%
	\expandafter\tempb\expandafter{\result}%
	\pgfuseshading{tempshading}%
}

\makeatother

\def\decompose/#1/#2\nil{%
  \def\test{#2}%
  \ifx\test\empty%
    % aha.
    \index{#1@\protect\texttt{#1} key}%
	\ifx\mypath\empty
	\else
		\index{\mypath#1@\protect\texttt{#1}}%
	\fi
    \def\myname{#1}%
	%\pgfmanualpdflabel{#1}{}% No, its better to use fully qualified keys and search if necessary!
  \else%
    \iffirsttime
		\begingroup	
			% also make a pdf link anchor with full key path.
			\def\hyperlabelwithoutslash##1/\nil{%
				\pgfmanualpdflabel{##1}{}%
			}%
			\hyperlabelwithoutslash/#1/#2\nil
		\endgroup
%    CF : disabled for /pgfplots/ prefix.
%		\def\mypath{#1@\protect\texttt{/#1/}!}%
%		\firsttimefalse
		\def\pgfplotslocTMPa{pgfplots}%
		\edef\pgfplotslocTMPb{#1}%
		\ifx\pgfplotslocTMPb\pgfplotslocTMPa
			\def\mypath{}%
		\else
			\def\mypath{#1@\protect\texttt{/#1/}!}%
		\fi
		\firsttimefalse
    \else
      \expandafter\def\expandafter\mypath\expandafter{\mypath#1@\protect\texttt{#1/}!}%
    \fi
    \def\firsttime{}
    \decompose/#2\nil%
  \fi%
}
\def\extracthandler#1#2\@nil{%
  \pgfmanualentryheadline{Key handler \meta{key}{\ttfamily/\declare{#1}}#2}%
  \index{\gobble#1@\protect\texttt{#1} handler}%
  \index{Key handlers!#1@\protect\texttt{#1}}
  \pgfmanualpdflabel{/handlers/#1}%
}
\def\extractcommand#1#2\@@{%
  \pgfmanualentryheadline{\declare{\texttt{\string#1}}#2}%
  \removeats{#1}%
  \index{\strippedat @\protect\myprintocmmand{\strippedat}}%
  \pgfmanualpdflabel{\textbackslash\strippedat}{}%
}
\def\extractenvironement#1#2\@@{%
  \pgfmanualentryheadline{{\ttfamily\char`\\begin\char`\{\declare{#1}\char`\}}#2}%
  \pgfmanualentryheadline{{\ttfamily\ \ }\meta{environment contents}}%
  \pgfmanualentryheadline{{\ttfamily\char`\\end\char`\{\declare{#1}\char`\}}}%
  \index{#1@\protect\texttt{#1} environment}%
  \index{Environments!#1@\protect\texttt{#1}}%
  \pgfmanualpdflabel{#1}{}%
}
\renewenvironment{predefinednode}[1]{
  \begin{pgfmanualentry}
    \pgfmanualentryheadline{Predefined node {\ttfamily\declare{#1}}}%
    \index{#1@\protect\texttt{#1} node}%
    \index{Predefined node!#1@\protect\texttt{#1}}
	\pgfmanualpdflabel{#1}{}%
    \pgfmanualbody
}
{
  \end{pgfmanualentry}
}