| 1 |
% \iffalse meta-comment |
| 2 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 |
% forest-ext-utils.dtx |
| 4 |
% Additions and changes Copyright (C) 2025-2026 Clea F. Rees. |
| 5 |
% Code from skeleton.dtx Copyright (C) 2015-2024 Scott Pakin (see below). |
| 6 |
% |
| 7 |
% This work may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 9 |
% of this license or (at your option) any later version. |
| 10 |
% The latest version of this license is in |
| 11 |
% https://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2008-05-04 or later. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status 'muaintained'. |
| 16 |
% |
| 17 |
% The Current Maintainer of this work is Clea F. Rees. |
| 18 |
% |
| 19 |
% This work consists of all files listed in manifest.txt. |
| 20 |
% |
| 21 |
% The file forest-ext-utils.dtx is a derived work under the terms of the |
| 22 |
% LPPL. It is based on version 2.4 of skeleton.dtx which is part of |
| 23 |
% dtxtut by Scott Pakin. A copy of dtxtut, including the |
| 24 |
% unmodified version of skeleton.dtx is available from |
| 25 |
% https://www.ctan.org/pkg/dtxtut and released under the LPPL. |
| 26 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 27 |
% \fi |
| 28 |
% |
| 29 |
% \iffalse |
| 30 |
%<*driver> |
| 31 |
\RequirePackage{svn-prov} |
| 32 |
% ref. ateb Max Chernoff: https://tex.stackexchange.com/a/723294/ |
| 33 |
\def\MakePrivateLetters{\makeatletter\ExplSyntaxOn\endlinechar13} |
| 34 |
\ExplSyntaxOff |
| 35 |
\ProvidesFileSVN{$Id: forest-ext-utils.dtx 11668 2026-02-21 02:34:38Z cfrees $}[v0.3 \revinfo][\filebase DTX: ] |
| 36 |
\DefineFileInfoSVN[forest-ext-utils] |
| 37 |
\documentclass[11pt,british]{ltxdoc} |
| 38 |
% ^^A l3doc, minted both load fancyvrb |
| 39 |
% ^^A fancyvrb overwrites svn-prov's macros without warning |
| 40 |
% ^^A restore \fileversion \filerev in case we're using something troublesome |
| 41 |
\GetFileInfoSVN{forest-ext-utils} |
| 42 |
\begin{document} |
| 43 |
\DocInput{\filename} |
| 44 |
\end{document} |
| 45 |
%</driver> |
| 46 |
% \fi |
| 47 |
% |
| 48 |
% \title{ext.utils} |
| 49 |
% \author{Clea F. Rees\thanks{% |
| 50 |
% Bug tracker: |
| 51 |
% \href{https://codeberg.org/cfr/prooftrees/issues}{\url{codeberg.org/cfr/prooftrees/issues}} |
| 52 |
% \textbar{} Code: |
| 53 |
% \href{https://codeberg.org/cfr/prooftrees}{\url{codeberg.org/cfr/prooftrees}} |
| 54 |
% % \textbar{} Mirror: |
| 55 |
% % \href{https://github.com/cfr42/prooftrees}{\url{github.com/cfr42/prooftrees}}% |
| 56 |
% }} |
| 57 |
% \date{\forestextdocdate} |
| 58 |
% \maketitle |
| 59 |
% |
| 60 |
% ^^A forest-lib-ext.utils{-debug} |
| 61 |
% ^^A <<< |
| 62 |
%<*sty> |
| 63 |
%<@@=forestext> |
| 64 |
% \permissivelines |
| 65 |
% \begin{macrocode} |
| 66 |
\NeedsTeXFormat{LaTeX2e} |
| 67 |
%% $Id: forest-ext-utils.dtx 11668 2026-02-21 02:34:38Z cfrees $} |
| 68 |
%<!debug> \ProvidesForestLibrary{ext.utils}[2025-12-05 v0.1] |
| 69 |
%<debug> \ProvidesForestLibrary{ext.utils-debug}[2025-12-05 v0.1] |
| 70 |
% |
| 71 |
%<!debug> \disable@package@load {forest-lib-ext.utils-debug} |
| 72 |
%<debug> \disable@package@load {forest-lib-ext.utils} |
| 73 |
{% |
| 74 |
%<!debug> \PackageWarning {ext.utils (forest library)} |
| 75 |
%<debug> \PackageWarning {ext.utils-debug (forest library)} |
| 76 |
{Only one of ext.utils and ext.utils-debug should be loaded. |
| 77 |
Since the |
| 78 |
%<!debug> ext.utils |
| 79 |
%<debug> ext.utils-debug |
| 80 |
library has already been loaded, I will ignore your request for |
| 81 |
%<!debug> ext.utils-debug.% |
| 82 |
%<debug> ext.utils.% |
| 83 |
}% |
| 84 |
} |
| 85 |
% \end{macrocode} |
| 86 |
% We don't want inconsistent names in hooks. |
| 87 |
% \begin{macrocode} |
| 88 |
\SetDefaultHookLabel{forest-ext/utils} |
| 89 |
% \end{macrocode} |
| 90 |
% \iffalse |
| 91 |
% ^^A Paid â defnyddio \GetFileInfoSVN*/\GetFileInfoSVN{} yn y fan hon!! |
| 92 |
% \fi |
| 93 |
% \subsection{Toks etc.}\label{subsec:imp-toks} |
| 94 |
% ^^A <<< toks |
| 95 |
% Only used if other stuff isn't loaded. |
| 96 |
% \begin{macrocode} |
| 97 |
\ExplSyntaxOn |
| 98 |
% \end{macrocode} |
| 99 |
% \begin{macro}{\forestext@toksapp} |
| 100 |
% Avoid standard name in case the user loads code which defines the macro after loading our package. |
| 101 |
% \begin{macrocode} |
| 102 |
\cs_new:Npn \forestext@toksapp#1#2{#1\expandafter{\the #1#2}} |
| 103 |
\@ifpackageloaded{memoize} |
| 104 |
{}{ |
| 105 |
\newif\ifmemoizing\memoizingfalse |
| 106 |
} |
| 107 |
% \end{macrocode} |
| 108 |
% \end{macro} |
| 109 |
% \begin{macro}{\socket_get_plug:nN} |
| 110 |
% See \url{https://github.com/latex3/latex2e/issues/1851#issuecomment-3566374363}. |
| 111 |
% I don't know the implementation status of Ulrike Fischer's suggestion. |
| 112 |
% \begin{macrocode} |
| 113 |
\cs_if_free:NT \socket_get_plug:nN |
| 114 |
{ |
| 115 |
\cs_new_protected_nopar:Npn \socket_get_plug:nN #1#2 |
| 116 |
{ |
| 117 |
\str_set_eq:cN { l__socket_#1_plug_str } #2 |
| 118 |
} |
| 119 |
} |
| 120 |
% \end{macrocode} |
| 121 |
% \end{macro} |
| 122 |
% ^^A >>> toks |
| 123 |
% |
| 124 |
% \subsection{‘Tagging keylists’}\label{subsec:imp-tagging-keylists} |
| 125 |
% ^^A <<< tagging keylists |
| 126 |
% A bit like \pkg{expl3} property lists outside \env{forest} environments; just like \pkg{forest} \emph{keylist options} inside them. |
| 127 |
% |
| 128 |
% Mostly intended for tagging, but possibly useful in some other context so here. |
| 129 |
% Sylwad jps: \url{https://chat.stackexchange.com/transcript/message/68670752#68670752}. |
| 130 |
% \begin{macrocode} |
| 131 |
\ExplSyntaxOn |
| 132 |
\tl_new:N \l_@@_tmpa_tl |
| 133 |
\prop_new:N \l_@@_tmpa_prop |
| 134 |
\seq_new:N \l_@@_tmpa_seq |
| 135 |
% \end{macrocode} |
| 136 |
% \begin{macro}{\@@_fkeylist_declare:nn}% ^^A <<< |
| 137 |
% Wrapper. |
| 138 |
% \begin{macrocode} |
| 139 |
\cs_new_protected_nopar:Npn \@@_fkeylist_declare:nn #1#2 |
| 140 |
{ |
| 141 |
%<debug> \typeout{[Forest~ext.utils~debug]::~Declare~#1~with~#2.} |
| 142 |
\prop_new:c {l_@@_#1_prop} |
| 143 |
\@@_fkeylist_put_from_keyval:nn {#1}{#2} |
| 144 |
%<debug> \@@_fkeylist_log:n {#1} |
| 145 |
} |
| 146 |
% \end{macrocode} |
| 147 |
% \end{macro}% ^^A >>> |
| 148 |
% \begin{macro}{\@@_fkeylist_redeclare:nn}% ^^A <<< |
| 149 |
% This one is the point, after all. |
| 150 |
% That is, it is here that \pkg{forest} \autocite{saso-forest} seems to lack capacity (as far as I can tell). |
| 151 |
% \begin{macrocode} |
| 152 |
\cs_new_protected_nopar:Npn \@@_fkeylist_redeclare:nn #1#2 |
| 153 |
{ |
| 154 |
%<debug> \typeout{[Forest~ext.utils~debug]::~Redeclare~#1~with~#2.} |
| 155 |
\prop_clear:c {l_@@_#1_prop} |
| 156 |
\@@_fkeylist_put_from_keyval:nn {#1} {#2} |
| 157 |
%<debug> \@@_fkeylist_log:n {#1} |
| 158 |
} |
| 159 |
% \end{macrocode} |
| 160 |
% \end{macro}% ^^A >>> |
| 161 |
% \begin{macro}{\@@_fkeylist_put_from_keyval:nn}% ^^A <<< |
| 162 |
% This is ugly as sin, but \pkg{l3prop} does not like keys without values. |
| 163 |
% |
| 164 |
% jps: <- ‘we'll need two steps of full expansion’ |
| 165 |
% I don't understand this at all. |
| 166 |
% |
| 167 |
% jps: \url{https://chat.stackexchange.com/transcript/message/68672267#68672267} |
| 168 |
% ‘\verb|\exp_args:Nne \prop_set_from_keyval:ce| will in combination expand the entire thing two times inside an e-argument, hence two steps of full expansion. |
| 169 |
% It's necessary because \verb|\keyval_parse:nnn| returns its result inside \verb|\exp_not:n|, but we want to also expand all the auxiliary functions, hence two steps.’ |
| 170 |
% \begin{macrocode} |
| 171 |
\cs_new_protected_nopar:Npn \@@_fkeylist_put_from_keyval:nn #1#2 |
| 172 |
{ |
| 173 |
%<debug> \typeout{[Forest~ext.utils~debug]::~Processing~#2~for~#1.} |
| 174 |
\exp_args:Nne \prop_put_from_keyval:ce {l_@@_#1_prop} |
| 175 |
{ |
| 176 |
\keyval_parse:NNn |
| 177 |
\@@_fkeylist_put_from_keyval_aux:n |
| 178 |
\@@_fkeylist_put_from_keyval_aux:nn |
| 179 |
{#2} |
| 180 |
} |
| 181 |
} |
| 182 |
% \end{macrocode} |
| 183 |
% \end{macro}% ^^A >>> |
| 184 |
% \begin{macro}{% |
| 185 |
% \@@_fkeylist_put_from_keyval_aux:n, |
| 186 |
% \@@_fkeylist_put_from_keyval_aux:nn% |
| 187 |
% }% ^^A <<< |
| 188 |
% jps. |
| 189 |
% I would never have thought to do it this way? |
| 190 |
% \begin{macrocode} |
| 191 |
\cs_new_nopar:Npn \@@_fkeylist_put_from_keyval_aux:n #1 |
| 192 |
{ |
| 193 |
% ^^A paid â wneud hwn! |
| 194 |
% ^^A %<debug> \typeout{[Forest~ext.utils~debug]::~Setting~keyval~#1.} |
| 195 |
\@@_fkeylist_put_from_keyval_aux:nn {#1} {\q_no_value} |
| 196 |
} |
| 197 |
\cs_new_nopar:Npn \@@_fkeylist_put_from_keyval_aux:nn #1#2 |
| 198 |
{ |
| 199 |
% ^^A paid â wneud hwn! |
| 200 |
% ^^A %<debug> \typeout{[Forest~ext.utils~debug]::~Setting~keyval~#1 = #2.} |
| 201 |
\exp_not:n { {#1} = {#2} }, |
| 202 |
} |
| 203 |
% \end{macrocode} |
| 204 |
% \end{macro}% ^^A >>> |
| 205 |
% \begin{macro}{\@@_fkeylist_to_keyval:n}% ^^A <<< |
| 206 |
% Wrapper. |
| 207 |
% \begin{macrocode} |
| 208 |
\cs_new_nopar:Npn \@@_fkeylist_to_keyval:n #1 |
| 209 |
{ |
| 210 |
% ^^A paid â wneud hwn. |
| 211 |
% ^^A \prop_to_keyval:c {l_@@_#1_prop} |
| 212 |
\prop_map_function:cN {l_@@_#1_prop} \@@_fkeylist_to_keyval_aux:nn |
| 213 |
% ^^A paid â wneud hwn. |
| 214 |
% ^^A %<debug> \@@_fkeylist_log:n {#1} |
| 215 |
} |
| 216 |
% \end{macrocode} |
| 217 |
% \end{macro}% ^^A >>> |
| 218 |
% \begin{macro}{\@@_fkeylist_to_keyval_aux:nn}% ^^A <<< |
| 219 |
% Ugly as sin in reverse. |
| 220 |
% \begin{macrocode} |
| 221 |
\cs_new_nopar:Npn \@@_fkeylist_to_keyval_aux:nn #1#2 |
| 222 |
{ |
| 223 |
% ^^A \str_if_eq:nnTF {\q_no_value} {#2} |
| 224 |
\quark_if_no_value:nTF {#2} |
| 225 |
{\exp_not:n{#1},}{\exp_not:n{#1}=\exp_not:n{{#2}},} |
| 226 |
} |
| 227 |
% \end{macrocode} |
| 228 |
% \end{macro}% ^^A >>> |
| 229 |
% \begin{macro}{\@@_fkeylist_put:nn}% ^^A <<< |
| 230 |
% Wrapper. |
| 231 |
% \begin{macrocode} |
| 232 |
\cs_new_protected_nopar:Npn \@@_fkeylist_put:nn #1#2 |
| 233 |
{ |
| 234 |
\@@_fkeylist_put_from_keyval:nn {#1} {#2} |
| 235 |
%<debug> \@@_fkeylist_log:n {#1} |
| 236 |
} |
| 237 |
% \end{macrocode} |
| 238 |
% \end{macro}% ^^A >>> |
| 239 |
% \begin{macro}{\@@_fkeylist_remove:nn}% ^^ <<< |
| 240 |
% Unconditionally remove a key. |
| 241 |
% \begin{macrocode} |
| 242 |
\cs_new_protected_nopar:Npn \@@_fkeylist_remove:nn #1#2 |
| 243 |
{ |
| 244 |
\prop_remove:cn {l_@@_#1_prop} {#2} |
| 245 |
%<debug> \@@_fkeylist_log:n {#1} |
| 246 |
} |
| 247 |
% \end{macrocode} |
| 248 |
% \end{macro}% ^^A >>> |
| 249 |
% \begin{macro}{\@@_fkeylist_remove_if_match:nn}% ^^A <<< |
| 250 |
% Conditional removal. |
| 251 |
% \begin{macrocode} |
| 252 |
\cs_new_protected_nopar:Npn \@@_fkeylist_remove_if_match:nn #1#2 |
| 253 |
{ |
| 254 |
%<debug> \typeout{[Forest~ext.utils~debug]::~Remove~#2~from~#1~if~value~match.} |
| 255 |
\prop_set_eq:Nc \l_@@_tmpa_prop {l_@@_#1_prop} |
| 256 |
\keyval_parse:NNn |
| 257 |
\@@_fkeylist_remove_from_keyval_aux:n |
| 258 |
\@@_fkeylist_remove_from_keyval_aux:nn |
| 259 |
{#2} |
| 260 |
\prop_set_eq:cN {l_@@_#1_prop} \l_@@_tmpa_prop |
| 261 |
%<debug> \@@_fkeylist_log:n {#1} |
| 262 |
} |
| 263 |
% \end{macrocode} |
| 264 |
% \end{macro}% ^^A >>> |
| 265 |
% \begin{macro}{% |
| 266 |
% \@@_fkeylist_remove_from_keyval_aux:n, |
| 267 |
% \@@_fkeylist_remove_from_keyval_aux:nn% |
| 268 |
% }% ^^A <<< |
| 269 |
% Auxiliaries. |
| 270 |
% \begin{macrocode} |
| 271 |
\cs_new_protected_nopar:Npn \@@_fkeylist_remove_from_keyval_aux:n #1 |
| 272 |
{ |
| 273 |
\@@_fkeylist_remove_from_keyval_aux:nn {#1} {\q_no_value} |
| 274 |
} |
| 275 |
\cs_new_protected_nopar:Npn \@@_fkeylist_remove_from_keyval_aux:nn #1#2 |
| 276 |
{ |
| 277 |
%<debug> \typeout{[Forest~ext.utils~debug]::~Remove~#1~if~value~is~#2.} |
| 278 |
\prop_get:NnN \l_@@_tmpa_prop {#1} \l_@@_tmpa_tl |
| 279 |
\tl_if_eq:NnT \l_@@_tmpa_tl {#2} |
| 280 |
{ |
| 281 |
\prop_remove:Nn \l_@@_tmpa_prop {#1} |
| 282 |
} |
| 283 |
} |
| 284 |
% \end{macrocode} |
| 285 |
% \end{macro}% ^^A >>> |
| 286 |
% \begin{macro}{% ^^A <<< 2e aliases |
| 287 |
% \forestext@keylist@declare, |
| 288 |
% \forestext@prop@to@keylist, |
| 289 |
% \forestext@keylist@put, |
| 290 |
% \forestext@keylist@remove@key, |
| 291 |
% \forestext@keylist@remove, |
| 292 |
% \forestext@keylist@redeclare |
| 293 |
% } |
| 294 |
% 2e aliases. |
| 295 |
% \begin{macrocode} |
| 296 |
\cs_new_eq:NN \forestext@keylist@declare \@@_fkeylist_declare:nn |
| 297 |
\cs_new_eq:NN \forestext@prop@to@keylist \@@_fkeylist_to_keyval:n |
| 298 |
\cs_new_eq:NN \forestext@keylist@put \@@_fkeylist_put:nn |
| 299 |
\cs_new_eq:NN \forestext@keylist@remove@key \@@_fkeylist_remove:nn |
| 300 |
\cs_new_eq:NN \forestext@keylist@remove \@@_fkeylist_remove_if_match:nn |
| 301 |
\cs_new_eq:NN \forestext@keylist@redeclare \@@_fkeylist_redeclare:nn |
| 302 |
% \end{macrocode} |
| 303 |
% \end{macro}% ^^A >>> |
| 304 |
% \begin{macro}{\@@_fkeylist_protected_show:n,\forestext@keylist@log}% ^^A <<< |
| 305 |
% \begin{macrocode} |
| 306 |
%<debug> \cs_new_nopar:Npn \@@_fkeylist_log:n #1 |
| 307 |
%<debug> { |
| 308 |
%<debug> \typeout{[tagforext~debug]::~ #1:~} |
| 309 |
%<debug> \prop_log:c {l_@@_#1_prop} |
| 310 |
%<debug> \expandafter\typeout{\the\forestext@toksa} |
| 311 |
%<debug> } |
| 312 |
%<debug> \cs_new_eq:NN \forestext@keylist@log \@@_fkeylist_log:n |
| 313 |
% \end{macrocode} |
| 314 |
% \end{macro}% ^^A >>> |
| 315 |
% \begin{macrocode} |
| 316 |
\cs_generate_variant:Nn \prop_to_keyval:N {c} |
| 317 |
\cs_generate_variant:Nn \prop_put_from_keyval:Nn {ce} |
| 318 |
\ExplSyntaxOff |
| 319 |
\newtoks\forestext@toksa |
| 320 |
% \end{macrocode} |
| 321 |
% Avoid using a hook. |
| 322 |
% \begin{macrocode} |
| 323 |
\forestset{% |
| 324 |
% \end{macrocode} |
| 325 |
% \begin{fstyle}{forestext~utils~debug} |
| 326 |
% Debugging. |
| 327 |
% \begin{macrocode} |
| 328 |
forestext utils debug/.style={% |
| 329 |
typeout={[Forest ext.utils debug]:: #1}, |
| 330 |
}, |
| 331 |
% \end{macrocode} |
| 332 |
% \end{fstyle} |
| 333 |
% \begin{fcodekey}{declare~tagging~keylist,redeclare~tagging~keylist} |
| 334 |
% Wrappers for primary functionality of these bits. |
| 335 |
% \begin{macrocode} |
| 336 |
declare tagging keylist/.code 2 args={% |
| 337 |
%<debug> \typeout{[Forest ext.utils debug]:: Declaring tagging keylist #1}% |
| 338 |
%<debug> \typeout{[Forest ext.utils debug]:: with default #2.}% |
| 339 |
\forestext@keylist@declare {#1}{#2}% |
| 340 |
%<debug> \forestext@keylist@log{#1}% |
| 341 |
\forestext@toksapp\forestext@toksa{% |
| 342 |
declare keylist/.process={_x{#1}{\forestext@prop@to@keylist{#1}}}, |
| 343 |
}% |
| 344 |
%<debug> \typeout{[Forest ext.utils debug]:: forestext@toksa:}% |
| 345 |
%<debug> \expandafter\typeout{\the\forestext@toksa}% |
| 346 |
\pgfqkeys{/forest}{% |
| 347 |
forestext utils debug={Setting processing order for #1 to unique=tree.}, |
| 348 |
#1 processing order/.nodewalk style={unique=tree}, |
| 349 |
}% |
| 350 |
}, |
| 351 |
redeclare tagging keylist/.code 2 args={% |
| 352 |
%<debug> \typeout{[Forest ext.utils debug]:: Redeclaring tagging keylist #1}% |
| 353 |
%<debug> \typeout{[Forest ext.utils debug]:: with default #2.}% |
| 354 |
\forestext@keylist@redeclare {#1}{#2}% |
| 355 |
%<debug> \forestext@keylist@log{#1}% |
| 356 |
}, |
| 357 |
% \end{macrocode} |
| 358 |
% \end{fcodekey} |
| 359 |
% \begin{fcodekey}{% |
| 360 |
% tagging~keylist~put, |
| 361 |
% tagging~keylist~remove~key, |
| 362 |
% tagging~keylist~remove% |
| 363 |
% } |
| 364 |
% Wrappers for manipulating these keylists. |
| 365 |
% \begin{macrocode} |
| 366 |
tagging keylist put/.code 2 args={% |
| 367 |
\forestext@keylist@put {#1}{#2}% |
| 368 |
}, |
| 369 |
tagging keylist remove key/.code 2 args={% |
| 370 |
\forestext@keylist@remove@key {#1}{#2}% |
| 371 |
}, |
| 372 |
tagging keylist remove/.code 2 args={% |
| 373 |
\forestext@keylist@remove {#1}{#2}% |
| 374 |
}, |
| 375 |
% \end{macrocode} |
| 376 |
% \end{fcodekey} |
| 377 |
% \begin{macrocode} |
| 378 |
} |
| 379 |
% \end{macrocode} |
| 380 |
% Declare ‘tagging keylist’ options so we get defaults applied to nodes. |
| 381 |
% Then zap all the user-facing keys used to manipulate them. |
| 382 |
% |
| 383 |
% We want this to happen really early, but we do need the group or there's no point. |
| 384 |
% |
| 385 |
% \changes{v0.2}{2026-01-18}{Go back to using env begin hook as it won't work with command form anyhow (and just have prooftrees invoke the hook manually as it does anyhow.} |
| 386 |
% \begin{macrocode} |
| 387 |
\AddToHook{env/forest/begin}[.]{% |
| 388 |
%<debug> \typeout{[Forest ext.utils debug]:: Creating options set with declare tagging keylist.}% |
| 389 |
%<debug> \expandafter\typeout{\the\forestext@toksa}% |
| 390 |
\expandafter\forestset\expandafter{\the\forestext@toksa}% |
| 391 |
\forestset{% |
| 392 |
tagging keylist error/.code={% |
| 393 |
\PackageError{ext.tagging (forest library)}{% |
| 394 |
The key '#1' cannot be used inside a forest environment.% |
| 395 |
}{% |
| 396 |
You need to use this key outside forest environments. |
| 397 |
Please see forest-ext's documentation for details.% |
| 398 |
}% |
| 399 |
}, |
| 400 |
declare tagging keylist/.style 2 args={% |
| 401 |
tagging keylist error=declare tagging keylist}, |
| 402 |
redeclare tagging keylist/.style 2 args={% |
| 403 |
tagging keylist error=redeclare tagging keylist}, |
| 404 |
tagging keylist put/.style 2 args={% |
| 405 |
tagging keylist error=tagging keylist put}, |
| 406 |
tagging keylist remove/.style 2 args={% |
| 407 |
tagging keylist error=tagging keylist remove}, |
| 408 |
tagging keylist remove key/.style 2 args={% |
| 409 |
tagging keylist error=tagging keylist remove key}, |
| 410 |
}% |
| 411 |
} |
| 412 |
% \end{macrocode} |
| 413 |
% Attempt to accommodate command form(s). |
| 414 |
% We want the hook code to be used inside the group, if there is one, so \cs{forest@config} looks the obvious place to hook before (and would work for the environment, too, but it's internal \dots. |
| 415 |
% |
| 416 |
% The ending is rather less obvious \dots. |
| 417 |
% |
| 418 |
% Probably this should be a macro so we don't run any other code chunks added here? |
| 419 |
% It would be good, too, if we had a check, I guess. |
| 420 |
% That's true for prooftrees, too, but seems less of a risk? (Maybe?) |
| 421 |
% \begin{macrocode} |
| 422 |
\AddToHook{cmd/Forest/before}[.]{% |
| 423 |
\AddToHookNext{cmd/forest@config/before}{% |
| 424 |
\UseHook{env/forest/begin}% |
| 425 |
}% |
| 426 |
\AddToHookNext{cmd/forest@node@drawtree/after}{% |
| 427 |
\UseHook{env/forest/end}% |
| 428 |
}% |
| 429 |
} |
| 430 |
% \end{macrocode} |
| 431 |
% ^^A >>> end tagging keylists |
| 432 |
% |
| 433 |
% \subsection{Styles}\label{subsec:imp-styles} |
| 434 |
% ^^A <<< styles |
| 435 |
% \begin{macrocode} |
| 436 |
\forestset{ |
| 437 |
% \end{macrocode} |
| 438 |
% \begin{fstyle}{align~middle~child,align~middle~children} |
| 439 |
% \texseans{436985} \texseqn{436881}[A. D] |
| 440 |
% \begin{macrocode} |
| 441 |
align middle child/.style={ |
| 442 |
before typesetting nodes={ |
| 443 |
if={ |
| 444 |
> Ow+P {n children}{isodd(##1)} |
| 445 |
}{ |
| 446 |
calign child/.process={ |
| 447 |
Ow+n {n children}{(##1+1)/2} |
| 448 |
}, |
| 449 |
calign=#1, |
| 450 |
}{}, |
| 451 |
}, |
| 452 |
}, |
| 453 |
align middle child/.default=child edge, |
| 454 |
align middle children/.style={ |
| 455 |
for tree={align middle child=#1}, |
| 456 |
}, |
| 457 |
align middle children/.default=child edge, |
| 458 |
% \end{macrocode} |
| 459 |
% \end{fstyle} |
| 460 |
% \begin{fkeylist}{utils@outer@label@opts} |
| 461 |
% Options. |
| 462 |
% \begin{macrocode} |
| 463 |
declare keylist={utils@outer@label@opts}{}, |
| 464 |
% \end{macrocode} |
| 465 |
% \end{fkeylist} |
| 466 |
% \begin{fkeylistr}{outer~labels} |
| 467 |
% Keys applied to all outer labels. |
| 468 |
% \begin{macrocode} |
| 469 |
declare keylist register={outer labels}, |
| 470 |
outer labels={anchor=base west}, |
| 471 |
% \end{macrocode} |
| 472 |
% \end{fkeylistr} |
| 473 |
% \begin{booleanr}{utils@has@outer@labels} |
| 474 |
% Boolean. |
| 475 |
% \begin{macrocode} |
| 476 |
declare boolean register=utils@has@outer@labels, |
| 477 |
utils@has@outer@labels=0, |
| 478 |
% \end{macrocode} |
| 479 |
% \end{booleanr} |
| 480 |
% \begin{ftoksr}{outer~labels~at} |
| 481 |
% Anchor. |
| 482 |
% \begin{macrocode} |
| 483 |
declare toks register=outer labels at, |
| 484 |
outer labels at=east, |
| 485 |
% \end{macrocode} |
| 486 |
% \end{ftoksr} |
| 487 |
% \begin{autotoks}{utils@outer@label} |
| 488 |
% Label. |
| 489 |
% \begin{macrocode} |
| 490 |
declare autowrapped toks={utils@outer@label}{}, |
| 491 |
% \end{macrocode} |
| 492 |
% \end{autotoks} |
| 493 |
% \begin{macrocode} |
| 494 |
/forest/ext/utils/outer@label/anchor/.initial=base, |
| 495 |
/forest/ext/utils/outer@label/anchor/.forward to=/tikz/anchor, |
| 496 |
/forest/ext/utils/outer@label/.search also={/tikz,/pgf}, |
| 497 |
% \end{macrocode} |
| 498 |
% \begin{fstyle}{outer~label} |
| 499 |
% Args: options, content |
| 500 |
% \begin{macrocode} |
| 501 |
outer label/.style={% |
| 502 |
split={#1}{:}{utils@outer@label,utils@outer@label@opts}, |
| 503 |
if utils@has@outer@labels={}{% |
| 504 |
utils@has@outer@labels, |
| 505 |
for root={% |
| 506 |
tikz+={% |
| 507 |
\coordinate (utils@outer@labels@align) at |
| 508 |
(current bounding box.\foresteregister{outer labels at}); |
| 509 |
}, |
| 510 |
before drawing tree={% |
| 511 |
where utils@outer@label={}{}{% |
| 512 |
tikz+/.process={% |
| 513 |
OOORw4 |
| 514 |
{utils@outer@label} |
| 515 |
{utils@outer@label@opts} |
| 516 |
{!u.grow} |
| 517 |
{outer labels} |
| 518 |
{% |
| 519 |
\path [% |
| 520 |
rotate=##3, |
| 521 |
] node [% |
| 522 |
##4, |
| 523 |
/forest/ext/utils/outer@label/.cd, |
| 524 |
##2, |
| 525 |
] at (.\pgfkeysvalueof{/forest/ext/utils/outer@label/anchor} |
| 526 |
|- utils@outer@labels@align) |
| 527 |
{##1}; |
| 528 |
}% |
| 529 |
}, |
| 530 |
}, |
| 531 |
}, |
| 532 |
}, |
| 533 |
}, |
| 534 |
}, |
| 535 |
% \end{macrocode} |
| 536 |
% \end{fstyle} |
| 537 |
% ^^A >>> styles |
| 538 |
% \begin{macrocode} |
| 539 |
%<!debug> libraries/ext.utils/defaults/.style= |
| 540 |
%<debug> libraries/ext.utils-debug/defaults/.style= |
| 541 |
{}% |
| 542 |
} |
| 543 |
% \end{macrocode} |
| 544 |
%</sty> |
| 545 |
%^^A >>> |
| 546 |
% |
| 547 |
% ^^A \Finale |
| 548 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 549 |
%^^A vim: et:tw=0:sw=2:ts=2:foldmethod=marker:fmr=<<<,>>>: |