From 0a913026039e7c9ab353dbc13d77074411ba616a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 4 Mar 2016 22:52:55 +0000 Subject: forest (4mar16) git-svn-id: svn://tug.org/texlive/trunk@39937 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/forest/README | 2 +- Master/texmf-dist/doc/latex/forest/forest-doc.pdf | Bin 1128357 -> 1135365 bytes Master/texmf-dist/doc/latex/forest/forest-doc.tex | 111 +++++++++++++++------ Master/texmf-dist/doc/latex/forest/forest.pdf | Bin 432039 -> 432641 bytes Master/texmf-dist/source/latex/forest/forest.dtx | 116 ++++++++++++++++------ Master/texmf-dist/tex/latex/forest/forest.sty | 114 +++++++++++++++------ 6 files changed, 252 insertions(+), 91 deletions(-) diff --git a/Master/texmf-dist/doc/latex/forest/README b/Master/texmf-dist/doc/latex/forest/README index d30dfb0a56a..26147e0e784 100644 --- a/Master/texmf-dist/doc/latex/forest/README +++ b/Master/texmf-dist/doc/latex/forest/README @@ -1,4 +1,4 @@ -LaTeX package: forest [2016/02/20 v2.0.1 Drawing (linguistic) trees] +LaTeX package: forest [2016/03/04 v2.0.2 Drawing (linguistic) trees] Copyright (c) 2016 Saso Zivanovic (Sa\v{s}o \v{Z}ivanovi\'{c}) diff --git a/Master/texmf-dist/doc/latex/forest/forest-doc.pdf b/Master/texmf-dist/doc/latex/forest/forest-doc.pdf index 4d6494448ed..75f49d6c362 100644 Binary files a/Master/texmf-dist/doc/latex/forest/forest-doc.pdf and b/Master/texmf-dist/doc/latex/forest/forest-doc.pdf differ diff --git a/Master/texmf-dist/doc/latex/forest/forest-doc.tex b/Master/texmf-dist/doc/latex/forest/forest-doc.tex index c49b354c2cf..9c3b64f016e 100644 --- a/Master/texmf-dist/doc/latex/forest/forest-doc.tex +++ b/Master/texmf-dist/doc/latex/forest/forest-doc.tex @@ -302,6 +302,9 @@ for first={+key={{ss }},format={pgfkey}} ]>{short step} +\indexset + [for first={format=pgfkey}] + >{named nodewalk} {\makeatletter % an dirty patch: \lst@nolig can sneak in the name... @@ -1616,13 +1619,12 @@ alongside the main package. Loading several libraries in this way is allowed: h more control over loading the defaults, use the following macros. \begin{syntax} -\indexitem{macro>useforestlibrary}[|*|]|{|\meta{library}|,...}| +\indexitem{macro>useforestlibrary}[|*|][|[|\meta{options}|]|]|{|\meta{library}|,...}| Loads the given libraries. -The starred version applies their defaults as well, while the starless does not. - -Multiple library names can be given, separated by commas. This macro can only be used in the -preamble. +The starred version applies their defaults as well, while the starless does not. Multiple library +names can be given, separated by commas. Libraries can receive \meta{options}. This macro can only +be used in the preamble. \indexitem{macro>forestapplylibrarydefaults}|{|\meta{library name},...|}| Loads the default settings of \meta{library}. @@ -1703,18 +1705,15 @@ By default, the package warns when a compatibility feature is used. Disable thi \begin{syntax} %%% begin listing region: forest_environment_doc -\indexitem{environment>forest={[\texttt{(}\meta{stages}\texttt{)}]\meta{tree}}} +\indexitem{environment>forest={[\texttt{(}\meta{config}\texttt{)}]\meta{tree}}} %%% end listing region: forest_environment_doc -\indexitem{macro>Forest}[*][|(|\meta{stages}|)|]\marg{tree} +\indexitem{macro>Forest}[*][|(|\meta{config}|)|]\marg{tree} The environment and the starless version of the macro introduce a group; the starred macro does not, so the created nodes can be used afterwards, like in the example below. (Note that this will leave a lot of temporary macros lying around. This shouldn't be a problem, however, since all of them reside in the |\forest| ``namespace''.) - \meta{stages}, if given, overrides the contents of style \index{stages} for the current - environment/macro. - {\tikzexternaldisable \begin{forestexample} We create a @@ -1734,6 +1733,13 @@ By default, the package warns when a compatibility feature is used. Disable thi } \end{forestexample}} + Using \meta{config}, it is possible to configure behaviour of the environment/macro prior to + application of \index{style>stages}. The following keys are defined. + \begin{syntax} + \indexitem{option of=forest>stages}|=|\meta{style definition} overrides the contents of style + \index{style>stages} for the current environment/macro. + \end{syntax} + \indexitem{macro>forestset}\marg{keylist} Execute \meta{keylist} (of node keys) with the default path set to \keyname{/forest}. @@ -1899,7 +1905,7 @@ processing flow. \indexitem{node key>typeset node} Typesets the \emph{current} node, saving the result in the node box. - This key can be useful also in the default \index{stages}. If, for example, the node's content + This key can be useful also in the default \index{style>stages}. If, for example, the node's content is changed and the node retypeset just before drawing the tree, the node will be positioned as if it contained the ``old'' content, but have the new content: this is how the constant distance between $\times$s is implemented in the \index{GP1} style. @@ -1929,8 +1935,11 @@ processing flow. \index{tikz}. Within each task, the order in which the nodes are visited is determined by nodewalk styles \indexdef{nodewalk style>draw tree nodes processing order}, \indexdef{nodewalk style>draw tree edges processing order} and \indexdef{nodewalk style>draw tree tikz processing - order}, respectively, with \index{processing order} as the fallback in case any of these styles - does not exist (the default). + order}, respectively, with \indexdef{nodewalk style>draw tree processing order} as the first and + \index{processing order} as the second fallback in case any of these styles does not exist. (By + default, \index{processing order}, with default value \index{tree}, is used, so the entire + (sub)tree is drawn.) The origin of all these nodewalks is the current node at the time of + invocation of |draw_tree|. However, the whole procedure is fully customizable via style \indexdef{style>draw tree method}, originally defined like shown below. To draw an individual node, edge (to parent) @@ -1938,6 +1947,11 @@ processing flow. edge} and \indexdef{node key>draw tree tikz} are used, respectively. \lstinputregion{forest.dtx}{draw_tree_method} + + Also available are keys \indexdef{node key>draw tree node'}, \indexdef{node key>draw tree edge'} + and \indexdef{node key>draw tree tikz'} which ignore \index{phantom}. Note that all these keys + (both variants with and without |'|) should be used only within the definition of \index{draw tree + method}. \indexitem{node key>draw tree box}|=|[\meta{\TeX\ box}] The picture drawn by the subsequent invocations of \index{draw tree} and \index{draw tree'} is put into \meta{\TeX\ box}. If @@ -2104,7 +2118,7 @@ All temporal propagators can be nested without limit. \indexitem{propagator>given options} - When \index{stages} processing starts, this list holds the keys given by the user in the + When \index{style>stages} processing starts, this list holds the keys given by the user in the bracket representation. \indexitem{propagator>before typesetting nodes}|=|\meta{keylist} Defers the processing of the @@ -3586,6 +3600,7 @@ parent-first first-child-first. current node's descendants (|first leaf|) or subtree (|first leaf'|), in the linear order \indexitem{step>id}|=|\meta{id} the node with the given id; this step does not depend on the current node \indexitem{step>last} the last child +\indexitem{step>last dynamic node} the last non-integrated (created/removed/replaced) node; see \S\ref{ref:dynamic} \indexitem{step>last leaf}, \indexdef{step>last leaf'} the last leaf (terminal node) of the current node's descendants (|last leaf|) or subtree (|last leaf'|), in the linear order \indexitem{step>n}|=|$n$ the $n$th child; counting starts at $1$\footnote{Note that \keyname{n} @@ -3693,21 +3708,21 @@ parent-first first-child-first. Like the |tree| keys, but the current node is not visited. -\indexitem[print form+=\spaces{9}]{step>relative level <}, +\indexitem[print form+=\spaces{9}]{step>relative level<}, \indexdef[print form+=\spaces{9}]{step>relative level}, - \indexdef[set={form=relative level \protect\greaterthan}]{step>relative level GT}\texttt{\spaces{9}}|=|\meta{count} + \indexdef[set={form=relative level\protect\greaterthan}]{step>relative levelGT}\texttt{\spaces{9}}|=|\meta{count} \itemnosep -\indexitem{step>relative level reversed <}, +\indexitem{step>relative level reversed<}, \indexdef{step>relative level reversed}, - \indexdef[set={form=relative level reversed \protect\greaterthan}]{step>relative level reversed GT}|=|\meta{count} + \indexdef[set={form=relative level reversed\protect\greaterthan}]{step>relative level reversedGT}|=|\meta{count} \itemnosep -\indexitem[print form+=\spaces{9},+print form=\spaces{9}]{step>level <}, +\indexitem[print form+=\spaces{9},+print form=\spaces{9}]{step>level<}, \indexdef[print form+=\spaces{9},+print form=\spaces{9}]{step>level}, - \indexdef[set={form=level \protect\greaterthan},+print form=\spaces{9}]{step>level GT}\texttt{\spaces{9}}|=|\meta{count} + \indexdef[set={form=level\protect\greaterthan},+print form=\spaces{9}]{step>levelGT}\texttt{\spaces{9}}|=|\meta{count} \itemnosep -\indexitem[+print form=\spaces{9}]{step>level reversed <}, +\indexitem[+print form=\spaces{9}]{step>level reversed<}, \indexdef[+print form=\spaces{9}]{step>level reversed}, - \indexdef[set={form=level reversed \protect\greaterthan},+print form=\spaces{9}]{step>level reversed GT}|=|\meta{count} + \indexdef[set={form=level reversed\protect\greaterthan},+print form=\spaces{9}]{step>level reversedGT}|=|\meta{count} Visits the nodes in the subtree of the current node whose level (depth) is less than \emph{or equal to}, equal to, or greater than \emph{or equal to} the given level. @@ -3739,7 +3754,7 @@ parent-first first-child-first. \itemnosep \indexitem[+print form=\spaces{22},print form+=\spaces{9}]{step>siblings reversed}% \itemnosep -\indexitem[print form={current and \spaces{13} siblings reversed}]{step>current and siblings reversed}% +\indexitem[print form={current and \spaces{9} siblings reversed}]{step>current and siblings reversed}% Visit preceding, following or all siblings; visit the current node as well or not; visit in normal or reversed order. @@ -4205,7 +4220,7 @@ redefining short steps is always ok, however, as they are never used in the code \let\outerleftmargin\leftmargin \begin{syntax} - \item\indexdef{option of=define long step>n args}|=|\meta{number}\hfill |1| + \item\indexdef{option of=define long step>n args}|=|\meta{number}\hfill |0| \item\indexdef{option of=define long step>make for}|=|\meta{boolean}\hfill |true| Should we make a \index{for step} prefix for the step? @@ -4241,6 +4256,11 @@ redefining short steps is always ok, however, as they are never used in the code Define short step taking $n$ arguments as the given \meta{nodewalk}. Refer to the arguments in the usual way, via |#1|, \dots. To (re)define braces, |{}|, write |define short step={group}{1}{...}|. + +\indexitem{handler>nodewalk style}|=|\meta{nodewalk} + +A shorthand for |for nodewalk={|\meta{nodewalk}|}{}|. + \end{syntax} @@ -4419,6 +4439,11 @@ the tree. The \meta{node} that will be (re)integrated into the tree can be specified in the following ways: \begin{syntax} \item \meta{empty}: uses the last non-integrated (i.e.\ created/removed/replaced) node. + \begin{advise} + \item This node can also be referred to using nodewalk step \index{last dynamic node}. + \item The list of all such nodes is automatically saved in named nodewalk \indexdef{named + nodewalk>dynamic nodes}, to be \index{load}ed when needed. + \end{advise} \item \meta{node}: a new node is created using the given bracket representation (the node may contain children, i.e.\ a tree may be specified), and used as the argument to the key. @@ -5124,6 +5149,34 @@ anchor,option>anchor,anchor>anchor,calign,for step,tree,s sep,option>l,n childre \subsubsection{v2.0} \begin{description} +\item[v2.0.2 (2016/03/04)] \mbox{} + + Backward incompatible changes: + \begin{itemize} + \item The semantics of the parenthesized optional argument to \index{forest} environment and + \index{Forest} macro has changed. The argument was introduced in v2.0.0: if present, it + redefined \index{style>stages} style for the current environment/macro. This argument is now + generalized to allow further (pre-\index{style>stages}) customization in future versions of the + package. To temporarily redefine \index{style>stages}, write |(|\index{option of=forest>stages}|={...})|. + \end{itemize} + + New functionality: + \begin{itemize} + \item Key \index{last dynamic node} and named nodewalk \index{dynamic nodes}. + \item An optional argument to \index{useforestlibrary} to pass package options to libraries. + \item Handler \index{nodewalk style}. + \item Keys \index{draw tree node'}, \index{draw tree edge'} and \index{draw tree tikz'}. + \end{itemize} + + Bugfixes: + \begin{itemize} + \item Fixed \index{replace by} when applied to the root node. + \item Registers are now initialized to an empty string, 0pt, or 0. + \item Packing doesn't destroy the current pgfpath anymore. + \item \index{forestStandardNode} now uses \index{name'}. + \item \index{draw tree edge} now respects \index{phantom}. + \end{itemize} + \item[v2.0.1 (2016/02/20)] \mbox{} New functionality: @@ -5162,8 +5215,8 @@ anchor,option>anchor,anchor>anchor,calign,for step,tree,s sep,option>l,n childre \item |compat=|\indexdef{option of=compat>1.0-stages} Processing of \index{given options}, which is now exposed, and the new keylists \index{default - preamble} and \index{preamble} is now included at the start of the default \index{stages} - style. When changing \index{stages}, the instruction to process these keylists must now be + preamble} and \index{preamble} is now included at the start of the default \index{style>stages} + style. When changing \index{style>stages}, the instruction to process these keylists must now be given explicitely. \item |compat=|\indexdef{option of=compat>1.0-forstep} @@ -5202,8 +5255,8 @@ anchor,option>anchor,anchor>anchor,calign,for step,tree,s sep,option>l,n childre (\keyname{for}) \keyname{linear previous}&(\index{for step}) \index{previous node}&\indexdef{option of=compat>1.0-linear}\\ \keyname{triangle}&\index{roof} (library \reflibrary{linguistics})&\indexdef{option of=compat>1.0-triangle}\\ \keyname{/tikz/fit to tree}&\index{fit to}\keyname{=}\index{tree}\footnote{The v1.0 key \keyname{/tikz/fit to tree} also set \keyname{inner sep=0}; the v2.0 key \index{fit to} does not do that.}&\indexdef{option of=compat>1.0-fittotree}\\ - \keyname{begin forest}, \keyname{end forest}&none (use \index{stages}&\index{1.0-stages}\\ - \keyname{end forest}, \keyname{end forest}&none (use \index{stages}&\index{1.0-stages}\\ + \keyname{begin forest}, \keyname{end forest}&none (use \index{style>stages}&\index{1.0-stages}\\ + \keyname{end forest}, \keyname{end forest}&none (use \index{style>stages}&\index{1.0-stages}\\ \end{tabularx} \end{syntax} @@ -5302,7 +5355,7 @@ anchor,option>anchor,anchor>anchor,calign,for step,tree,s sep,option>l,n childre \end{compactitem} \item[v1.02 (2013/01/20)] \mbox{} \begin{compactitem} - \item Reworked style \index{stages}: it's easier to modify the processing flow now. + \item Reworked style \index{style>stages}: it's easier to modify the processing flow now. \item Individual stages must now be explicitely called in the context of some (usually root) node. \item Added \index{delay n} and \index{if have delayed}. diff --git a/Master/texmf-dist/doc/latex/forest/forest.pdf b/Master/texmf-dist/doc/latex/forest/forest.pdf index ed9be4c2389..26d4af38af8 100644 Binary files a/Master/texmf-dist/doc/latex/forest/forest.pdf and b/Master/texmf-dist/doc/latex/forest/forest.pdf differ diff --git a/Master/texmf-dist/source/latex/forest/forest.dtx b/Master/texmf-dist/source/latex/forest/forest.dtx index cd0c0187080..615d4712a3f 100644 --- a/Master/texmf-dist/source/latex/forest/forest.dtx +++ b/Master/texmf-dist/source/latex/forest/forest.dtx @@ -1,4 +1,4 @@ -% \CheckSum{12506} +% \CheckSum{12570} % \iffalse meta-comment % forest.dtx %% `forest' is a `pgf/tikz'-based package for drawing (linguistic) trees. @@ -83,7 +83,7 @@ % % \section{Identification} % \begin{macrocode} -\ProvidesPackage{forest}[2016/02/20 v2.0.1 Drawing (linguistic) trees] +\ProvidesPackage{forest}[2016/03/04 v2.0.2 Drawing (linguistic) trees] \RequirePackage{tikz}[2013/12/13] \usetikzlibrary{shapes} @@ -132,11 +132,12 @@ \foresttikzcshacktrue \def\forest@loadlibrarieslater{} \AtEndOfPackage{\forest@loadlibrarieslater} -\NewDocumentCommand\useforestlibrary{s m}{% - \forcsvlist\useforestlibrary@{#2}% - \IfBooleanT{#1}{\forestapplylibrarydefaults{#2}}% +\NewDocumentCommand\useforestlibrary{s O{} m}{% + \def\useforestlibrary@@##1{\useforestlibrary@{#2}{##1}}% + \forcsvlist\useforestlibrary@@{#3}% + \IfBooleanT{#1}{\forestapplylibrarydefaults{#3}}% } -\def\useforestlibrary@#1{\RequirePackage{forest-lib-#1}} +\def\useforestlibrary@#1#2{\RequirePackage[#1]{forest-lib-#2}} \def\forestapplylibrarydefaults#1{\forcsvlist\forestapplylibrarydefaults@{#1}} \def\forestapplylibrarydefaults@#1{\forestset{libraries/#1/defaults/.try}} \NewDocumentCommand\ProvidesForestLibrary{m O{}}{\ProvidesPackage{forest-lib-#1}[#2]} @@ -2676,21 +2677,27 @@ \forestset{ declare toks register/.code={% \forest@declareregisterhandler\forest@declaretoksregister@handler{#1}% + \forestset{#1={}}% }, declare autowrapped toks register/.code={% \forest@declareregisterhandler\forest@declareautowrappedtoksregister@handler{#1}% + \forestset{#1={}}% }, declare keylist register/.code={% \forest@declareregisterhandler\forest@declarekeylistregister@handler{#1}% + \forestset{#1'={}}% }, declare dimen register/.code={% \forest@declareregisterhandler\forest@declaredimenregister@handler{#1}% + \forestset{#1'=0pt}% }, declare count register/.code={% \forest@declareregisterhandler\forest@declarecountregister@handler{#1}% + \forestset{#1'=0}% }, declare boolean register/.code={% \forest@declareregisterhandler\forest@declarebooleanregister@handler{#1}% + \forestset{#1=0}% }, } % \end{macrocode} @@ -3673,6 +3680,11 @@ \fi }, } +\pgfqkeys{/handlers}{ + .nodewalk style/.code={\forest@handlers@savecurrentpath\pgfkeysalso{% + \forest@currentpath/nodewalk/\forest@currentname/.style={#1}% + }}, +} % \end{macrocode} % |\forest@forstepwrapper| is defined so that it can be changed by |compat| to create unfailable spatial propagators from v1.0. % \begin{macrocode} @@ -4622,6 +4634,7 @@ % % \begin{macrocode} \def\forest@last@node{0} +\csdef{forest@nodewalk@saved@dynamic nodes}{} \def\forest@nodehandleby@name@nodewalk@or@bracket#1{% \ifx\pgfkeysnovalue#1% \edef\forest@last@node{\forest@node@Nametoid{forest@last@node}}% @@ -4632,6 +4645,7 @@ \def\forest@nodehandleby@nnb@checkfirst#1#2\forest@END{% \ifx[#1%] \forest@create@node{#1#2}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@last@node,}% \else \forest@forthis{% \forest@nameandgo{#1#2}% @@ -4730,11 +4744,17 @@ \forestset{% create/.code={% \forest@create@node{#1}% - \forest@fornode{\forest@last@node}{\forest@node@setalias{forest@last@node}}% + \forest@fornode{\forest@last@node}{% + \forest@node@setalias{forest@last@node}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@last@node,}% + }% }, create'/.code={% \forest@create@node@and@process@given@options{#1}% - \forest@fornode{\forest@last@node}{\forest@node@setalias{forest@last@node}}% + \forest@fornode{\forest@last@node}{% + \forest@node@setalias{forest@last@node}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@last@node,}% + }% }, append/.code={\def\forest@dynamics@copyhow{0}\forest@appto@do@dynamics\forest@append@node{#1}}, prepend/.code={\def\forest@dynamics@copyhow{0}\forest@appto@do@dynamics\forest@prepend@node{#1}}, @@ -4750,6 +4770,7 @@ insert before''/.code={\def\forest@dynamics@copyhow{2}\forest@appto@do@dynamics\forest@insertbefore@node{#1}}, remove/.code={% \pgfkeysalso{alias=forest@last@node}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@cn,}% \expandafter\apptotoks\expandafter\forest@do@dynamics\expandafter{% \expandafter\forest@remove@node\expandafter{\forest@cn}}% }, @@ -4780,8 +4801,10 @@ } \def\forest@replaceby@code#1#2{%#1=node spec,#2=insert after[']['] \ifnum\forestove{@parent}=0 - \pgfkeysalso{set root={#1}}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@cn,}% + \pgfkeysalso{alias=forest@last@node,set root={#1}}% \else + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@cn,}% \pgfkeysalso{alias=forest@last@node,#2={#1}}% \eapptotoks\forest@do@dynamics{% \noexpand\ifnum\noexpand\forestOve{\forest@cn}{@parent}=\forestove{@parent} @@ -4845,6 +4868,11 @@ \def\forest@nodesort@let#1#2{% \csletcs{forest@nodesort@#1}{forest@nodesort@#2}% } +\forestset{ + define long step={last dynamic node}{style,must start at valid node=false}{% + name=forest@last@node + } +} % \end{macrocode} % % \section{Stages} @@ -4967,7 +4995,10 @@ draw tree node/.code={\forest@draw@node}, draw tree edge/.code={\forest@draw@edge}, draw tree tikz/.code={\forest@draw@tikz}, - for nodewalk={processing order/.style={tree}}{}, + draw tree node'/.code={\forest@draw@node@}, + draw tree edge'/.code={\forest@draw@edge@}, + draw tree tikz'/.code={\forest@draw@tikz@}, + processing order/.nodewalk style={tree}, %given options processing order/.style={processing order}, %before typesetting nodes processing order/.style={processing order}, %before packing processing order/.style={processing order}, @@ -5155,13 +5186,15 @@ % the parent's anchor. % \begin{macrocode} \def\forest@pack{% + \pgfsyssoftpath@getcurrentpath\forest@pack@original@path \forest@pack@computetiers \forest@pack@computegrowthuniformity \forest@@pack + \pgfsyssoftpath@setcurrentpath\forest@pack@original@path } \def\forest@@pack{% \ifnum\forestove{n children}>0 - \ifnum\forestove{uniform growth}>0 + \ifnum\forestove{uniform growth}>0 \forest@pack@level@uniform \forest@pack@aligntiers@ofsubtree \forest@pack@sibling@uniform@recursive @@ -6496,8 +6529,14 @@ \fi \fi } +\def\forest@drawtree@root{0} \def\forest@node@drawtree@{% - \forest@forthis{\forestset{draw tree method}}% + \forest@forthis{% + \forest@saveandrestoremacro\forest@drawtree@root{% + \edef\forest@drawtree@root{\forest@cn}% + \forestset{draw tree method}% + }% + }% \forest@node@Ifnamedefined{forest@baseline@node}{% \edef\forest@temp{% \noexpand\pgfsetbaselinepointlater{% @@ -6510,27 +6549,37 @@ } \def\forest@draw@node{% \ifnum\forestove{phantom}=0 - \forest@node@forest@positionnodelater@restore - \ifforest@drawtree@preservenodeboxes@ - \pgfnodealias{forest@temp}{\forestove{later@name}}% - \fi - \pgfpositionnodenow{\pgfqpoint{\forestove{x}}{\forestove{y}}}% - \ifforest@drawtree@preservenodeboxes@ - \pgfnodealias{\forestove{later@name}}{forest@temp}% - \fi + \forest@draw@node@ + \fi +} +\def\forest@draw@node@{% + \forest@node@forest@positionnodelater@restore + \ifforest@drawtree@preservenodeboxes@ + \pgfnodealias{forest@temp}{\forestove{later@name}}% + \fi + \pgfpositionnodenow{\pgfqpoint{\forestove{x}}{\forestove{y}}}% + \ifforest@drawtree@preservenodeboxes@ + \pgfnodealias{\forestove{later@name}}{forest@temp}% \fi } \def\forest@draw@edge{% - \ifnum\forest@cn=\forest@root\relax\else + \ifnum\forest@cn=\forest@drawtree@root\relax\else \ifnum\forestove{phantom}=0 \ifnum\forestOve{\forestove{@parent}}{phantom}=0 - \edef\forest@temp{\forestove{edge path}}% - \forest@temp + \forest@draw@edge@ \fi \fi \fi } +\def\forest@draw@edge@{% + \edef\forest@temp{\forestove{edge path}}\forest@temp +} \def\forest@draw@tikz{% + \ifnum\forestove{phantom}=0 + \forest@draw@tikz@ + \fi +} +\def\forest@draw@tikz@{% \forestove{tikz}% } % \end{macrocode} @@ -7827,18 +7876,23 @@ % Most of the code in this section deals with externalization. % % \begin{macrocode} -\NewDocumentEnvironment{forest}{D(){stages}}{% - \forest@defstages{#1}% +\NewDocumentEnvironment{forest}{D(){}}{% + \forest@config{#1}% \Collect@Body \forest@env }{} -\NewDocumentCommand{\Forest}{s D(){stages} m}{% - \forest@defstages{#2}% +\NewDocumentCommand{\Forest}{s D(){} m}{% + \forest@config{#2}% \IfBooleanTF{#1}{\let\forest@next\forest@env}{\let\forest@next\forest@group@env}% \forest@next{#3}% } -\def\forest@defstages#1{% - \def\forest@stages{#1}% +\def\forest@config#1{% + \def\forest@stages{stages}% + \forestset{@config/.cd,#1}% +} +\forestset{@config/.cd, + stages/.store in=\forest@stages, + .unknown/.code={\PackageError{forest}{Unknown config option for forest environment/command.}{In Forest v2.0.0 and v2.0.1, this (parenthesized) argument accepted the definition of style stages for the current forest environment/macro. Since v2.0.2, you should write "\string\begin{forest}(stages={...})...\string\end{forest}", or "\string\Forest(stages={...}){...}" instead.}} } \def\forest@group@env#1{{\forest@env{#1}}} \newif\ifforest@externalize@tree@ @@ -8029,7 +8083,7 @@ \advance\forest@node@maxid1 \forest@fornode{\the\forest@node@maxid}{% \forest@node@init - \forest@node@setname{standard node}% + \forest@node@setname@silent{standard node}% }% } \def\forest@standardnode@calibrate{% @@ -8179,7 +8233,7 @@ \forest@forestcs@anchor{#2}% } \def\forest@cs@invalidnodeerror{% - \PackageError{forest}{Attempt to refer to the invalid node by "forest cs"}% + \PackageError{forest}{Attempt to refer to the invalid node by "forest cs"}{}% } \tikzdeclarecoordinatesystem{forest}{% \forest@forthis{% diff --git a/Master/texmf-dist/tex/latex/forest/forest.sty b/Master/texmf-dist/tex/latex/forest/forest.sty index 9b7800e7c82..a1746c66751 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}[2016/02/20 v2.0.1 Drawing (linguistic) trees] +\ProvidesPackage{forest}[2016/03/04 v2.0.2 Drawing (linguistic) trees] \RequirePackage{tikz}[2013/12/13] \usetikzlibrary{shapes} @@ -84,11 +84,12 @@ \foresttikzcshacktrue \def\forest@loadlibrarieslater{} \AtEndOfPackage{\forest@loadlibrarieslater} -\NewDocumentCommand\useforestlibrary{s m}{% - \forcsvlist\useforestlibrary@{#2}% - \IfBooleanT{#1}{\forestapplylibrarydefaults{#2}}% +\NewDocumentCommand\useforestlibrary{s O{} m}{% + \def\useforestlibrary@@##1{\useforestlibrary@{#2}{##1}}% + \forcsvlist\useforestlibrary@@{#3}% + \IfBooleanT{#1}{\forestapplylibrarydefaults{#3}}% } -\def\useforestlibrary@#1{\RequirePackage{forest-lib-#1}} +\def\useforestlibrary@#1#2{\RequirePackage[#1]{forest-lib-#2}} \def\forestapplylibrarydefaults#1{\forcsvlist\forestapplylibrarydefaults@{#1}} \def\forestapplylibrarydefaults@#1{\forestset{libraries/#1/defaults/.try}} \NewDocumentCommand\ProvidesForestLibrary{m O{}}{\ProvidesPackage{forest-lib-#1}[#2]} @@ -2219,21 +2220,27 @@ \forestset{ declare toks register/.code={% \forest@declareregisterhandler\forest@declaretoksregister@handler{#1}% + \forestset{#1={}}% }, declare autowrapped toks register/.code={% \forest@declareregisterhandler\forest@declareautowrappedtoksregister@handler{#1}% + \forestset{#1={}}% }, declare keylist register/.code={% \forest@declareregisterhandler\forest@declarekeylistregister@handler{#1}% + \forestset{#1'={}}% }, declare dimen register/.code={% \forest@declareregisterhandler\forest@declaredimenregister@handler{#1}% + \forestset{#1'=0pt}% }, declare count register/.code={% \forest@declareregisterhandler\forest@declarecountregister@handler{#1}% + \forestset{#1'=0}% }, declare boolean register/.code={% \forest@declareregisterhandler\forest@declarebooleanregister@handler{#1}% + \forestset{#1=0}% }, } \forestset{ @@ -3185,6 +3192,11 @@ \fi }, } +\pgfqkeys{/handlers}{ + .nodewalk style/.code={\forest@handlers@savecurrentpath\pgfkeysalso{% + \forest@currentpath/nodewalk/\forest@currentname/.style={#1}% + }}, +} \def\forest@forstepwrapper#1#2{\forest@forthis{\forest@nodewalk{#1}{#2}}} \def\forest@util@nargs#1#2#3{% #1 = prefix (#, ##, ...), #2 = n args, #3=start; returns {#start}{#start+1}...{#start+n} \ifnum#2>0 {#1\number\numexpr#3+1}\fi @@ -4102,6 +4114,7 @@ } \let\forest@nodewalkstephandler@styletrueorfalse\forest@nodewalkstephandler@styletrue \def\forest@last@node{0} +\csdef{forest@nodewalk@saved@dynamic nodes}{} \def\forest@nodehandleby@name@nodewalk@or@bracket#1{% \ifx\pgfkeysnovalue#1% \edef\forest@last@node{\forest@node@Nametoid{forest@last@node}}% @@ -4112,6 +4125,7 @@ \def\forest@nodehandleby@nnb@checkfirst#1#2\forest@END{% \ifx[#1%] \forest@create@node{#1#2}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@last@node,}% \else \forest@forthis{% \forest@nameandgo{#1#2}% @@ -4210,11 +4224,17 @@ \forestset{% create/.code={% \forest@create@node{#1}% - \forest@fornode{\forest@last@node}{\forest@node@setalias{forest@last@node}}% + \forest@fornode{\forest@last@node}{% + \forest@node@setalias{forest@last@node}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@last@node,}% + }% }, create'/.code={% \forest@create@node@and@process@given@options{#1}% - \forest@fornode{\forest@last@node}{\forest@node@setalias{forest@last@node}}% + \forest@fornode{\forest@last@node}{% + \forest@node@setalias{forest@last@node}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@last@node,}% + }% }, append/.code={\def\forest@dynamics@copyhow{0}\forest@appto@do@dynamics\forest@append@node{#1}}, prepend/.code={\def\forest@dynamics@copyhow{0}\forest@appto@do@dynamics\forest@prepend@node{#1}}, @@ -4230,6 +4250,7 @@ insert before''/.code={\def\forest@dynamics@copyhow{2}\forest@appto@do@dynamics\forest@insertbefore@node{#1}}, remove/.code={% \pgfkeysalso{alias=forest@last@node}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@cn,}% \expandafter\apptotoks\expandafter\forest@do@dynamics\expandafter{% \expandafter\forest@remove@node\expandafter{\forest@cn}}% }, @@ -4260,8 +4281,10 @@ } \def\forest@replaceby@code#1#2{%#1=node spec,#2=insert after[']['] \ifnum\forestove{@parent}=0 - \pgfkeysalso{set root={#1}}% + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@cn,}% + \pgfkeysalso{alias=forest@last@node,set root={#1}}% \else + \cseappto{forest@nodewalk@saved@dynamic nodes}{\forest@cn,}% \pgfkeysalso{alias=forest@last@node,#2={#1}}% \eapptotoks\forest@do@dynamics{% \noexpand\ifnum\noexpand\forestOve{\forest@cn}{@parent}=\forestove{@parent} @@ -4325,6 +4348,11 @@ \def\forest@nodesort@let#1#2{% \csletcs{forest@nodesort@#1}{forest@nodesort@#2}% } +\forestset{ + define long step={last dynamic node}{style,must start at valid node=false}{% + name=forest@last@node + } +} \def\forest@root{0} %%% begin listing region: stages \forestset{ @@ -4442,7 +4470,10 @@ draw tree node/.code={\forest@draw@node}, draw tree edge/.code={\forest@draw@edge}, draw tree tikz/.code={\forest@draw@tikz}, - for nodewalk={processing order/.style={tree}}{}, + draw tree node'/.code={\forest@draw@node@}, + draw tree edge'/.code={\forest@draw@edge@}, + draw tree tikz'/.code={\forest@draw@tikz@}, + processing order/.nodewalk style={tree}, %given options processing order/.style={processing order}, %before typesetting nodes processing order/.style={processing order}, %before packing processing order/.style={processing order}, @@ -4611,13 +4642,15 @@ \fi } \def\forest@pack{% + \pgfsyssoftpath@getcurrentpath\forest@pack@original@path \forest@pack@computetiers \forest@pack@computegrowthuniformity \forest@@pack + \pgfsyssoftpath@setcurrentpath\forest@pack@original@path } \def\forest@@pack{% \ifnum\forestove{n children}>0 - \ifnum\forestove{uniform growth}>0 + \ifnum\forestove{uniform growth}>0 \forest@pack@level@uniform \forest@pack@aligntiers@ofsubtree \forest@pack@sibling@uniform@recursive @@ -5745,8 +5778,14 @@ \fi \fi } +\def\forest@drawtree@root{0} \def\forest@node@drawtree@{% - \forest@forthis{\forestset{draw tree method}}% + \forest@forthis{% + \forest@saveandrestoremacro\forest@drawtree@root{% + \edef\forest@drawtree@root{\forest@cn}% + \forestset{draw tree method}% + }% + }% \forest@node@Ifnamedefined{forest@baseline@node}{% \edef\forest@temp{% \noexpand\pgfsetbaselinepointlater{% @@ -5759,27 +5798,37 @@ } \def\forest@draw@node{% \ifnum\forestove{phantom}=0 - \forest@node@forest@positionnodelater@restore - \ifforest@drawtree@preservenodeboxes@ - \pgfnodealias{forest@temp}{\forestove{later@name}}% - \fi - \pgfpositionnodenow{\pgfqpoint{\forestove{x}}{\forestove{y}}}% - \ifforest@drawtree@preservenodeboxes@ - \pgfnodealias{\forestove{later@name}}{forest@temp}% - \fi + \forest@draw@node@ + \fi +} +\def\forest@draw@node@{% + \forest@node@forest@positionnodelater@restore + \ifforest@drawtree@preservenodeboxes@ + \pgfnodealias{forest@temp}{\forestove{later@name}}% + \fi + \pgfpositionnodenow{\pgfqpoint{\forestove{x}}{\forestove{y}}}% + \ifforest@drawtree@preservenodeboxes@ + \pgfnodealias{\forestove{later@name}}{forest@temp}% \fi } \def\forest@draw@edge{% - \ifnum\forest@cn=\forest@root\relax\else + \ifnum\forest@cn=\forest@drawtree@root\relax\else \ifnum\forestove{phantom}=0 \ifnum\forestOve{\forestove{@parent}}{phantom}=0 - \edef\forest@temp{\forestove{edge path}}% - \forest@temp + \forest@draw@edge@ \fi \fi \fi } +\def\forest@draw@edge@{% + \edef\forest@temp{\forestove{edge path}}\forest@temp +} \def\forest@draw@tikz{% + \ifnum\forestove{phantom}=0 + \forest@draw@tikz@ + \fi +} +\def\forest@draw@tikz@{% \forestove{tikz}% } \newdimen\forest@xg @@ -6579,18 +6628,23 @@ }% }% \fi -\NewDocumentEnvironment{forest}{D(){stages}}{% - \forest@defstages{#1}% +\NewDocumentEnvironment{forest}{D(){}}{% + \forest@config{#1}% \Collect@Body \forest@env }{} -\NewDocumentCommand{\Forest}{s D(){stages} m}{% - \forest@defstages{#2}% +\NewDocumentCommand{\Forest}{s D(){} m}{% + \forest@config{#2}% \IfBooleanTF{#1}{\let\forest@next\forest@env}{\let\forest@next\forest@group@env}% \forest@next{#3}% } -\def\forest@defstages#1{% - \def\forest@stages{#1}% +\def\forest@config#1{% + \def\forest@stages{stages}% + \forestset{@config/.cd,#1}% +} +\forestset{@config/.cd, + stages/.store in=\forest@stages, + .unknown/.code={\PackageError{forest}{Unknown config option for forest environment/command.}{In Forest v2.0.0 and v2.0.1, this (parenthesized) argument accepted the definition of style stages for the current forest environment/macro. Since v2.0.2, you should write "\string\begin{forest}(stages={...})...\string\end{forest}", or "\string\Forest(stages={...}){...}" instead.}} } \def\forest@group@env#1{{\forest@env{#1}}} \newif\ifforest@externalize@tree@ @@ -6756,7 +6810,7 @@ \advance\forest@node@maxid1 \forest@fornode{\the\forest@node@maxid}{% \forest@node@init - \forest@node@setname{standard node}% + \forest@node@setname@silent{standard node}% }% } \def\forest@standardnode@calibrate{% @@ -6873,7 +6927,7 @@ \forest@forestcs@anchor{#2}% } \def\forest@cs@invalidnodeerror{% - \PackageError{forest}{Attempt to refer to the invalid node by "forest cs"}% + \PackageError{forest}{Attempt to refer to the invalid node by "forest cs"}{}% } \tikzdeclarecoordinatesystem{forest}{% \forest@forthis{% -- cgit v1.2.3