From 57d833d68da94cb5a1cc5e675f9e21f1681e59d0 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 4 Feb 2017 00:23:35 +0000 Subject: forest (3feb17) git-svn-id: svn://tug.org/texlive/trunk@43129 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/forest/forest.sty | 113 +++++++++++++++----------- 1 file changed, 65 insertions(+), 48 deletions(-) (limited to 'Master/texmf-dist/tex/latex/forest') diff --git a/Master/texmf-dist/tex/latex/forest/forest.sty b/Master/texmf-dist/tex/latex/forest/forest.sty index 47a19b90cd2..0c6c43ba005 100644 --- a/Master/texmf-dist/tex/latex/forest/forest.sty +++ b/Master/texmf-dist/tex/latex/forest/forest.sty @@ -44,7 +44,7 @@ %% - LICENCE %% To use the package, only the files marked with + need to be installed. %% -\ProvidesPackage{forest}[2017/01/27 v2.1.3 Drawing (linguistic) trees] +\ProvidesPackage{forest}[2017/02/02 v2.1.4 Drawing (linguistic) trees] \RequirePackage{tikz}[2013/12/13] \usetikzlibrary{shapes} @@ -2342,8 +2342,8 @@ \expandafter\endgroup \expandafter\edef\expandafter#2\expandafter{\forest@temp@message}% } -\NewDocumentCommand\forestdebugtypeouttree{o m}{% - \forestdebug@typeouttree{#1}\forest@temp +\NewDocumentCommand\forestdebugtypeouttree{d() O{\forest@cn}}{% + \forestdebug@typeouttree{#2}\forest@temp \typeout{\IfValueTF{#1}{#1: }{}\forest@temp}% } \def\forestdebug@typeouttree@build{% @@ -4361,10 +4361,10 @@ {#2}% } \def\forest@aggregate@count#1{\forest@aggregate - {\def\forestmathresult{1}}% - {\def\forestmathresult{1}}% - {\edef\forestmathresult{\the\numexpr\forestregister{aggregate result}+1}}% - {\forestrget{aggregate result}\forestmathresult}% + {\def\forestmathresult{0}\let\forestmathresulttype\forestmathtype@count}% + {\def\forestmathresult{1}\let\forestmathresulttype\forestmathtype@count}% + {\edef\forestmathresult{\the\numexpr\forestregister{aggregate result}+1}\let\forestmathresulttype\forestmathtype@count}% + {\forestrget{aggregate result}\forestmathresult\let\forestmathresulttype\forestmathtype@count}% {#1}% } \def\forest@aggregate@average#1#2{\forest@aggregate @@ -6320,10 +6320,17 @@ \forest@patch@enormouscoordinateboxbounds@minus\pgfpositionnodelatermaxx \forest@patch@enormouscoordinateboxbounds@minus\pgfpositionnodelatermaxy % end of patch - \xappto\forest@smuggle{\noexpand\forestoset{min x}{\pgfpositionnodelaterminx}}% - \xappto\forest@smuggle{\noexpand\forestoset{min y}{\pgfpositionnodelaterminy}}% - \xappto\forest@smuggle{\noexpand\forestoset{max x}{\pgfpositionnodelatermaxx}}% - \xappto\forest@smuggle{\noexpand\forestoset{max y}{\pgfpositionnodelatermaxy}}% + % when shape=coordinate, pgf returns \pgfpositionnodelater... with wrong catcode of pt + \forest@pnn@addtosmuggle{min x}\pgfpositionnodelaterminx + \forest@pnn@addtosmuggle{max x}\pgfpositionnodelatermaxx + \forest@pnn@addtosmuggle{min y}\pgfpositionnodelaterminy + \forest@pnn@addtosmuggle{max y}\pgfpositionnodelatermaxy +} +\def\forest@pnn@addtosmuggle#1#2{% + {% + \pgfutil@tempdima=#2\relax + \xappto\forest@smuggle{\noexpand\forestoset{#1}{\the\pgfutil@tempdima}}% + }% } \def\forest@node@forest@positionnodelater@restore{% \ifforest@drawtree@preservenodeboxes@ @@ -7703,7 +7710,7 @@ \advance\c@pgf@counta -1 \forest@sort\forest@ppiraw@cmp\forest@ppiraw@let\forest@sort@ascending{0}{\the\c@pgf@counta}% } -\def\forest@processprojectioninfo#1#2{% +\def\forest@processprojectioninfo#1#2#3{% \edef\forest@ppi@inputprefix{#1}% \c@pgf@counta=0 \c@pgf@countb=-1 @@ -7735,15 +7742,17 @@ \forest@append@point@to@inner@array \forest@xo\forest@yo {#2\the\c@pgf@countb @}% - \csedef{#2(\forest@xo,\forest@yo)}{\the\c@pgf@countb}% + \eapptotoks#3{(\forest@xo,\forest@yo){\the\c@pgf@countb}}% \fi\fi \fi\fi + % todo: is this really necessary? (yes: see the "ugly" thing above) \cslet{#1\the\c@pgf@counta xo}\relax \cslet{#1\the\c@pgf@counta yo}\relax \cslet{#1\the\c@pgf@counta xp}\relax \cslet{#1\the\c@pgf@counta yp}\relax \advance\c@pgf@counta 1 \saferepeat + % todo: is this really necessary? \cslet{#1n}\relax \advance\c@pgf@countb 1 \csedef{#2n}{\the\c@pgf@countb}% @@ -7768,15 +7777,16 @@ \advance\c@pgf@countc 1 \csedef{#3n}{\the\c@pgf@countc}% } -\def\forest@breakpath#1#2#3{% +\def\forest@breakpath#1#2#3#4{% \edef\forest@bp@prefix{#2}% + \let\forest@breakpath@toks#3% \forest@save@pgfsyssoftpath@tokendefs \let\pgfsyssoftpath@movetotoken\forest@breakpath@processfirstpoint \let\pgfsyssoftpath@linetotoken\forest@breakpath@processfirstpoint %\pgfusepath{}% empty the current path. ok? #1% \forest@restore@pgfsyssoftpath@tokendefs - \pgfsyssoftpath@getcurrentpath#3% + \pgfsyssoftpath@getcurrentpath#4% } \def\forest@breakpath@processfirstpoint#1#2{% \forest@breakpath@processmoveto{#1}{#2}% @@ -7787,17 +7797,21 @@ \pgfsyssoftpath@moveto{#1}{#2}% \def\forest@previous@x{#1}% \def\forest@previous@y{#2}% - \expandafter\let\expandafter\forest@previous@i - \csname\forest@bp@prefix(#1,#2)\endcsname + \forest@breakpath@getfromtoks\forest@breakpath@toks\forest@previous@i{#1}{#2}% \expandafter\let\expandafter\forest@previous@px \csname\forest@bp@prefix\forest@previous@i x\endcsname \expandafter\let\expandafter\forest@previous@py \csname\forest@bp@prefix\forest@previous@i y\endcsname } +\def\forest@breakpath@getfromtoks#1#2#3#4{% + % #1=cache toks register, #2=receiving cs, (#3,#4)=point; + % we rely on the fact that the point we're looking up should always be present + \def\forest@breakpath@getfromtoks@##1(#3,#4)##2##3\forest@END{##2}% + \edef#2{\expandafter\forest@breakpath@getfromtoks@\the#1\forest@END}% +} \def\forest@breakpath@processlineto#1#2{% \let\forest@breakpath@op\pgfsyssoftpath@lineto - \expandafter\let\expandafter\forest@i - \csname\forest@bp@prefix(#1,#2)\endcsname + \forest@breakpath@getfromtoks\forest@breakpath@toks\forest@i{#1}{#2}% \expandafter\let\expandafter\forest@px \csname\forest@bp@prefix\forest@i x\endcsname \expandafter\let\expandafter\forest@py @@ -7838,7 +7852,6 @@ \forest@append@point@to@inner@array \forest@last@x\forest@last@y {\forest@bp@prefix\the\forest@temp@count @}% - \csedef{\forest@bp@prefix(\the\pgf@x,\the\pgf@y)}{\the\forest@temp@count}% \saferepeat \fi \forest@breakpath@op{#1}{#2}% @@ -7860,13 +7873,15 @@ }% \let#3\forest@gep@global@edge } +\newtoks\forest@pi@toks +\newtoks\forest@segment@toks \def\forest@get@one@tightedgeofpath#1#2#3{% \forest@projectpathtogrowline#1{forest@pp@}% \forest@sortprojections{forest@pp@}% - \forest@processprojectioninfo{forest@pp@}{forest@pi@}% - \forest@breakpath#1{forest@pi@}\forest@brokenpath + \forest@processprojectioninfo{forest@pp@}{forest@pi@}\forest@pi@toks + \forest@breakpath#1{forest@pi@}\forest@pi@toks\forest@brokenpath \forest@sort@inner@arrays{forest@pi@}#2% - \forest@pathtodict\forest@brokenpath{forest@pi@}% + \forest@pathtodict\forest@brokenpath\forest@segment@toks \forest@gettightedgeofpath@getedge\forest@edge \forest@simplifypath\forest@edge#3% } @@ -7916,9 +7931,8 @@ \noexpand\forest@sort@cmpdimcs{#1##1d}{#1##2d}% }% } -\let\forest@inpath\advance \def\forest@pathtodict#1#2{% - \edef\forest@pathtodict@prefix{#2}% + \let\forest@pathtodict@toks#2% \forest@save@pgfsyssoftpath@tokendefs \let\pgfsyssoftpath@movetotoken\forest@pathtodict@movetoop \let\pgfsyssoftpath@linetotoken\forest@pathtodict@linetoop @@ -7927,15 +7941,10 @@ \forest@restore@pgfsyssoftpath@tokendefs } \def\forest@pathtodict@movetoop#1#2{% - \def\forest@pathtodict@subpathstart{(#1,#2)-}% + \apptotoks\forest@pathtodict@toks{(#1,#2)}% } \def\forest@pathtodict@linetoop#1#2{% -\if\relax\forest@pathtodict@subpathstart\relax\else - \let\forest@pathtodict@from\forest@pathtodict@subpathstart - \fi - \expandafter\let\csname\forest@pathtodict@prefix\forest@pathtodict@from-(#1,#2)\endcsname\forest@inpath - \def\forest@pathtodict@from{(#1,#2)-}% - \def\forest@pathtodict@subpathstart{}% + \apptotoks\forest@pathtodict@toks{--(#1,#2)}% } \def\forest@gettightedgeofpath@getedge#1{% cs to store the edge into \pgfsyssoftpath@setcurrentpath\pgfutil@empty @@ -7975,25 +7984,28 @@ \advance\c@pgf@counta -1 \safeloop \ifnum\c@pgf@countc<\csname forest@pi@\forest@aplusone @n\endcsname\relax - \forest@tempfalse - \expandafter\ifx\csname forest@pi@(% - \csname forest@pi@\the\c@pgf@counta @\the\c@pgf@countb x\endcsname,% + \edef\forest@temp{% + (\csname forest@pi@\the\c@pgf@counta @\the\c@pgf@countb x\endcsname,% \csname forest@pi@\the\c@pgf@counta @\the\c@pgf@countb y\endcsname)--(% \csname forest@pi@\forest@aplusone @\the\c@pgf@countc x\endcsname,% \csname forest@pi@\forest@aplusone @\the\c@pgf@countc y\endcsname)% - \endcsname\forest@inpath - \forest@temptrue + }% + \expandafter\expandafter\expandafter\pgfutil@in@\expandafter\expandafter\expandafter + {\expandafter\forest@temp\expandafter}\expandafter + {\the\forest@segment@toks}% + \ifpgfutil@in@ \else - \expandafter\ifx\csname forest@pi@(% - \csname forest@pi@\forest@aplusone @\the\c@pgf@countc x\endcsname,% + \edef\forest@temp{% + (\csname forest@pi@\forest@aplusone @\the\c@pgf@countc x\endcsname,% \csname forest@pi@\forest@aplusone @\the\c@pgf@countc y\endcsname)--(% \csname forest@pi@\the\c@pgf@counta @\the\c@pgf@countb x\endcsname,% \csname forest@pi@\the\c@pgf@counta @\the\c@pgf@countb y\endcsname)% - \endcsname\forest@inpath - \forest@temptrue - \fi + }% + \expandafter\expandafter\expandafter\pgfutil@in@\expandafter\expandafter\expandafter + {\expandafter\forest@temp\expandafter}\expandafter + {\the\forest@segment@toks}% \fi - \ifforest@temp + \ifpgfutil@in@ \forest@gettightedgeofpath@maybemoveto{\the\c@pgf@counta}{\the\c@pgf@countb}% \edef\forest@last@x{% \csname forest@pi@\forest@aplusone @\the\c@pgf@countc x\endcsname}% @@ -8150,7 +8162,10 @@ }% \pgfsyssoftpath@getcurrentpath#3% } +\newtoks\forest@PIi@toks +\newtoks\forest@PIii@toks \def\forest@distance@between@edge@paths#1#2#3{% + \begingroup % #1, #2 = (edge) paths % % project paths @@ -8162,11 +8177,11 @@ {forest@p1@}{forest@p2@}% {forest@P1@}{forest@P2@}% % process projections - \forest@processprojectioninfo{forest@P1@}{forest@PI1@}% - \forest@processprojectioninfo{forest@P2@}{forest@PI2@}% + \forest@processprojectioninfo{forest@P1@}{forest@PI1@}\forest@PIi@toks + \forest@processprojectioninfo{forest@P2@}{forest@PI2@}\forest@PIii@toks % break paths - \forest@breakpath#1{forest@PI1@}\forest@broken@one - \forest@breakpath#2{forest@PI2@}\forest@broken@two + \forest@breakpath#1{forest@PI1@}\forest@PIi@toks\forest@broken@one + \forest@breakpath#2{forest@PI2@}\forest@PIii@toks\forest@broken@two % sort inner arrays ---optimize: it's enough to find max and min \forest@sort@inner@arrays{forest@PI1@}\forest@sort@descending \forest@sort@inner@arrays{forest@PI2@}\forest@sort@ascending @@ -8190,7 +8205,9 @@ \fi \advance\c@pgf@countc 1 \forest@repeat - \let#3\forest@distance + \global\let\forest@global@temp\forest@distance + \endgroup + \let#3\forest@global@temp } % merge projections: we need two projection arrays, both containing % projection points from both paths, but each with the original -- cgit v1.2.3