diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/pgfplots/pgfplots-macros.tex')
-rw-r--r-- | Master/texmf-dist/doc/latex/pgfplots/pgfplots-macros.tex | 407 |
1 files changed, 392 insertions, 15 deletions
diff --git a/Master/texmf-dist/doc/latex/pgfplots/pgfplots-macros.tex b/Master/texmf-dist/doc/latex/pgfplots/pgfplots-macros.tex index ce1d14208bc..3db2099ab98 100644 --- a/Master/texmf-dist/doc/latex/pgfplots/pgfplots-macros.tex +++ b/Master/texmf-dist/doc/latex/pgfplots/pgfplots-macros.tex @@ -3,8 +3,139 @@ \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, + export=false, % needs to be activated for single pictures (i.e. expensive ones) + mode=list and make, + verbose IO=false, + %xport=true,% FASTER FOR DEBUGGING + ] + {pgfplots} + \tikzifexternalizing{% + \nofiles + \pgfkeys{/pdflinks/codeexample links=false}% + }{}% +}% + +\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} {% @@ -20,13 +151,90 @@ \declare{\texttt{#2}} \texttt{#3;}}% \unskip \nobreak - \pgfmanualentryheadline{\textcolor{gray}{{\texttt{\char`\\addplot}\oarg{style options} \texttt{plot}\oarg{behavior options}}\ }% + \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 } @@ -36,7 +244,7 @@ \newenvironment{codekey}[1]{% \begin{pgfmanualentry} - \pgfmanualentryheadline{{\ttfamily\declare{#1}\textcolor{gray}{/.code}=\marg{...}}\hfill}% + \pgfmanualentryheadline{{\ttfamily\declare{#1}\textcolor{gray}{/\pgfmanualpdfref{/handlers/.code}{.code}}=\marg{...}}\hfill}% \def\mykey{#1}% \def\mypath{}% \def\myname{}% @@ -56,7 +264,7 @@ } \newenvironment{pgfplotscodetwokey}[1]{% \begin{pgfmanualentry} - \pgfmanualentryheadline{{\ttfamily\declare{/pgfplots/#1}\textcolor{gray}{/.code 2 args}=\marg{...}}\hfill}% + \pgfmanualentryheadline{{\ttfamily\declare{/pgfplots/#1}\textcolor{gray}{/\pgfmanualpdfref{/handlers/.code 2 args}{.code 2 args}}=\marg{...}}\hfill}% \def\mykey{/pgfplots/#1}% \def\mypath{}% \def\myname{}% @@ -75,7 +283,7 @@ \pgfmanualentryheadline@##1\pgfplots@EOI }% \def\pgfmanualentryheadline@##1\hfill##2\pgfplots@EOI{% - \oldpgfmanualentryheadline{{\ttfamily\declare{##1}\textcolor{gray}{/.code}=\marg{...}}\hfill}% + \oldpgfmanualentryheadline{{\ttfamily\declare{##1}\textcolor{gray}{/\pgfmanualpdfref{/handlers/.code}{.code}}=\marg{...}}\hfill}% } \begin{pgfplotsxykeylist}{#1}% } @@ -97,6 +305,8 @@ \newif\iffirstchoice \newcommand\mchoice[1]{% \begingroup + \let\margold=\marg + \def\marg##1{{\normalfont\margold{##1}}}% \firstchoicetrue \foreach \mchoice@ in {#1} {% \iffirstchoice @@ -109,6 +319,9 @@ \endgroup }% + + + % \begin{xykey}{/path/\x label=value} % \end{xykey} % @@ -157,11 +370,11 @@ \ifx\insertpathifneeded@@\empty \def\mykey{#1}% \else - \insertpathifneeded@#2\@nil + \insertpathifneeded@#1\@nil \ifpgfutil@in@ - \def\mykey{#2/#1}% - \else \def\mykey{#1}% + \else + \def\mykey{#2/#1}% \fi \fi }% @@ -196,6 +409,45 @@ \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} @@ -216,6 +468,31 @@ \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\xykey@eq#1=#2\@nil{% @@ -232,6 +509,9 @@ \def\x{y}% \xdef\mykey{#1}% \expandafter\extractkey\mykey=#2\@nil% + \def\x{z}% + \xdef\mykey{#1}% + \expandafter\extractkey\mykey=#2\@nil% \fi } \def\xykey@noeq#1\@nil{% @@ -248,6 +528,9 @@ \def\x{y}% \xdef\mykey{#1}% \expandafter\extractkey\mykey\@nil% + \def\x{z}% + \xdef\mykey{#1}% + \expandafter\extractkey\mykey\@nil% \fi } @@ -271,11 +554,12 @@ } -\newenvironment{plottype}[1]{% - \begin{key}{/tikz/#1}% - \end{key} +% 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{#1}]}}}% + \pgfmanualentryheadline{\textcolor{gray}{{\ttfamily\char`\\addplot+[\declare{#2}]}}}% \pgfmanualbody } { @@ -356,14 +640,15 @@ \pgfplotsassertcmdkeyexists{#1}% \pgfplotsassertcmdkeyexists{#2}% \begin{pgfplotskey}{#1=\marg{key-value-list}} - An abbreviation for \texttt{#2/.append style=}\marg{key-value-list}. + An abbreviation for \texttt{\pgfmanualpdfref{#2}{#2}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}\marg{key-value-list}. \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{#2/.append style=}}\marg{key-value-list} (or the respective style for $y$, {\def\x{y}\texttt{#2}}). + An abbreviation for {\def\x{x}\texttt{\pgfmanualpdfref{#2}{#2}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}}\marg{key-value-list} + (or the respective style for $y$, {\def\x{y}\texttt{\pgfmanualpdfref{#2}{#2}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}}). \end{pgfplotsxykey} } \def\pgfplotsshortstylekeys #1,#2=#3\pgfeov{% @@ -373,7 +658,7 @@ \begin{pgfplotskeylist}{% #1=\marg{key-value-list}, #2=\marg{key-value-list}} - Different abbreviations for \texttt{#3/.append style=}\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{% @@ -383,10 +668,31 @@ \begin{pgfplotsxykeylist}{% #1=\marg{key-value-list}, #2=\marg{key-value-list}} - Different abbreviations for {\def\x{x}\texttt{#3/.append style=}}\marg{key-value-list} (or the respective style for $y$, {\def\x{y}\texttt{#3}}). + Different abbreviations for {\def\x{x}\texttt{\pgfmanualpdfref{#3}{#3}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}}\marg{key-value-list} + (or the respective style for $y$, {\def\x{y}\texttt{\pgfmanualpdfref{#3}{#3}/\pgfmanualpdfref{/handlers/.append style}{.append style}=}}). \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{% @@ -406,3 +712,74 @@ } \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} +} + |