diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex new file mode 100644 index 00000000000..e3094554af6 --- /dev/null +++ b/Master/texmf-dist/tex/generic/pgfplots/util/pgfplotsutil.code.tex @@ -0,0 +1,206 @@ +%-------------------------------------------- +% +% Package pgfplots +% +% Provides a user-friendly interface to create function plots (normal +% plots, semi-logplots and double-logplots). +% +% It is based on Till Tantau's PGF package. +% +% Copyright 2007/2008 by Christian Feuersänger. +% +% This program is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program. If not, see <http://www.gnu.org/licenses/>. +% +%-------------------------------------------- + +\def\pgfplots@EOI{\pgfplots@EOI}% + +\newtoks\t@pgfplots@toka +\newtoks\t@pgfplots@tokb +\newtoks\t@pgfplots@tokc +\newdimen\pgfplots@tmpa + +% use these macros for GLOBAL temporary assignments. +% you can NEVER rely on their values unless you know exactly what you are doing. +\gdef\pgfplots@glob@TMPa{}% +\gdef\pgfplots@glob@TMPb{}% +\gdef\pgfplots@glob@TMPc{}% + +% use these macros for LOCAL temporary assigments. +% you can NEVER rely on their values unless you know exactly what you are doing. +\def\pgfplots@loc@TMPa{}% +\def\pgfplots@loc@TMPb{}% +\def\pgfplots@loc@TMPc{}% + +\input pgfplotsliststructure.code.tex +\input pgfplotsliststructureext.code.tex +\input pgfplotsarray.code.tex +\input pgfplotstable.code.tex + +% Produces an \aftergroup statement for each single token in #1. +% +% ATTENTION: you *can't* use braces inside of '#1'! +\def\pgfplotsqaftergroupeach#1{% + \pgfplotsqaftergroupeach@#1\pgfplots@EOI +} +\def\pgfplotsqaftergroupeach@#1{% + \gdef\pgfplots@TMP{#1}% + \ifx\pgfplots@TMP\pgfplots@EOI + \else + \aftergroup#1% + \expandafter\pgfplotsqaftergroupeach@ + \fi +} + +\def\pgfplotsaftergroupcollectinto#1#2\pgfplots@EOI{% + \def#1{#2}% +}% + +% Assigns list contents #2 to a list macro #1. +% +% The list contents may be provided in one of two formats: +% a) in the (deprecated) list format 'first\\second\\thirst\\' +% or +% b) in the PGF foreach list format 'first,second,third'. +\def\pgfplots@assign@list#1#2{% + \def\pgfplots@TMP{#2}% + \ifx\pgfplots@TMP\pgfutil@empty + \pgfplotslistnewempty#1% + \else + \pgfplots@check@backwards@compatible@list@format #2\\\pgfplots@EOI + \ifpgfplots@is@old@list@format + \pgfplotslistnew#1{#2}% + \else + \pgfplots@foreach@to@list{#2}\to#1 + \fi + \fi +}% + +% Sets the boolean \ifpgfplots@is@old@list@format to true if and only +% if the input is a list in the format '{first\\second\\}'. +% +% This format is deprecated, but is still provided for backwards +% compatibility. +% +% Usage: +% \pgfplots@check@backwards@compatible@list@format <argument>'\\'\pgfplots@EOI +% you NEED to append '\\\pgfplots@EOI' at the end. +\def\pgfplots@check@backwards@compatible@list@format#1\\#2\pgfplots@EOI{% + \def\pgfplots@TMP{#2}% + \ifx\pgfplots@TMP\pgfutil@empty + \pgfplots@is@old@list@formatfalse + \else + \pgfplots@is@old@list@formattrue + \fi +}% + +\def\pgfplots@error#1{\PackageError{pgfplots}{#1}{}}% +\def\pgfplots@warning#1{\pgfplots@message{! Package pgfplots Warning: #1}}% +\def\pgfplots@message#1{% + \immediate\write16{#1}% +}% +\def\pgfplots@assert@tikzinternal@exists#1{% + \pgfutil@ifundefined{#1}{% + \pgfplots@error{Sorry, pgfplots relies on the existance of the tikz internal macro '#1'. + Unfortunately, this does no longer exist ... you will need to get an updated version of pgfplots to fix this problem.}% + \expandafter\let\csname #1\endcsname=\pgfutil@empty + }{}% +}% + + +% A future-version compatibility method which checks whether the +% macro '#2' exists. +% +% We assume that '#2' usually contains the value of the tikz key '#1'. +% Example: +% /tikz/variable is usually stored into '\tikz@plot@var'. +% +% However, this may change in future versions. +% +% So, we do the following: +% 1. check whether '#2' exists, if yet: ok. +% 2. if not, check whether the value is stored directly into '/tikz/#1'. +% 3. if not, check whether the value is stored directly into '/pgf/#1'. +% 4. If everything fails, provide an error message. +% +% #1: a tikz key without key prefix (/tikz/ and /pgf/ will be prepended). +% #2: a macro name WITHOUT backslash. +% #3: the default value if everything fails. +\def\pgfplots@gettikzinternal@keyval#1#2#3{% + \pgfutil@ifundefined{#2}{% + \pgfkeysifdefined{/tikz/#1}{% + \pgfkeysgetvalue{/tikz/#1}\pgfplots@TMP + \expandafter\let\csname #1\endcsname=\pgfplots@TMP + }{% + \pgfkeysifdefined{/pgf/#1}{% + \pgfkeysgetvalue{/pgf/#1}\pgfplots@TMP + \expandafter\let\csname #1\endcsname=\pgfplots@TMP + }{% + \expandafter\def\csname #1\endcsname{#3}% + {\t@pgfplots@tokc={#3}% + \pgfplots@warning{Sorry, could not find value of '/tikz/#1'. Assuming '\the\t@pgfplots@tokc'.}% + }% + }% + }% + }{}% +}% + +\def\pgfplots@getcurrent@plothandler#1{% + \pgfutil@ifundefined{tikz@plot@handler}{% + \pgfplots@error{Sorry, can't get the current plot handler. It appears that tikz and pgfplots is no longer compatible!? You will need to get a newer version of pgfplots.}% + \let#1=\pgfplothandlerlineto + }{% + \let#1=\tikz@plot@handler + }% +}% + + +% Converts an arbitrary command to a string in which all characters +% have category 12. +% +% #1: a macro name (which takes no arguments) +% #2: a macro name which will be assigned to '#1' converted to string. +% +% This uses '\meaning#1' hackery. +\def\pgfplots@command@to@string#1#2{% + \expandafter\pgfplots@command@to@string@@\meaning#1\pgfplots@EOI{#2}% +}% +{ +\let\CATCODE=\catcode +\CATCODE`\:=12 +\CATCODE`\-=12 +\CATCODE`\>=12 +\CATCODE`\m=12 +\CATCODE`\a=12 +\CATCODE`\c=12 +\CATCODE`\r=12 +\CATCODE`\o=12 +\xdef\pgfplts@glb@TMP{macro:->}% +} +\expandafter\def\expandafter\pgfplots@command@to@string@@\pgfplts@glb@TMP#1\pgfplots@EOI#2{% + \def#2{#1}% +}% + +% Usage: +% \pgfplots@if{pgfplots@scaled@ticks}{true-code}{false-code} +% +% it is to be used if the tex boolean is only known as string, not as +% macro. +\def\pgfplots@if#1#2#3{% + \csname if#1\endcsname + #2% + \else + #3% + \fi +}% |