Debian Codegraph @

texmf-dist/tex/latex/forest/forest-compat.sty

raw
1 % \CheckSum{12884}
2 % \iffalse meta-comment
3 % forest-index.dtx
4 %% `forest-compat' defines a compatibility layer of package `forest'.
5 %%
6 %% Copyright (c) 2012-2017 Saso Zivanovic
7 %% (Sa\v{s}o \v{Z}ivanovi\'{c})
8 %% [email protected]
9 %%
10 %% This work may be distributed and/or modified under the
11 %% conditions of the LaTeX Project Public License, either version 1.3
12 %% of this license or (at your option) any later version.
13 %% The latest version of this license is in
14 %%
15 %% http://www.latex-project.org/lppl.txt
16 %%
17 %% and version 1.3 or later is part of all distributions of LaTeX
18 %% version 2005/12/01 or later.
19 %%
20 %% This work has the LPPL maintenance status `author-maintained'.
21 %%
22 %% This file is a part of package `forest'. For the list of files
23 %% constituting the package see main source file of the package,
24 %% `forest.dtx', or the derived `forest.sty'.
25
26 \ProvidesPackage{forest-compat}[2016/12/31]
27
28 \def\forest@deprecated#1{%
29 \PackageWarning{forest}{Compatibility mode for #1}%
30 }
31 \forestset{@@deprecated/.code={\forest@deprecated{#1}}}
32 \def\forestcompat#1{\pgfqkeys{/forest/@compat}{#1}}
33 \def\forestcompat@patchfailed{%
34 \pgfkeys@split@path
35 \PackageError{forest}{Patching in compat=\pgfkeyscurrentname\space failed}{}%
36 }
37 \forestcompat{
38 silent/.code={\def\forest@deprecated##1{}},
39 %%% begin listing region: compat_keys
40 most/.style={1.0-most},
41 all/.style={1.0-all},
42 none/.style={},
43 1.0-harmless/.style={
44 1.0-triangle,1.0-linear,1.0-nodewalk,1.0-ancestors,
45 1.0-fittotree,1.0-for,1.0-forall,
46 },
47 1.0-most/.style={1.0-harmless,2.0.2-most},
48 1.0-all/.style={1.0-harmless,
49 1.0-forstep,1.0-rotate,1.0-stages,1.0-name,
50 2.0.2-all,
51 },
52 2.0.2-most/.style={2.0-most},
53 2.0.2-all/.style={
54 2.0.2-delayn,2.0.2-wrapnpgfmathargs,
55 2.0-all,
56 },
57 2.0-edges/.style={2.0-anchors,2.0-forkededge,2.0-folder},
58 2.0-most/.style={2.1.1-most},
59 2.0-all/.style={
60 2.0-delayn,
61 2.0-edges,
62 2.1.1-all,
63 },
64 2.1.1-most/.style={},
65 2.1.1-all/.style={2.1.1-loops},
66 %%% end listing region: compat_keys
67 1.0-triangle/.style={
68 /forest/triangle/.style={
69 @@deprecated={key "triangle" from v1.0.x. Use key "roof" from library "linguistics" instead},
70 edge path'={%
71 (.north west)--(!u.south)--(.north east)--cycle
72 }
73 }
74 },
75 1.0-linear/.style={
76 /forest/define long step={linear next}{autostep}{%
77 \forest@deprecated{nodewalk step "linear next" from v1.0. Use key "next node" instead.}%
78 \edef\forest@cn{\forest@node@linearnextid}},
79 /forest/define long step={linear previous}{autostep}{%
80 \forest@deprecated{nodewalk step "linear previous" from v1.0. Use key "previous node" instead.}%
81 \edef\forest@cn{\forest@node@linearpreviousid}},
82 },
83 1.0-nodewalk/.style={
84 /forest/node walk/before walk/.style={},
85 /forest/node walk/every step/.style={},
86 /forest/node walk/after walk/.style={},
87 /forest/node walk/.style={
88 @@deprecated={key "node walk" from v1.0. Use key "nodewalk" instead.},
89 /forest/node walk/before walk,
90 /forest/nodewalk/before walk/.style={/forest/node walk/before walk},
91 /forest/nodewalk/every step/.style={/forest/node walk/every step},
92 /forest/nodewalk/after walk/.style={/forest/node walk/after walk},
93 /forest/nodewalk/node walk/.style={before walk,for nodewalk={####1,options={/forest/nodewalk/after walk}}{/forest/nodewalk/every step}},
94 for nodewalk={##1,options={/forest/nodewalk/after walk}}{/forest/nodewalk/every step},
95 },
96 },
97 1.0-ancestors/.style={
98 /forest/for ancestors'/.style={
99 @@deprecated={key "for ancestors'" from v1.0.x. Use key "for current and ancestors" instead.},
100 for current and ancestors={##1}},
101 },
102 1.0-fittotree/.style={%
103 /tikz/fit to tree/.style={
104 /forest/@@deprecated={key "/tikz/fit to tree" from v1.0.x. Use "/tikz/fit to=tree" instead.},
105 inner sep=0pt,fit to=tree
106 }
107 },
108 1.0-for/.style={
109 /forest/for/.code 2 args={% #1 = nodewalk, #2 = after walk keylist
110 \forest@deprecated{Key "for" from v1.0.x. Use key "for group" instead.}%
111 \forest@forthis{\forest@nodewalk{##1,options={##2}}{}}%
112 }
113 },
114 1.0-forall/.style={
115 /forest/for all next/.style={
116 @@deprecated={Key "for all next" from v1.0.x. Use key "for following siblings" instead.},
117 for following siblings={##1}},
118 /forest/for all previous/.style={
119 @@deprecated={Key "for all previous" from v1.0.x. Use key "for preceding siblings" instead.},
120 for preceding siblings={##1}},
121 },
122 1.0-forstep/.code={%
123 \def\forest@forstepwrapper##1##2{%
124 \forest@forthis{%
125 \forest@configured@nodewalk{independent}{independent}{compatfake}{##1}{##2}%
126 }%
127 }%
128 \def\forest@relatednode@option@compat@ignoreinvalidsteps##1{%
129 \forest@saveandrestoremacro\forest@nodewalk@oninvalid{%
130 \def\forest@nodewalk@oninvalid{compatfake}%
131 ##1%
132 }%
133 }%
134 },
135 1.0-rotate/.style={
136 /forest/undef option=rotate,
137 rotate/.style={
138 @@deprecate={Using non-autoforwarded key "rotate". Some keys, like "forked edges" and "folder", might produce a wrong result.},
139 node options={rotate={##1}},
140 },
141 },
142 1.0-stages/.style={
143 /forest/@@deprecated={Using v1.0.x "stages" style},
144 /forest/stages/.style={
145 process keylist=before typesetting nodes,
146 typeset nodes stage,
147 process keylist=before packing,
148 pack stage,
149 process keylist=before computing xy,
150 compute xy stage,
151 process keylist=before drawing tree,
152 draw tree stage,
153 },
154 /forest/TeX={%
155 \def\forest@defstages##1{%
156 \def\forest@stages{%
157 begin forest,
158 for root'={
159 process keylist register=default preamble,
160 process keylist register=preamble
161 },
162 process keylist=given options,
163 ##1,
164 end forest
165 }%
166 }%
167 },
168 },
169 1.0-name/.code={%
170 \forest@deprecated{key "name": using key "name" from v1.0.x, which does not enforce uniqueness. If you really need this, you're doing something wrong.}%
171 \def\forest@node@setname##1{%
172 \ifstrempty{##1}{}{%
173 \forestoeset{name}{##1}%
174 \csedef{forest@id@of@##1}{\forest@cn}%
175 }%
176 }%
177 \def\forest@node@setalias##1{%
178 \ifstrempty{##1}{}{%
179 \csedef{forest@id@of@##1}{\forest@cn}%
180 }%
181 }%
182 },
183 2.0.2-delayn/.style={
184 /forest/delay@n/.style 2 args={
185 @@deprecated={propagator "delay n" (it introduces two levels of hash doubling reevaluates the first argument (the desired number of cycles) at every cycle)},
186 if={##1==1}{delay={##2}}{delay={delay@n/.wrap pgfmath arg={{####1}{##2}}{##1-1}}}
187 },
188 2.0-delayn/.style={}, % this key would patch the same thing!
189 },
190 2.0.2-wrapnpgfmathargs/.code={%
191 \def\forest@wrap@pgfmath@args@@@wrapandpasson{%
192 \forest@deprecated{handler "wrap n pgfmath args" (it introduces two levels of hash doubling)}%
193 \expandafter\expandafter\expandafter\def
194 \expandafter\expandafter\expandafter\forest@wrapped
195 \expandafter\expandafter\expandafter{%
196 \expandafter\forest@wrap@code\forest@wrap@args}%
197 \expandafter\pgfkeysalso\expandafter{\expandafter\pgfkeyscurrentpath\expandafter=\expandafter{\forest@wrapped}}%
198 }%
199 },
200 2.0-delayn/.style={
201 /forest/delay n/.style 2 args={
202 @@deprecated={propagator "delay n" (it reevaluates the first argument (the desired number of cycles) at every cycle)},
203 if={##1==0}{##2}{delay@n={##1}{##2}}
204 },
205 /forest/delay@n/.style 2 args={
206 if={##1==1}{delay={##2}}{delay={delay@n/.process={P}{##1-1}{##2}}}
207 },
208 },
209 2.0-anchors/.code={%
210 \csdef{forest@anchor@@parent'}{%
211 \forest@anchor@isbordertrue
212 \edef\forest@temp@anchor{\number\numexpr\forestove{grow}-\forestove{rotate}+180}%
213 }
214 \csdef{forest@anchor@@parent first'}{%
215 \forest@anchor@isbordertrue
216 \edef\forest@temp@anchor@parent{\number\numexpr\forestove{grow}-\forestove{rotate}+180}%
217 \edef\forest@temp@anchor@first{\number\numexpr\forestove{grow}-\forestove{rotate}\ifnum\forestove{reversed}=0 -\else+\fi90}%
218 \forest@getaverageangle{\forest@temp@anchor@parent}{\forest@temp@anchor@first}\forest@temp@anchor
219 }
220 \csdef{forest@anchor@@parent last'}{%
221 \forest@anchor@isbordertrue
222 \edef\forest@temp@anchor@parent{\number\numexpr\forestove{grow}-\forestove{rotate}+180}%
223 \edef\forest@temp@anchor@last{\number\numexpr\forestove{grow}-\forestove{rotate}\ifnum\forestove{reversed}=0 +\else-\fi90}%
224 \forest@getaverageangle{\forest@temp@anchor@parent}{\forest@temp@anchor@last}\forest@temp@anchor
225 }
226 },
227 2.0-forkededge/.code={%
228 \forest@iflibraryloaded{edges}{%
229 \forestset{
230 forked edge/.style={
231 edge={rotate/.pgfmath=grow()},
232 edge path'={(!u.parent anchor) -- ++(\forestoption{fork sep},0) |- (.child anchor)},
233 },
234 forked edges/.style={
235 for tree={parent anchor=children},
236 for descendants={child anchor=parent,forked edge}
237 },
238 }%
239 }{%
240 \appto\forest@compat@libraries@edges{\forestcompat{2.0-forkededge}}%
241 }%
242 },
243 2.0-folder/.code={%
244 \forest@iflibraryloaded{edges}{%
245 \expandafter\patchcmd\csname pgfk@/forest/folder/.@cmd\endcsname
246 {parent anchor=-children last}
247 {parent anchor=parent last}
248 {}{\forestcompat@patchfailed}%
249 \expandafter\patchcmd\csname pgfk@/forest/folder/.@cmd\endcsname
250 {edge={rotate/.option=!parent.grow},}
251 {edge={rotate/.pgfmath=grow()}}
252 {}{\forestcompat@patchfailed}%
253 }{%
254 \appto\forest@compat@libraries@edges{\forestcompat{2.0-folder}}%
255 }%
256 },
257 2.1.1-loops/.code={%
258 \patchcmd\newsafeRKloop % pre-{##1}
259 {\forest@temp@toks}%
260 {%
261 \forest@deprecated{hash-doubling loops from pre-2.1.2}%
262 \def\forest@temp
263 }%
264 {}{\forestcompat@patchfailed}%
265 \patchcmd\newsafeRKloop % post-{##1}
266 {\csedef}%
267 {\forest@temp@toks\expandafter{\forest@temp}\csedef}%
268 {}{\forestcompat@patchfailed}%
269 },
270 }
271 \expandafter\forestcompat\expandafter{\forest@compat}