diff options
author | Karl Berry <karl@freefriends.org> | 2016-11-07 22:15:00 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-11-07 22:15:00 +0000 |
commit | 04c0ffa1bcffa7a3b017387a190029feaf04a340 (patch) | |
tree | 0d9afaf6de0a0d0bfbe6f85892a1011d55ce6385 /Master/texmf-dist/tex/latex | |
parent | 293604ad265c7c828f4f9183844ed5e6647c2b84 (diff) |
tikz-dependency (7nov16)
git-svn-id: svn://tug.org/texlive/trunk@42454 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
4 files changed, 1596 insertions, 6 deletions
diff --git a/Master/texmf-dist/tex/latex/tikz-dependency/pgfmanual.code.tex b/Master/texmf-dist/tex/latex/tikz-dependency/pgfmanual.code.tex new file mode 100644 index 00000000000..0160878cb99 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-dependency/pgfmanual.code.tex @@ -0,0 +1,65 @@ +% Copyright 2009 by Till Tantau and Christian Feuersänger +% +% 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. + +\input pgfmanual.prettyprinter.code.tex +\input pgfmanual.pdflinks.code.tex + +% TODO for auto xrefs: +% 1. check the already identified labels, preferrably using +% /pdflinks/show labels=true +% and the image externalization debug mode (see pgfmanual-en-main.tex) +% (to strip almost all images away) +% +% 2. Insert '\declareandlabel' in the document whenever something has been +% defined in the text, so it should get a pdf anchor (see +% pgfmanual.pdflinks.code.tex ) +% +% 2.1 perhaps insert \pgfmanualpdflabel{<label>}{} where needed. +% +% 3. Verify that the |...| commands occuring in situations where catcodes can't +% be changed (footnotes or macro arguments) work as expected. +% +% 4. Consider telling the pretty printer that several control sequences +% have arguments which are options (see below for the predefined list). +% This may apply to \pgfpageslogicalpageoptions or so. +% +% 5. @Christian: consider extensions of the parser such that it identifies path commands (at least partially) +% +% + +\def\pgfmanual@warning#1{\immediate\write16{! Package pgfmanual Warning: #1}}% + + +\pgfkeys{ + % set this to 'false' to disable auto reference generation. + % However, a little bit runtime overhead will still remain + % (and the \pgfmanualpdflabel commands will still be used) + /pdflinks/codeexample links=true, + % + /codeexample/prettyprint/cs arguments/tikzset/.initial=1, + /codeexample/prettyprint/cs/tikzset/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/usetikzlibrary/.initial=1, + /codeexample/prettyprint/cs/usetikzlibrary/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualpdfref{#2}{#2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/usepgflibrary/.initial=1, + /codeexample/prettyprint/cs/usepgflibrary/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualpdfref{#2}{#2}\pgfmanualclosebrace}, + % + % + % + % whenever an unqualified key is found, the following key prefix + % list is tried to find a match. + /pdflinks/search key prefixes in={/tikz/,/pgf/,/depgraph/}, + % + % the link prefix written to the pdf file: + /pdflinks/internal link prefix=pgf, + % + /pdflinks/warnings=false, + % for debugging: + /pdflinks/show labels=false, +}% + diff --git a/Master/texmf-dist/tex/latex/tikz-dependency/pgfmanual.pdflinks.code.tex b/Master/texmf-dist/tex/latex/tikz-dependency/pgfmanual.pdflinks.code.tex new file mode 100644 index 00000000000..e507d30e85c --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-dependency/pgfmanual.pdflinks.code.tex @@ -0,0 +1,414 @@ +%-------------------------------------------- +% +% 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/2009 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/>. +% +%-------------------------------------------- + +% This file provides an interface to the +% pgfmanual.prettyprint.code.tex thing -- it allows to +% *generate pdf crossrefs inside of codeexamples automatically* +% without any user input. +% +% Thus, you write +% \begin{codeexample}[] +% \begin{tikzpicture}[options] +% \end{tikzpicture} +% \end{codeexample} +% and pdf cross references to the definitions of 'tikzpicture' +% and any options will be generated automatically. +% +% Furthermore, pdf cross references will be generated for everything +% within vertical bars, |....|. +% +% +% +% +% +% The only necessary thing is that \pgfmanualpdflabel has been called +% for every (fully qualified) key, control sequence, environment or +% whatever. + +\newif\ifpgfmanualpdfwarnings +\pgfmanualpdfwarningstrue + +\newif\ifpgfmanualshowlabels + +\pgfkeys{% + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\pgfmanualpdfref{#1}{#1}\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, + % + /codeexample/prettyprint/autolinks/.style={% + /codeexample/prettyprint/key name/.code={\pgfmanualpdfref{##1}{##1}}, + /codeexample/prettyprint/key name with handler/.code 2 args={\pgfmanualpdfref{##1}{##1}/\pgfmanualpdfref{/handlers/##2}{##2}}, + /codeexample/prettyprint/key value display only/.code={\pgfmanualprettyprintcode{##1}}, + /codeexample/prettyprint/cs/.code={\pgfmanualpdfref{##1}{##1}}, + /codeexample/prettyprint/cs with args/.code 2 args={\pgfmanualpdfref{##1}{##1}\{\pgfmanualprettyprintcode{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\pgfmanualpdfref{##1}{##1}\{\pgfmanualprettyprintpgfkeys{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/begin/.initial=1, + /codeexample/prettyprint/cs/begin/.code 2 args={##1\{\pgfmanualpdfref{##2}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/end/.initial=1, + /codeexample/prettyprint/cs/end/.code 2 args={##1\{\pgfmanualpdfref{##2}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/word/.code={\begingroup\pgfkeyssetvalue{/pdflinks/search key prefixes in}{}\pgfmanualpdfref{##1}{##1}\endgroup}, + /codeexample/prettyprint/point/.code={##1},% + /codeexample/prettyprint/point with cs/.code 2 args={(\pgfmanualpdfref{##1}{##1}:##2},% + },% + /codeexample/prettyprint/autolinks, +}% + +\pgfkeys{ + % + % Enables or disables the parsing of codeexamples. + /pdflinks/codeexample links/.is if=pgfmanualprettyenabled, + /pdflinks/codeexample links/.default=true, + % + % whenever an unqualified key is found, the following key prefix + % list is tried to find a match. + /pdflinks/search key prefixes in/.initial={/tikz/,/pgf/}, + % + % Enables or disables warnings for failed auto links: + /pdflinks/warnings/.is if=pgfmanualpdfwarnings, + /pdflinks/warnings/.default=true, + % + % Shows the autogenerated labels. This is useful to check if the + % 'search key prefixes in' worked as it ought to. + /pdflinks/show labels/.is if=pgfmanualshowlabels, + /pdflinks/show labels/.default=true, + /pdflinks/show labels=false, + % will be invoked with '#1' set to the generated label. + /pdflinks/show labels code/.code={ + \hbox to 0pt{% + \vbox to 0pt{\hsize=0pt + \vskip-\baselineskip + \hbox to \hsize{% + \hss + {\footnotesize\ttfamily\textcolor{red}{#1}}% + \hss + }% + \vss + }% + \vbox to 0pt{\hsize=0pt + \vss + \hbox to \hsize{% + \hss + {\footnotesize\ttfamily\textcolor{red}{$\vert$}}% + \hss + }% + }% + \vsize=0pt + }% + }, + % + % the link prefix written to the pdf file: + /pdflinks/internal link prefix/.initial=pgf, +} + +\gdef\pgfmanualpdf@installreplacements{% + \def\marg##1{{##1}}% + \def\oarg##1{[##1]}% + \def\meta##1{<##1>}% + \def\x{x}% + \def\textbackslash{<CS>}% + \def\\{\textbackslash}% + \def\space{:}% + \edef\ {\space}% + \edef\#{}% + \def\printanat{@}% + \def\protect{}% + \def\textasciicircum{o}% + \expandafter\edef\pgfmanual@verb@activebar{\pgfmanual@verb@bar}% +}% + +% Defines a new pdf cross ref label for use with \pgfmanualpdfref. +% +% Usage: +% \pgfmanualpdflabel{<label>}{<text>} +% #1: the label. +% The text #2 will be shown in the resulting pdf (if it is not empty). +% +% There is also support for catcode changes if <label> contains +% something which shouldn't be written as-is into .aux files: +% \pgfmanualpdflabel[\catcode`\|=12 ]{|-}{} +% -> this will write +% \begingroup \catcode `\|=12 +% <code to deal with the label |- > +% \endgroup +% into the .aux file. +% +\def\pgfmanualpdflabel{\pgfutil@ifnextchar[{\pgfmanualpdflabel@opt}{\pgfmanualpdflabel@opt[]}}% +\def\pgfmanualpdflabel@opt[#1]#2#3{% + \begingroup + % + \def\pgfmanualpdf@catcode{#1}% + \pgfmanualpdf@catcode + % + \pgfmanualpdflabel@generate{#2}{#3}% + % + % this is pgfplots-specific: pgfplots supports generic styles which + % contain '\x' where '\x' iterates through 'x,y,z'. + \pgfutil@in@\x{#2}% + \ifpgfutil@in@ + \def\x{y}% + \pgfmanualpdflabel@generate{#2}{#3}% + \def\x{z}% + \pgfmanualpdflabel@generate{#2}{#3}% + \fi + \endgroup +}% +\def\pgfmanualpdflabel@generate#1#2{% + \pgfmanual@handlespeciallabeltokens@in{#1}% + % + \def\pgfmanualpdflabel@generateone{0}% + \pgfutil@ifundefined{pgfd@lbl@\pgfmanualpdflabel@@}{% + % ok, no such label is known. + \def\pgfmanualpdflabel@generateone{1}% + }{% + \if\csname pgfd@lbl@\pgfmanualpdflabel@@\endcsname a% "a"ux + % ah, it is "just" known from a previous run, but there is + % no code in the pdf! Write it! + \def\pgfmanualpdflabel@generateone{1}% + \else + % ok, we already wrote one before. Skip. + \fi + }% + \if\pgfmanualpdflabel@generateone1% + \ifpgfmanualshowlabels + \pgfkeysvalueof{/pdflinks/show labels code/.@cmd}{\pgfmanualpdflabel@@}\pgfeov + \fi + % + \if@filesw + \ifx\pgfmanualpdf@catcode\pgfutil@empty + \else + \toks0=\expandafter{\pgfmanualpdf@catcode}% + \immediate\write\@auxout{% + \noexpand\begingroup + \the\toks0 + }% + \fi + \immediate\write\@auxout{% + \noexpand\expandafter\noexpand\gdef + \noexpand\csname pgfd@lbl@\pgfmanualpdflabel@@\noexpand\endcsname{a}% a = known in "a"ux file + }% + \ifx\pgfmanualpdf@catcode\pgfutil@empty + \else + \immediate\write\@auxout{\noexpand\endgroup}% + \fi + \fi + \expandafter\gdef\csname pgfd@lbl@\pgfmanualpdflabel@@\endcsname{w}% 1. remember the label AND remember that we "w"rote it into the pdf. + \edef\pgfmanualpdflabel@@{\pgfkeysvalueof{/pdflinks/internal link prefix}.\pgfmanualpdflabel@@}% + \expandafter\hypertarget\expandafter{\pgfmanualpdflabel@@}{#2}% + \else + #2% + \fi +}% + +% A pdf reference to label `#1' with (TeX) text `#2'. +% @see also \verbpdfref. +\def\pgfmanualpdfref#1#2{% + \begingroup + \pgfmanual@handlespeciallabeltokens@in{#1}% + % + \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname + \else + \global\let\pgfmanual@glob=\pgfmanualpdflabel@@ + \def\pgfmanual@tempa{\foreach \prefix in }% + \pgfkeysgetvalue{/pdflinks/search key prefixes in}\pgfmanual@tempb + \expandafter\pgfmanual@tempa\expandafter{\pgfmanual@tempb}{% + \edef\pgfmanualpdflabel@@{\prefix\pgfmanualpdflabel@@}% + \expandafter\pgfmanual@handlespeciallabeltokens@in\expandafter{\pgfmanualpdflabel@@}% + \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname + \xdef\pgfmanual@glob{\pgfmanualpdflabel@@}% + \breakforeach + \fi + }% + \let\pgfmanualpdflabel@@=\pgfmanual@glob + \ifcsname pgfd@lbl@\pgfmanualpdflabel@@\endcsname + \else + \ifpgfmanualpdfwarnings + \begingroup + \toks0={#1}% + \pgfmanual@warning{pgfmanualpdfref{\the\toks0 }: target label does not exist.}% + \endgroup + \fi + #2% + \let\pgfmanualpdflabel@@=\pgfutil@empty + \fi + \fi + \ifx\pgfmanualpdflabel@@\pgfutil@empty + \else + \expandafter\pgfmanualpdfref@\expandafter{\pgfmanualpdflabel@@}{#2}% + \fi + \endgroup +}% +\def\pgfmanualpdfref@#1#2{% + \pgfkeysgetvalue{/pdflinks/internal link prefix}\pgfmanual@temp + \expandafter\hyperlink\expandafter{\pgfmanual@temp.#1}{#2}% + \ifpgfmanualshowlabels + \pgfkeysvalueof{/pdflinks/show labels code/.@cmd}{#1}\pgfeov + \fi +}% + +% Handles special tokens in a pdf label which should be treated with +% care. +% +% For example, backslashes might produce problems. +% This occurs quite frequently with automatically generated hyperrefs +% inside of codeexamples where \pgfmanualpdfref will be invoked - +% there, we get the catcode 12 backslashes. +% Check for them! +% +% #1: a token list which shall be used either as cross ref or as +% label. +% +% On output, the macro \pgfmanualpdflabel@@ will be '\edef'ed to the +% new, possibly modified value. +\def\pgfmanual@handlespeciallabeltokens@in#1{% + \begingroup + \pgfmanualpdf@installreplacements + \expandafter\pgfutil@in@\pgfmanual@pretty@backslash{#1}% + \ifpgfutil@in@ + % assume the backslash is the first char and substitute it: + \pgfmanualpdfref@substitute@backslash#1\relax + \else + \edef\pgfmanualpdflabel@@{#1}% + \fi + \def\pgfmanual@tmp{\pgfutilstrreplace{ }{\space}}% + \expandafter\pgfmanual@tmp\expandafter{\pgfmanualpdflabel@@}% + \edef\pgfmanualpdflabel@@{\pgfretval}% + \pgfmath@smuggleone\pgfmanualpdflabel@@ + \endgroup +}% + +\expandafter\def\expandafter\pgfmanualpdfref@substitute@backslash\expandafter#\expandafter1\pgfmanual@pretty@backslash#2\relax{% + \edef\pgfmanualpdflabel@@{#1\textbackslash #2}% +}% + +% Typesets '#1' in red,\texttt like every declaration. It will also +% generate a pdf cross ref anchor for #1. +% +% WARNING: this changes catcodes! In case this is not acceptable in +% your context, you will need to generate a \pgfmanualpdflabel +% manually. +% +% \declareandlabel{\controlsequence} can be used as |\controlsequence| +\def\declareandlabel{% + \begingroup + \pgfmanual@verb@preparecatcodes@ + \def\pgfmanualprettyprinterhandlecollectedargs##1{% + \pgfmanualpdflabel##1{\texttt{\declare##1}}% mark: '##1' contains already braces. + \endgroup + }% + \pgfmanualprettyprintercollectargcount1{\relax}% +} + +% +% \verbpdfref{\controlsequence more stuff} +% is the same as writing |\controlsequence more stuff|, but the +% *complete* argument is supposed to be one label. +% +% The difference to \pgfmanualpdfref{...}{} is that the argument is +% supposed to be verbatim text. +\def\verbpdfref{% + \begingroup + \pgfmanual@verb@preparecatcodes@ + \def\pgfmanualprettyprinterhandlecollectedargs##1{% + \pgfmanualpdfref##1{\texttt{##1}}% mark: '##1' contains already braces. + \endgroup + }% + \pgfmanualprettyprintercollectargcount1{\relax}% +} + +% Prepare active vertical bars, |....| for auto-pretty cross +% referencing. +% +% Example: +% |\pgfkeys| -> will generate a hyperref! +{ + \catcode`\|=12 + \gdef\pgfmanual@verb@bar{|}% +% \gdef\pgfmanual@verb@collect#1|{% +% % this command will also handle control sequences. +% \texttt{\pgfmanualprettyprintpgfkeys{#1}}% +% \endgroup +% }% + \catcode`\|=13 + \gdef\pgfmanual@verb@activebar{|}% +} +\def\pgfmanual@verb{% + \begingroup + \pgfmanual@verb@preparecatcodes@ + \toksdef\t@pgfmanual@verb=0 + \t@pgfmanual@verb={}% + \pgfmanual@verb@collect +} +% this version of \pgfmanual@verb@collect is less efficient than the +% one uncommented above. BUT: it can auto-detect the case when +% |...| has been provided somewhere where I can't change catcodes! +% The other one would simply fail to compile. +\def\pgfmanual@verb@collect#1{% + \def\pgfmanual@temp{#1}% + \ifx\pgfmanual@temp\pgfmanual@verb@bar + % ok, finish: + \edef\pgfmanual@verb@collect@next{% + % this command will also handle control sequences. + \noexpand\endgroup + \noexpand\texttt{\noexpand\pgfmanualprettyprintpgfkeys{\the\t@pgfmanual@verb}}% + }% + \else + \ifx\pgfmanual@temp\pgfmanual@verb@activebar + % ohoh... that should not happen! It means someone invoked + % |...| within an argument; I couln't change catcodes. + % Ok, resort to a simple fallback solution. + % FIXME : I have just realized that THIS DOESN'T PRESERVE SPACES + \edef\pgfmanual@verb@collect@next{% + \noexpand\endgroup + \noexpand\texttt{\the\t@pgfmanual@verb}% + }% + \else + \t@pgfmanual@verb=\expandafter{\the\t@pgfmanual@verb #1}% + \let\pgfmanual@verb@collect@next=\pgfmanual@verb@collect + \fi + \fi + \pgfmanual@verb@collect@next +}% + +\AtBeginDocument{% + \ifpgfmanualprettyenabled + \catcode`\|=13 + \expandafter\let\pgfmanual@verb@activebar=\pgfmanual@verb + \fi +}% + +\def\pgfmanual@verb@preparecatcodes@{% + \let\do\@makeother% + \dospecials% + \catcode`\%=12 % THATS IMPORTANT! Do *not* handle comments! + % these catcodes are expected by the pretty printer... + %\catcode`\^^M=13 + \catcode`\ =13 + \catcode`\^^I=13 + \expandafter\def\pgfmanual@pretty@activespace{\space}% + \expandafter\def\pgfmanual@pretty@activetab{\space\space\space\space}% +}% +\endinput +% vi: ts=4 sw=4 diff --git a/Master/texmf-dist/tex/latex/tikz-dependency/pgfmanual.prettyprinter.code.tex b/Master/texmf-dist/tex/latex/tikz-dependency/pgfmanual.prettyprinter.code.tex new file mode 100644 index 00000000000..85482fedaaf --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-dependency/pgfmanual.prettyprinter.code.tex @@ -0,0 +1,1095 @@ +%-------------------------------------------- +% +% 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/2009 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/>. +% +%-------------------------------------------- + +% this is some kind of "plug-in" for pgfmanual-en-macros.tex which +% provides pretty printing of the code lines in 'codeexample'. +% +% It requires to be invoked with \pgfmanualprettyprintcode{#1} at the +% right place. +% +% ATTENTION: +% this is NOT a sophisticated syntax highlighter like lstlistings! +% It has rather strict assumptions about how to use it (the input must +% have been read verbatim, for example). + +% Special code for syntax highlighting: +% +% +% USER INTERFACE +\pgfkeys{% + % this is the public hook into + % \begin{codeexample}...\end{codeexample} which triggers pretty + % printing: + /codeexample/typeset listing/.code= {\pgfmanualprettyprintcode{#1}}, + % + % this key will be invoked whenever a key in key-value context has been identified. + % + % It won't be invoked for handled keys like |my style/.style=....|, see below. + % + % #1 will be the keys name. + /codeexample/prettyprint/key name/.code={#1}, + % + % A variant which will be used instead of |key name| if the key + % has a key handler. For example, when the pretty printer finds + % |my style/.style|, it will call + % |key name with handler={my style}{.style}. + /codeexample/prettyprint/key name with handler/.code 2 args={#1/#2}, + % + % Will be invoked whenever the value of a key has been found. + % It will be invoked AFTER 'key name' and not at all if there was + % no value. + % + % #1: the key's name + % #2: the key's value. + % + % The default implementation checks if there is a special handler + % for the key name '#1', in + % /codeexample/prettyprint/key value/#1. + % For example: + % /codeexample/prettyprint/key value/my key/.code 2 args={name=#1, value =#2} + % If such a key exists, it will be invoked with {#1}{#2} as + % arguments. Otherwise, the generic method + % /codeexample/prettyprint/key value with style detection={#1}{#2} + % will be invoked. + /codeexample/prettyprint/key value/.code 2 args={% + \pgfkeysifdefined{/codeexample/prettyprint/key value/#1}{% + \pgfkeysalso{/codeexample/prettyprint/key value/#1={#1}{#2}}% + }{% + \pgfkeysalso{/codeexample/prettyprint/key value with style detection={#1}{#2}}% + }% + }, + % A helper macro for the default 'key value' implementation. + /codeexample/prettyprint/key value with style detection/.code 2 args={% + \pgfutil@in@{style}{#1}% + \ifpgfutil@in@ + \pgfmanualprettyprintpgfkeys{#2}% + \else + \pgfkeysalso{/codeexample/prettyprint/key value display only={#2}}% + \fi + },% + % + % Will be invoked by the default 'key value' implementation to + % typeset the value as such. + /codeexample/prettyprint/key value display only/.code={#1}, + % + % Used to typeset a single word. A word is something which has not + % been identified in any other context; a maximal sequence of + % non-white-space tokens. + /codeexample/prettyprint/word/.code={#1}, + % + % A two-argument code key which invokes '#1' if spaces shall + % delimit words and '#2' if not. + % This may be useless. Handle with care! + /codeexample/prettyprint/if space is word delim/.code 2 args={% + #1% + },% + % + % A three-argument code key which should invoke '#2' if the single + % token '#1' is a word delimiter and '#3' if that is not the case. + % Note that '#1' doesn't have the usual catcodes (see the + % \pgfmanual@pretty@** macros)! + % Furthermore, white spaces are treated separately. + /codeexample/prettyprint/if is word delim/.code args={#1#2#3}{% + \edef\pgfmanual@check{,;().;\pgfmanual@pretty@lbrace\pgfmanual@pretty@rbrace}% + \def\pgfmanual@check@{\pgfutil@in@{#1}}% + \expandafter\pgfmanual@check@\expandafter{\pgfmanual@check}% + \ifpgfutil@in@ #2\else #3\fi + },% + % + % Used to typeset a single control sequence. + % #1 is the control sequence's name as a sequence of catcode 12 + % tokens. + /codeexample/prettyprint/cs/.code={#1}, + % + % Used to typeset a single control sequence together with one or + % more arguments. + % + % #1 is the control sequence's name (including the backslash as + % literal string) and + % #2,#3,...,#9 are the arguments. The number of arguments depends + % on the 'cs arguments/<CS NAME>' key; it contains the integer + % number. + % + % For example, if + % |cs arguments/pgfkeys/.initial=1|, + % the pretty printer invokes + % |cs with args={\pgfkeys}{<argument>}. + % + % If + % |cs arguments/mycommand/.initial=2|, + % the pretty printer invokes + % |cs with args={\pgfkeys}{<argument1>}{<argument2>}. + % In this case, 'cs with args' needs to be defined in a way which + % allows to deal with 3 arguments. + % + % Please note that the value do not contain braces! The braces + % need to be inserted manually. + % + % Special cases: + % 1. If end-of-input is encountered BEFORE the expected number of + % arguments has been found, the following happens: + % - if not even one (partial) argument has been found, the + % /codeexample/prettyprint/cs/.@cmd key will be used instead. + % - the \ifpgfmanualprettyprinterarghasunmatchedbraces boolean + % indicates if the trailing brace is missing. + /codeexample/prettyprint/cs with args/.code 2 args={#1\{#2\pgfmanualclosebrace}, + % + % For every identified control sequence, the key + % /codeexample/prettyprint/cs arguments/<CSNAME> + % will be checked. If it exists, it contains an integer with the + % number of arguments it takes. + % The <CSNAME> must not contain the '\'. + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + % + % For every identified control sequence, the key + % /codeexample/prettyprint/cs/<CSNAME>/.@cmd + % will be checked. If it exists, it will be used instead of + % 'cs with args' (with the same special case restrictions for + % early end-of-input). + % + % The <CSNAME> must not contain the '\'. + % + % This allows special treatment for special + % commands like \pgfkeys: + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={#1\{\pgfmanualprettyprintpgfkeys{#2}\pgfmanualclosebrace}, + % + % recognise environments: + /codeexample/prettyprint/cs arguments/begin/.initial=1, + /codeexample/prettyprint/cs/begin/.code 2 args={#1\{#2\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/end/.initial=1, + /codeexample/prettyprint/cs/end/.code 2 args={#1\{#2\pgfmanualclosebrace}, + % + % a point coordinate (#1) + % Note that '#1' will contain the braces (if there was one), + /codeexample/prettyprint/point/.code={#1},% + % + % a point coordinate with explicit coordinate system: (#1:#2) + % Note that '#2' will contain the terminating brace (if there was one) + % #1: the coordinate system name (*without* the leading brace). + % The leading brace must be re-inserted by this style. + /codeexample/prettyprint/point with cs/.code 2 args={(#1:#2},% + % the same with specialised code: + %/codeexample/prettyprint/point with cs/<CS NAME>/.code 2 args={(#1:#2},% + % + % + % A predefined style which colors every identified token. It's + % purpose is only debugging. + /codeexample/prettyprint/colored/.style={% + /codeexample/prettyprint/key name/.code={\textcolor{red!75!black}{##1}}, + /codeexample/prettyprint/key name with handler/.code 2 args={\textcolor{red!75!black}{##1}/\textcolor{red!90!black}{##2}}, + /codeexample/prettyprint/key value display only/.code={\textcolor{yellow}{##1}}, + /codeexample/prettyprint/cs/.code={\textcolor{green}{##1}}, + /codeexample/prettyprint/cs with args/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/pgfkeys/.initial=1, + /codeexample/prettyprint/cs/pgfkeys/.code 2 args={\textcolor{green}{##1}\{\pgfmanualprettyprintpgfkeys{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/begin/.initial=1, + /codeexample/prettyprint/cs/begin/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/cs arguments/end/.initial=1, + /codeexample/prettyprint/cs/end/.code 2 args={\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/word/.code={\textcolor{brown}{##1}}, + /codeexample/prettyprint/point/.code={\textcolor{red}{##1}},% + /codeexample/prettyprint/point with cs/.code 2 args={(\textcolor{green}{##1}:\textcolor{red}{##2}},% + },% + % A further debuggin helper. + /codeexample/prettyprint/colored and verbose/.style={% + /codeexample/prettyprint/colored, + /codeexample/prettyprint/key name/.code={\message{[key name=##1]}\textcolor{red!75!black}{##1}}, + /codeexample/prettyprint/key name with handler/.code 2 args={\message{[key name with handler=##1/##2]}\textcolor{red!75!black}{##1}/\textcolor{red!90!black}{##2}}, + /codeexample/prettyprint/key value display only/.code={\def\temp{##1}\message{[key value=\meaning\temp]}\textcolor{yellow}{##1}}, + /codeexample/prettyprint/cs/.code={\message{[cs=##1]}\textcolor{green}{##1}}, + /codeexample/prettyprint/cs with args/.code 2 args={\def\temp{##2}\message{[cs with args={##1}{\meaning\temp}]}\textcolor{green}{##1}\{\textcolor{orange}{##2}\pgfmanualclosebrace}, + /codeexample/prettyprint/word/.code={\message{[word=##1]}\textcolor{brown}{##1}}, + /codeexample/prettyprint/point/.code={\message{[point=##1]}\textcolor{red}{##1}},% + /codeexample/prettyprint/point with cs/.code 2 args={\message{[point with cs={##1}{##2}]}(\textcolor{green}{##1}:\textcolor{red}{##2}},% + },% + %/codeexample/prettyprint/colored, + %/codeexample/prettyprint/colored and verbose, +}% + +\newif\ifpgfmanualprettyenabled +\pgfmanualprettyenabledtrue + +% User interface command to handle unmatched braces: +% +% It expands to '\}' unless the preceding argument had unmatched braces. +\def\pgfmanualclosebrace{% + \ifpgfmanualprettyprinterarghasunmatchedbraces + \else + \}% + \fi +}% + + +% Typesets '#1', possibly using some sort of pretty printer. +% +% The argument '#1' is expected to be a long token list in which +% 1. all characters have catcode 11 or 12 (normal letters), +% 2. white spaces, tabs and newlines have catcode 13 (are active). +% +% @see \pgfmanualprettyprintpgfkeys +\long\def\pgfmanualprettyprintcode#1{% +%\def\temp{#1}\message{STARTING PRETTY PRINTING for \meaning\temp}% + \ifpgfmanualprettyenabled + \begingroup + \pgfmanualprettyprintstyles + \pgfmanual@pretty@mainloop#1\pgfmanual@EOI + \endgroup + \else + #1% + \fi +}% +% DISABLE: +%\long\def\pgfmanualprettyprintcode#1{#1}% + +\def\pgfmanualprettyprintstyles{% +%\tracingmacros=2 \tracingcommands=2 \message{PRETTYPRINT INIT}% + \def\{{\pgfmanual@pretty@lbrace}% + \def\}{\pgfmanual@pretty@rbrace}% + \pgfmanual@pretty@installcommenthandler + \let\pgfmanualprettyprintstyles=\relax +}% + + +\newif\ifpgfmanualprettycommentactive + +% we can't use the \@typeset@till@return method for comments because +% the pretty printer needs full control over the token list. +% +% We try a replacement here. +% +% FIXME +% THIS INTRODUCES A NEW GROUP! Does that hurt the pretty printer?? +% +\def\pgfmanual@pretty@installcommenthandler{% + \expandafter\def\pgfmanual@pretty@activepercent{% + \begingroup + \pgfmanualprettycommentactivetrue + \expandafter\let\pgfmanual@pretty@activenl=\pgfmanual@pretty@recoveraftercomment + \expandafter\def\pgfmanual@pretty@activepercent{\%}% + %\tt + \% % + }% +}% +\def\pgfmanual@pretty@recoveraftercomment{% + \endgroup + \pgfmanual@pretty@activenl +}% + +\def\pgfmanual@EOI{\pgfmanual@EOI}% + +{ + \catcode`\[=0 + \catcode`\\=12 + [gdef[pgfmanual@pretty@backslash{\}% +} +\begingroup + \catcode`\:=12 + \catcode`\(=12 + \catcode`\)=12 + \gdef\pgfmanual@pretty@colon{:}% + \gdef\pgfmanual@pretty@lroundbrace{(}% + \gdef\pgfmanual@pretty@rroundbrace{)}% + \catcode`\[=1 + \catcode`\]=2 + \catcode`\{=12 + \catcode`\}=12 + \gdef\pgfmanual@pretty@lbrace[{]% + \gdef\pgfmanual@pretty@rbrace[}]% + \catcode`\{=1 + \catcode`\}=2 + \catcode`\[=12 + \catcode`\]=12 + \catcode`\,=12 + \catcode`\ =10\relax\gdef\pgfmanual@pretty@space{ }% + \gdef\pgfmanual@pretty@lbracket{[}% + \gdef\pgfmanual@pretty@rbracket{]}% + \gdef\pgfmanual@pretty@comma{,}% + \catcode`\==12 + \gdef\pgfmanual@pretty@eq{=}% +\endgroup +\begingroup + \catcode`\%=12 + \gdef\pgfmanual@pretty@percent{%} + \catcode`\%=13 + \gdef\pgfmanual@pretty@activepercent{%} + \catcode`\^^M=13 + \gdef\pgfmanual@pretty@activenl{^^M}\endgroup +\begingroup +\catcode`\^^I=13\relax\gdef\pgfmanual@pretty@activetab{^^I}% +\catcode`\ =13\relax\gdef\pgfmanual@pretty@activespace{ }\endgroup + +% loops through all tokens. +% #1 is a single token. +\def\pgfmanual@pretty@mainloop{% + \def\pgfmanual@pretty@mainloop@currentword{}% + \pgfmanual@pretty@mainloop@ +}% +\long\def\pgfmanual@pretty@mainloop@#1{% + \def\pgfmanual@loc@TMPa{#1}% + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@mainloop@ + \ifx\pgfmanual@loc@TMPa\pgfmanual@EOI + % stop iteration. + \pgfmanual@pretty@mainloop@finishword + \let\pgfmanual@pretty@mainloop@NEXT=\relax + \else + \ifpgfmanualprettycommentactive + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lbracket% + % we found the start of OPTIONS '[ ... ]'. + \pgfmanual@pretty@mainloop@finishword + % Attempt syntax highlighting for pgfkeys: + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@pgfkeys + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@backslash + % we found the start of a control sequence '\command' + \pgfmanual@pretty@mainloop@finishword + % + % collect the control sequence name into + % \pgfmanual@loc@TMPa, but without the backslash: + \let\pgfmanual@loc@TMPa=\pgfutil@empty + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@collectcs@loop + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lroundbrace% + \pgfmanual@pretty@mainloop@finishword + \let\pgfmanual@pretty@mainloop@NEXT=\pgfmanual@pretty@collectpoint + \else + \def\pgfmanual@isspace{0}% + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) or comment + \def\pgfmanual@isspace{1}% + \else + \ifnum10=\catcode`#1 + \def\pgfmanual@isspace{1}% + \fi + \fi + \if\pgfmanual@isspace1% + \pgfkeysvalueof{/codeexample/prettyprint/if space is word delim/.@cmd}{% + \pgfmanual@pretty@mainloop@finishword + #1% ok, show it. + }{% + % collect the word. + \expandafter\def\expandafter\pgfmanual@pretty@mainloop@currentword\expandafter{\pgfmanual@pretty@mainloop@currentword #1}% + }% + \else + \pgfkeysvalueof{/codeexample/prettyprint/if is word delim/.@cmd}{#1}{% + \pgfmanual@pretty@mainloop@finishword + #1% ok, show the delimiter. + }{% + % collect the word. + \expandafter\def\expandafter\pgfmanual@pretty@mainloop@currentword\expandafter{\pgfmanual@pretty@mainloop@currentword #1}% + }\pgfeov% + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@mainloop@NEXT +}% + +\def\pgfmanual@pretty@mainloop@finishword{% + \ifx\pgfmanual@pretty@mainloop@currentword\pgfutil@empty + \else + \def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/word/.@cmd}}% + \expandafter\pgfmanual@loc@TMPa\pgfmanual@pretty@mainloop@currentword\pgfeov + \let\pgfmanual@pretty@mainloop@currentword=\pgfutil@empty + \fi +}% + +\def\pgfmanual@pretty@collectpoint{% + \let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@collectargs@finish@collectpoint + \expandafter\pgfmanualprettyprintercollectupto\pgfmanual@pretty@rroundbrace + {\afterpgfmanual@pretty@collectpoint}% +} + +{ +\catcode`\:=12 +\gdef\pgfmanual@pretty@collectargs@finish@collectpoint#1{% + \expandafter\pgfutil@in@\pgfmanual@pretty@colon{#1}% + \ifpgfutil@in@ + \def\pgfmanual@pretty@collectpoint@getcoordsystem##1:##2\relax{% + \begingroup + \pgfmanual@pretty@restorespaces + % remove active spaces from ##1: + \xdef\pgfmanual@pretty@glob@TMPa{##1}% + \endgroup + \pgfkeysifdefined{/codeexample/prettyprint/point with cs/\pgfmanual@pretty@glob@TMPa/.@cmd}{% + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point with cs/\pgfmanual@pretty@glob@TMPa/.@cmd}}% + }{% + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point with cs/.@cmd}}% + }% + \expandafter\def\expandafter\pgfmanual@loc@TMPa\expandafter{\expandafter{\pgfmanual@pretty@glob@TMPa}{##2}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov + }% + \ifpgfmanualprettyprinterfoundterminator + \pgfmanual@pretty@collectpoint@getcoordsystem#1)\relax + \else + \pgfmanual@pretty@collectpoint@getcoordsystem#1\relax + \fi + \else + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/point/.@cmd}}% + \ifpgfmanualprettyprinterfoundterminator + \pgfmanual@loc@TMPb(#1)\pgfeov + \else + \pgfmanual@loc@TMPb(#1\pgfeov + \fi + \fi +}% +} +\def\afterpgfmanual@pretty@collectpoint{\pgfmanual@pretty@mainloop}% + +% loops through all tokens, assembling the cs name as it goes. +% #1 is a single token. +\def\pgfmanual@pretty@collectcs@loop#1{% + \let\pgfmanual@pretty@collectcs@loop@NEXT=\pgfmanual@pretty@collectcs@loop + \def\pgfmanual@loc@TMPb{#1}% + \ifx\pgfmanual@loc@TMPb\pgfmanual@EOI + \def\pgfmanual@pretty@collectcs@loop@NEXT{\pgfmanual@pretty@collectcs@loop@END #1}% + \else + % a csname may only use letters. And: only letters have a + % positive lcccode! + \ifnum\lccode`#1=0 + \ifx\pgfmanual@loc@TMPb @% + % ok, we may also accept an `@': + \edef\pgfmanual@loc@TMPa{\pgfmanual@loc@TMPa #1}% + \else + % This here is the first non-letter. + \def\pgfmanual@pretty@collectcs@loop@NEXT{\pgfmanual@pretty@collectcs@loop@END #1}% + \fi + \else + % continue iterating and assemble the csname... + \edef\pgfmanual@loc@TMPa{\pgfmanual@loc@TMPa #1}% + \fi + \fi + \pgfmanual@pretty@collectcs@loop@NEXT +}% +\def\afterpgfmanual@pretty@cs{\pgfmanual@pretty@mainloop}% + +\def\pgfmanual@pretty@collectcs@loop@END{% + \pgfkeysifdefined{/codeexample/prettyprint/cs arguments/\pgfmanual@loc@TMPa}{% + % oh. The collected control sequence expects arguments. That + % means a lot of work since there are no nestable braces in + % the token list! All of them have catcode 12... we need to do + % that manually. + \let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@collectargs@finish@cs + \def\pgfmanual@pretty@collectcs@loop@END@next{% + \pgfmanualprettyprintercollectargcount + {\pgfkeysvalueof{/codeexample/prettyprint/cs arguments/\pgfmanual@loc@TMPa}}% + {\afterpgfmanual@pretty@cs}% + }% + }{% + % re-insert the backslash: + \edef\pgfmanual@loc@TMPa{\pgfmanual@pretty@backslash \pgfmanual@loc@TMPa}% + % ok, report the macro and continue with the main loop. + \def\pgfmanual@loc@TMPb{\pgfkeysvalueof{/codeexample/prettyprint/cs/.@cmd}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov + \let\pgfmanual@pretty@collectcs@loop@END@next=\afterpgfmanual@pretty@cs + }% + \pgfmanual@pretty@collectcs@loop@END@next +}% + +\newif\ifpgfmanualprettyprinterarghasunmatchedbraces + +% Collects arguments inside of a token list, dealing with nested +% catcode-12-braces. +% +% #1: is the NUMBER of arguments to collect. +% #2: is TeX code which shall be invoked after +% \pgfmanualprettyprinterhandlecollectedargs has been invoked (see +% below). +% +% PRECONDITION: +% there is a large token list following +% \pgfmanualprettyprintercollectargcount with balanced braces. The braces +% have \catcode 12. +% POSTCONDITION: +% 1. the arguments will be collected as +% '<result> := {<first arg>}{<second arg>}', +% 2.1 the macro \pgfmanualprettyprinternumcollectedargs will contain +% the *actual* number of *completely* collected arguments, +% 2.2 the if \ifpgfmanualprettyprinterarghasunmatchedbraces will be +% set to \c true if the last found argument had an unmatched brace, +% 3. then, \pgfmanualprettyprinterhandlecollectedargs{<result>} will be +% invoked. Just define \pgfmanualprettyprinterhandlecollectedargs +% properly. +% Afterwards, #2 will be invoked to recover from the argument +% collection. +% +% +% Example: +% \pgfmanualprettyprintercollectargcount{2}{\donnextstep} +% {_12 first argument }_12 {_12 second argument }_12 next tokens% +% +% will result in the expansion +% \pgfmanualprettyprinterhandlecollectedargs{{_1 first argument }_2 {_1 second argument }_2 } +% \donnextstep +% next tokens +% +% +% +% ATTENTION: +% \pgfmanualprettyprinterhandlecollectedargs will be invoked with a SINGLE +% argument. The argument as such will contain extra braces, one pair +% of braces for each of the #1 arguments. These braces will have +% catcode 1 and 2, i.e. they can *really* be used in TeX. Thus, the +% finish routine will be invoked with +% \pgfmanualprettyprinterhandlecollectedargs{{<arg>}} +% for one argument and with +% \pgfmanualprettyprinterhandlecollectedargs{{<first arg>}{<second arg>}} +% for two and more arguments. Note the extra set of braces for one +% arg. +% It might happen that not all arguments have been found if +% end-of-input occured before. The +% \pgfmanualprettyprinterhandlecollectedargs routine has to check +% this using the macro \pgfmanualprettyprinternumcollectedargs which +% contains the actual number of collected args. +% +% @remark This macro checks for the end-of-input indicator, \pgfmanual@EOI. In case it encounters +% \pgfmanual@EOI, it +% 1. stops collecting, leaving the \pgfmanual@EOI as next token to be read, +% 2. sets \ifpgfmanualprettyprinterarghasunmatchedbraces to \iftrue if necessary, +% 3. assigns \pgfmanualprettyprinternumcollectedargs +% 4. invokes the finish routine. +% The \pgfmanual@EOI needs to be collected by following routines in +% this case. You can also use \pgfutil@ifnextchar\pgfmanual@EOI{}{} in +% following routines to check for \pgfmanual@EOI. +\def\pgfmanualprettyprintercollectargcount#1#2{% + \pgfmanualprettyprinterarghasunmatchedbracesfalse + \begingroup + \edef\pgfmanual@loc@csargcount{#1}% + \toksdef\t@afterpgfmanualprettyprinterhandlecollected=10 + \t@afterpgfmanualprettyprinterhandlecollected={#2}% + \let\c@pgfmanual@pretty@openbracecount=\c@pgf@counta + \let\c@pgfmanual@pretty@curargcount=\c@pgf@countb + % I will track open braces and the number of completely + % collected arguments here: + \c@pgfmanual@pretty@openbracecount=0 + \c@pgfmanual@pretty@curargcount=0 + % + % and I will accumulate the argument token lists as such here: + \toksdef\t@pgfmanual@currentarg=0 + \toksdef\t@pgfmanual@allargs=1 + \t@pgfmanual@currentarg={}% + \t@pgfmanual@allargs={}% + % + \pgfmanual@pretty@collectargs@loop +}% + +% loops through all tokens, collecting the required number of +% arguments. This involves to track nested braces manually. +% #1 is a single token. +\def\pgfmanual@pretty@collectargs@loop#1{% + \let\pgfmanual@pretty@collectargs@loop@NEXT=\pgfmanual@pretty@collectargs@loop + \def\pgfmanual@loc@TMPc{#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@EOI + \ifnum\c@pgfmanual@pretty@openbracecount>0 + \ifpgfmanualpdfwarnings + \pgfplots@warning{The pretty printer did not found the closing curly brace!? This will potentially lead to display errors}% + \fi + \fi + \edef\pgfmanual@pretty@collectargs@loop@NEXT{% + \noexpand\endgroup + \ifnum\c@pgfmanual@pretty@openbracecount>0 + \noexpand\pgfmanualprettyprinterarghasunmatchedbracestrue + \fi + \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + \noexpand\pgfmanual@EOI% <- put this token back into token list! + }% + \else + \ifpgfmanualprettycommentactive + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activenl + \pgfmanualprettycommentactivefalse + \fi + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activepercent + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \pgfmanualprettycommentactivetrue + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@lbrace + \advance\c@pgfmanual@pretty@openbracecount by1 + \ifnum\c@pgfmanual@pretty@openbracecount>1 + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@rbrace + \advance\c@pgfmanual@pretty@openbracecount by-1 + \ifnum\c@pgfmanual@pretty@openbracecount=0 + % we have one complete argument ready! + % append it -- with REAL braces if needed: + \edef\pgfmanual@loc@TMPc{\the\t@pgfmanual@allargs{\the\t@pgfmanual@currentarg}}% + \t@pgfmanual@allargs=\expandafter{\pgfmanual@loc@TMPc}% + \t@pgfmanual@currentarg={}% + % + % check it we need more arguments: + \advance\c@pgfmanual@pretty@curargcount by1 + \ifnum\c@pgfmanual@pretty@curargcount=\pgfmanual@loc@csargcount\relax + \edef\pgfmanual@pretty@collectargs@loop@NEXT{% + \noexpand\endgroup + \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs}% + \the\t@afterpgfmanualprettyprinterhandlecollected + }% + \fi + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \else + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) or comment + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifnum10=\catcode`#1 + % we found a white space (space, TAB + % or NL) with unexpected catcode + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifnum\c@pgfmanual@pretty@openbracecount=0 + \ifpgfmanualpdfwarnings + \begingroup + \toks4{#1}% + \pgfplots@warning{The pretty printer did not find the expected \pgfmanual@loc@csargcount\space arguments (only token \the\toks4 )}% + \endgroup + \fi + \edef\pgfmanual@pretty@collectargs@loop@NEXT{% + \noexpand\endgroup + \noexpand\def\noexpand\pgfmanualprettyprinternumcollectedargs{\the\c@pgfmanual@pretty@curargcount}% + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@allargs\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + \noexpand#1% <- put this token back into token list! + }% + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@collectargs@loop@NEXT +}% + +\newif\ifpgfmanualprettyprinterfoundterminator + +% Collects tokens inside of a token list up to a single delimiting token, dealing with nested +% catcode-12-braces. +% +% #1: is the end token, the delimiter. It won't be collected. +% #2: is code to invoke after +% \pgfmanualprettyprinterhandlecollectedargs has been invoked. +% +% PRECONDITION: +% there is a large token list following +% \pgfmanualprettyprintercollectargcount with balanced braces. The braces +% have \catcode 12. +% POSTCONDITION: +% - the arguments will be collected as +% '<result> := <token list>' +% and then, \pgfmanualprettyprinterhandlecollectedargs{<result>} will be +% invoked. Just define \pgfmanualprettyprinterhandlecollectedargs +% properly. +% Then, #2 will be invoked. +% - The boolean \ifpgfmanualprettyprinterfoundterminator will be set to true if and only if '#1' has been found. +% +% @see \pgfmanualprettyprintercollectargcount for more details. +% +\def\pgfmanualprettyprintercollectupto#1#2{% + \pgfmanualprettyprinterarghasunmatchedbracesfalse + \pgfmanualprettyprinterfoundterminatortrue + \begingroup + \def\pgfmanual@loc@delimittoken{#1}% + \toksdef\t@afterpgfmanualprettyprinterhandlecollected=10 + \t@afterpgfmanualprettyprinterhandlecollected={#2}% + % + \let\c@pgfmanual@pretty@openbracecount=\c@pgf@counta + % I will track open braces here: + \c@pgfmanual@pretty@openbracecount=0 + % + % and I will accumulate the argument token lists as such here: + \toksdef\t@pgfmanual@currentarg=0 + \t@pgfmanual@currentarg={}% + % + \pgfmanual@pretty@collectupto@loop +}% + +% loops through all tokens, collecting the required number of +% arguments. This involves to track nested braces manually. +% #1 is a single token. +\def\pgfmanual@pretty@collectupto@loop#1{% + \let\pgfmanual@pretty@collectupto@loop@NEXT=\pgfmanual@pretty@collectupto@loop + \def\pgfmanual@loc@TMPc{#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@EOI + \edef\pgfmanual@pretty@collectupto@loop@NEXT{% + \noexpand\endgroup + \ifnum\c@pgfmanual@pretty@openbracecount>0 + \noexpand\pgfmanualprettyprinterarghasunmatchedbracestrue + \fi + \noexpand\pgfmanualprettyprinterfoundterminatorfalse + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + \noexpand\pgfmanual@EOI% <- put this token back into token list! + }% + \else + \ifpgfmanualprettycommentactive + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activenl + \pgfmanualprettycommentactivefalse + \fi + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@activepercent + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \pgfmanualprettycommentactivetrue + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@lbrace + \advance\c@pgfmanual@pretty@openbracecount by1 + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@pretty@rbrace + \advance\c@pgfmanual@pretty@openbracecount by-1 + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \else + \ifx\pgfmanual@loc@TMPc\pgfmanual@loc@delimittoken + \ifnum\c@pgfmanual@pretty@openbracecount=0 + % do NOT include the delimit token. + \edef\pgfmanual@pretty@collectupto@loop@NEXT{% + \noexpand\endgroup + \noexpand\pgfmanualprettyprinterhandlecollectedargs{\the\t@pgfmanual@currentarg}% + \the\t@afterpgfmanualprettyprinterhandlecollected + }% + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \else + \t@pgfmanual@currentarg=\expandafter{\the\t@pgfmanual@currentarg#1}% + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@collectupto@loop@NEXT +}% + +\def\pgfmanual@pretty@collectargs@finish@cs#1{% + \def\pgfmanual@pretty@collectargs@finish@cs@hasargs{1}% + \ifnum\pgfmanualprettyprinternumcollectedargs=0 + \ifpgfmanualprettyprinterarghasunmatchedbraces + \else + \def\pgfmanual@pretty@collectargs@finish@cs@hasargs{0}% + \fi + \fi + \if\pgfmanual@pretty@collectargs@finish@cs@hasargs1% + % report the macro and its arguments: + \pgfkeysifdefined{/codeexample/prettyprint/cs/\pgfmanual@loc@TMPa/.@cmd}{% + % oh, we have a separate routine for this macro! Ok, use it: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs/\pgfmanual@loc@TMPa/.@cmd}}% + }{% + % use the generic routine: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs with args/.@cmd}}% + }% + % re-insert the backslash: + \edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@backslash\pgfmanual@loc@TMPa}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa #1\pgfeov + \else + % Oh. We probably got |\pgfkeys| instead of |\pgfkeys{arg}| + % re-insert the backslash: + \edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@backslash\pgfmanual@loc@TMPa}}% + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/cs/.@cmd}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa\pgfeov + #1\relax% simply typeset any encountered tokens after the control sequence. + \fi +}% + +% A user macro which pretty prints a set of keys. +% +% If '#1' is NOT an argument for \pgfkeys, +% \pgfmanualprettyprintpgfkeys will try to recognise at least control +% sequences (in the same way as usual). Thus, you can even use this +% method if there *could* be pgfkeys arguments in an automated pretty +% printing environment. +% +% However, '#1' should only have catcode 12 characters with the +% exception of catcode 13 for newlines, spaces and comments. +\long\def\pgfmanualprettyprintpgfkeys#1{% + \ifpgfmanualprettyenabled + \begingroup + \pgfmanualprettyprintstyles + \pgfmanual@pretty@pgfkeys@loop#1\pgfmanual@EOI + \endgroup + \else + #1% + \fi +} + +\def\pgfmanual@pretty@pgfkeys{% + \let\pgfmanualprettyprinterhandlecollectedargs=\pgfmanual@pretty@pgfkeys@start + \pgfmanualprettyprintercollectupto]{\pgfmanual@pretty@mainloop}%% +}% +\long\def\pgfmanual@pretty@pgfkeys@start#1{% + [% + \pgfmanual@pretty@pgfkeys@loop#1\pgfmanual@EOI + ]% +}% +% iterates through single tokens, detecting key names and values while +% it goes. +\long\def\pgfmanual@pretty@pgfkeys@loop#1{% + \def\pgfmanual@loc@TMPa{#1}% + \ifx\pgfmanual@loc@TMPa\pgfmanual@EOI + \def\pgfmanual@pretty@pgfkeys@loop@NEXT{\relax}% + \else + \def\pgfmanual@pretty@pgfkeys@loop@NEXT{\pgfmanual@pretty@pgfkeys@loop}% + \ifpgfmanualprettycommentactive + #1% + \else + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) or comment + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@comma% + %\let\pgfmanual@pretty@pgfkeys@loop@NEXT=\pgfmanual@pretty@pgfkeys@checkforEOI + ,% + \else + \ifnum10=\catcode`#1 + % another white space... I thought they'd have + % catcode 13. doesn't matter. + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@lbrace + % braces may not occur in the first place - + % but there are circumstances where it is + % convenient to deal with them here (when + % processing arguments of styles) + % Do it. + #1% + \else + \ifx\pgfmanual@loc@TMPa\pgfmanual@pretty@rbrace + #1% + \else + % found the beginning of a key! + % We will collect the key name into + % \toks0. + \toks0={}% + % + % Handle it: + % FIXME what if we found an opening brace!? + \def\pgfmanual@pretty@pgfkeys@loop@NEXT{\pgfmanual@pretty@pgfkeys@collectkey #1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@pgfkeys@loop@NEXT +}% +\def\pgfmanual@pretty@pgfkeys@collectkey#1{% + \def\pgfmanual@loc@TMPb{#1}% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@collectkey}% + \ifx\pgfmanual@loc@TMPb\pgfmanual@EOI + % finish key name. + \edef\pgfmanual@loc@TMPb{\the\toks0 }% + \ifx\pgfmanual@loc@TMPb\pgfutil@empty + \else + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + \fi + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\relax}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@eq + % finish key name. + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + % now, we do the same with the value - we collect it into + % \toks0. + \toks0={}% + \def\pgfmanual@pretty@pgfkeys@collectvalue@hasconsumedspaces{0}% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@collectvalue}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@comma + % finish key name. + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@activenl + % finish key name before newline. This is not + % necessarily as in TeX, but its simpler here + % because we don't need special cases for comments + % and we don't need to gobble following white + % spaces. + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@backslash + % This is confusing. I simply try to invoke + % the control sequence code and recover as + % good as possible. Let's see if that's + % useful. + \edef\pgfmanual@loc@TMPb{\the\toks0 }% + \ifx\pgfmanual@loc@TMPb\pgfutil@empty + \else + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + \fi + % + % we found the start of a control sequence '\command': + % + % collect the control sequence name into + % \pgfmanual@loc@TMPa, but without the backslash: + \begingroup + \let\pgfmanual@loc@TMPa=\pgfutil@empty + \def\afterpgfmanual@pretty@cs{% + \endgroup + \pgfmanual@pretty@pgfkeys@loop + }% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@collectcs@loop}% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@lbrace + % Braces in key names are allowed (if they + % are not the first character of a key + % name) + \def\pgfmanualprettyprinterhandlecollectedargs##1{% + \toks1={##1}% + \edef\pgfmanual@loc@TMPc{% + \the\toks0 \pgfmanual@pretty@lbrace \the\toks1 + \ifpgfmanualprettyprinterarghasunmatchedbraces + \else + \pgfmanual@pretty@rbrace + \fi + }% + \toks0=\expandafter{\pgfmanual@loc@TMPc}% + }% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{% + \pgfmanualprettyprintercollectargcount{1}{\pgfmanual@pretty@pgfkeys@collectkey}% + #1% + }% + \else + \ifx\pgfmanual@loc@TMPb\pgfmanual@pretty@rbrace + \expandafter\pgfmanual@pretty@pgfkeys@processkey\expandafter{\the\toks0 }% + #1% + \def\pgfmanual@pretty@pgfkeys@collectkey@next{\pgfmanual@pretty@pgfkeys@loop}% + \else + \toks0=\expandafter{\the\toks0 #1}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + \pgfmanual@pretty@pgfkeys@collectkey@next +}% +\def\pgfmanual@pretty@pgfkeys@collectvalue#1{% + \def\pgfmanual@loc@TMPb{#1}% + \let\pgfmanual@pretty@pgfkeys@collectvalue@next=\pgfmanual@pretty@pgfkeys@collectvalue + \ifx\pgfmanual@loc@TMPb\pgfmanual@EOI + % the key value is empty. + %\expandafter\pgfmanual@pretty@pgfkeys@processvalue\expandafter{\the\toks0 }% + \let\pgfmanual@pretty@pgfkeys@collectvalue@next=\relax + \else + \def\pgfmanual@pretty@isconsumed{0}% + \if\pgfmanual@pretty@pgfkeys@collectvalue@hasconsumedspaces0% + \ifnum13=\catcode`#1 + % we found a white space (space, TAB or NL) + #1% + \def\pgfmanual@pretty@isconsumed{1}% + \else + \ifnum10=\catcode`#1 + % another white space... I thought they'd have + % catcode 13. doesn't matter. + \def\pgfmanual@pretty@isconsumed{1}% + #1% + \fi + \fi + \fi + \if\pgfmanual@pretty@isconsumed0% + \def\pgfmanualprettyprinterhandlecollectedargs##1{\pgfmanual@pretty@pgfkeys@processvalue{##1}}% the braces will be handled separately. + \def\pgfmanual@pretty@pgfkeys@collectvalue@next{% + \pgfmanualprettyprintercollectupto,{\afterpgfmanual@pretty@collectargs@finish@value}#1% + }% + \fi + \fi + \pgfmanual@pretty@pgfkeys@collectvalue@next +}% +\def\afterpgfmanual@pretty@collectargs@finish@value{% + \pgfutil@ifnextchar\pgfmanual@EOI{% + \pgfmanual@pretty@pgfkeys@loop + }{% + \pgfmanual@pretty@pgfkeys@loop,% re-insert the gobbled comma here! + }% +}% + +{\catcode`\^^M=13 \catcode`\ =13\relax\catcode`\%=13\relax\gdef\pgfmanual@pretty@restorespaces{\def%{\pgfmanual@pretty@percent}\def^^M{\pgfmanual@pretty@space}\def {\pgfmanual@pretty@space}}} + +% #1: the key's name +\def\pgfmanual@pretty@pgfkeys@processkey#1{% + \begingroup + \pgfmanual@pretty@restorespaces + % remember this key name! It is used when we are dealing with + % its value later... (if it has a value) + \xdef\pgfmanual@pretty@pgfkeys@collectkey@keyname{#1}% + \endgroup + % + % check if it is a handled key. FIXME: this could be done in a + % rigorous way! This here assumes that all key handlers start with + % '.' and the '.' occurs never right after a '/' otherwise: + \def\pgfmanual@loc@TMPa{\pgfutil@in@{/.}}% + \expandafter\pgfmanual@loc@TMPa\expandafter{\pgfmanual@pretty@pgfkeys@collectkey@keyname}% + \ifpgfutil@in@ + % split into key name and handler name... + \def\pgfmanual@pretty@splitit##1/.##2\relax{% + \def\pgfmanual@loc@TMPb{{##1}{.##2}}% + }% + \expandafter\pgfmanual@pretty@splitit\pgfmanual@pretty@pgfkeys@collectkey@keyname\relax + % + % report key name AND handler: + \def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/key name with handler/.@cmd}}% + \expandafter\pgfmanual@loc@TMPa\pgfmanual@loc@TMPb\pgfeov + \else + % report key name ... + \def\pgfmanual@loc@TMPa{\pgfkeysvalueof{/codeexample/prettyprint/key name/.@cmd}}% + \expandafter\pgfmanual@loc@TMPa\pgfmanual@pretty@pgfkeys@collectkey@keyname\pgfeov + \fi +} +\def\pgfmanual@pretty@pgfkeys@processvalue#1{% + % report or process the value, depending on the keyname. + % After all, it *may* be a style which needs to be pretty printed + % as well. + \pgfkeysifdefined{/codeexample/prettyprint/key value/\pgfmanual@pretty@pgfkeys@collectkey@keyname/.@cmd}{% + % oh, we have a separate routine for this macro! Ok, use it: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/key value/\pgfmanual@pretty@pgfkeys@collectkey@keyname/.@cmd}}% + }{% + % use the generic routine: + \edef\pgfmanual@loc@TMPb{\noexpand\pgfkeysvalueof{/codeexample/prettyprint/key value/.@cmd}}% + }% + \edef\pgfmanual@loc@TMPa{{\pgfmanual@pretty@pgfkeys@collectkey@keyname}}% + \expandafter\pgfmanual@loc@TMPb\pgfmanual@loc@TMPa{#1}\pgfeov +} + diff --git a/Master/texmf-dist/tex/latex/tikz-dependency/tikz-dependency.sty b/Master/texmf-dist/tex/latex/tikz-dependency/tikz-dependency.sty index 4e57109f8de..bd2022398a3 100644 --- a/Master/texmf-dist/tex/latex/tikz-dependency/tikz-dependency.sty +++ b/Master/texmf-dist/tex/latex/tikz-dependency/tikz-dependency.sty @@ -9,11 +9,15 @@ % % Changelog % +% 1.2 (Nov 3, 2016) +% - It's been a while :) Integrated a patch submitted by Jan Strunk <jan.strunk@uni-koeln.de> +% (thanks a lot Jan!) fixing a bug with the behavior of "edge end x offset". +% % 1.1 (Jan 17, 2012) % - Added the possibility to use simple arcs as edges (keys: arc edge/segmented edge) % - Added "edge start x offset" and "edge end x offset" to fine tune edge start/end point position % - Added \depstyle to define styles more easily -% - Added "simple" theme, based on the parse on page 1 of [Nivre and McDonald, 2008 ACL-HLT] +% - Added "simple" theme, based on the parse on page 1 of [Nivre and McDonald, 2008 ACL-HLT] % - Added instructions to draw bubble parses % - Fixed bug that would cause groupedges not to be straight under some circumstances; % @@ -37,6 +41,9 @@ /depgraph/.search also = {/tikz}, dep id/.code = {\def\dt@depid{#1}}, dep id = dependency, + % fix the distance of the edge + edge height/.code = {\pgfmathsetlengthmacro{\dt@linkheight}{#1}}, + edge height = 0pt, % the distant of the horizontal line of the edge style for two adjacent words edge unit distance/.code = {\pgfmathsetlengthmacro{\dt@linkstep}{#1}}, edge unit distance = 3ex, @@ -179,7 +186,12 @@ \def\anchorpoint{south} \fi \def\source{\dt@depid-\dt@tgtlayer-#2} - \pgfmathsetmacro{\distance}{\dt@linkstep * 4} + + \ifdim\dt@linkheight=0pt + \pgfmathsetmacro{\distance}{\dt@linkstep * 4} + \else + \pgfmathsetlengthmacro{\distance}{\dt@linkheight} + \fi \pgfmathsetlengthmacro{\dt@startdist}{\dt@linkdist} \ifdt@linkbelow \pgfmathsetmacro{\distance}{-(\dt@linkstep * 4)} @@ -199,7 +211,11 @@ \def\source{\wordref{\dt@tgtlayer}{#2}} \def\dest{\wordref{\dt@tgtlayer}{#3}} \def\depname{#4} - \pgfmathsetlengthmacro{\distance}{abs(\offb - \offa)*\dt@linkstep} + \ifdim\dt@linkheight=0pt + \pgfmathsetlengthmacro{\distance}{abs(\offb - \offa)*\dt@linkstep} + \else + \pgfmathsetlengthmacro{\distance}{\dt@linkheight} + \fi \groupedge[#1]{\source}{\dest}{\depname}{\distance} \end{scope}} @@ -263,9 +279,9 @@ % meaningful for segmented edge, but we also draw the nodes for arc edge, someone % may always find these anchors useful... \node (\dt@lastlabel-edge-origin) [coordinate] at ($(#2.\anchorpoint) + (\doff,\dt@startdist) + (\dt@EdgeStartOffsetX,0)$) {}; - \node (\dt@lastlabel-edge-first-corner) [coordinate] at ($(\dt@lastlabel-edge-origin) + (\dslant,\dt@enddist) + (\dt@EdgeEndOffsetX,0)$) {}; - \node (\dt@lastlabel-edge-second-corner) [coordinate] at ($(#3.\anchorpoint) + (-\dslant,\dt@enddist+\dt@startdist+\ydiff)$) {}; - \node (\dt@lastlabel-edge-endpoint) [coordinate] at ($(#3.\anchorpoint) + (0,\dt@startdist)$) {}; + \node (\dt@lastlabel-edge-first-corner) [coordinate] at ($(\dt@lastlabel-edge-origin) + (\dslant,\dt@enddist)$) {}; + \node (\dt@lastlabel-edge-second-corner) [coordinate] at ($(#3.\anchorpoint) + (\dt@EdgeEndOffsetX,0) + (-\dslant,\dt@enddist+\dt@startdist+\ydiff)$) {}; + \node (\dt@lastlabel-edge-endpoint) [coordinate] at ($(#3.\anchorpoint) + (0,\dt@startdist) + (\dt@EdgeEndOffsetX,0)$) {}; \ifdt@arcedge % link above, left to right |