| 1 |
% \iffalse meta-comment |
| 2 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 |
% forest-ext-multi.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-multi.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-multi.dtx 11668 2026-02-21 02:34:38Z cfrees $}[v0.3 \revinfo][\filebase DTX: ] |
| 36 |
\DefineFileInfoSVN[forest-ext-multi] |
| 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-multi} |
| 42 |
\begin{document} |
| 43 |
\DocInput{\filename} |
| 44 |
\end{document} |
| 45 |
%</driver> |
| 46 |
% \fi |
| 47 |
% |
| 48 |
% \title{ext.multi} |
| 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.multi{-debug} |
| 61 |
% ^^A <<< |
| 62 |
%<*sty> |
| 63 |
% \permissivelines |
| 64 |
% \begin{macrocode} |
| 65 |
\NeedsTeXFormat{LaTeX2e} |
| 66 |
%% $Id: forest-ext-multi.dtx 11668 2026-02-21 02:34:38Z cfrees $} |
| 67 |
%<!debug> \ProvidesForestLibrary{ext.multi}[2025-12-05 v0.1] |
| 68 |
%<debug> \ProvidesForestLibrary{ext.multi-debug}[2025-12-05 v0.1] |
| 69 |
% |
| 70 |
%<!debug> \disable@package@load {forest-lib-ext.multi-debug} |
| 71 |
%<debug> \disable@package@load {forest-lib-ext.multi} |
| 72 |
{% |
| 73 |
%<!debug> \PackageWarning {ext.multi (forest library)} |
| 74 |
%<debug> \PackageWarning {ext.multi-debug (forest library)} |
| 75 |
{Only one of ext.multi and ext.multi-debug should be loaded. |
| 76 |
Since the |
| 77 |
%<!debug> ext.multi |
| 78 |
%<debug> ext.multi-debug |
| 79 |
library has already been loaded, I will ignore your request for |
| 80 |
%<!debug> ext.multi-debug.% |
| 81 |
%<debug> ext.multi.% |
| 82 |
}% |
| 83 |
} |
| 84 |
% \end{macrocode} |
| 85 |
% \iffalse |
| 86 |
% ^^A Paid â defnyddio \GetFileInfoSVN*/\GetFileInfoSVN{} yn y fan hon!! |
| 87 |
% \fi |
| 88 |
% We don't want inconsistent names in hooks. |
| 89 |
% \begin{macrocode} |
| 90 |
\SetDefaultHookLabel{forest-ext/multi} |
| 91 |
\forestset{ |
| 92 |
% \end{macrocode} |
| 93 |
% Public options. |
| 94 |
% ^^A % Booleans. |
| 95 |
% ^^A % \begin{macrocode} |
| 96 |
% ^^A % \end{macrocode} |
| 97 |
% ^^A % Counts. |
| 98 |
% ^^A % \begin{macrocode} |
| 99 |
% ^^A % \end{macrocode} |
| 100 |
% \begin{fkeylist}{every parent,other parents} |
| 101 |
% Keylists. |
| 102 |
% \begin{macrocode} |
| 103 |
declare keylist={every parent}{}, |
| 104 |
declare keylist={other parents}{}, |
| 105 |
% \end{macrocode} |
| 106 |
% \end{fkeylist} |
| 107 |
% Generic toks. |
| 108 |
% \begin{macrocode} |
| 109 |
% \end{macrocode} |
| 110 |
% Internal options. |
| 111 |
% \begin{macrocode} |
| 112 |
declare boolean={multi@connector}{0}, |
| 113 |
declare count={multi@n@parents}{0}, |
| 114 |
declare count={multi@connects@fosterling}{-1}, |
| 115 |
declare count={multi@connects@foster@parent}{-1}, |
| 116 |
declare keylist={multi@foster@parents}{}, |
| 117 |
declare keylist={multi@fosterlings}{}, |
| 118 |
declare keylist={multi@all@parents}{}, |
| 119 |
declare toks={multi@edge}{}, |
| 120 |
declare toks={multi@edge@subpath}{edge}, |
| 121 |
declare toks={multi@edge@sublast}{--}, |
| 122 |
declare toks={multi@edge@route}{--}, |
| 123 |
declare toks={multi@parent@of}{}, |
| 124 |
% \end{macrocode} |
| 125 |
% \texseans[My answer:]{695602}. |
| 126 |
% \texseans{695600}[Alan Munn], which was based on my original answer. |
| 127 |
% |
| 128 |
% Public registers. |
| 129 |
% \begin{macrocode} |
| 130 |
%<debug> declare boolean register={debug multi phantoms}, |
| 131 |
%<debug> not debug multi phantoms, |
| 132 |
% \end{macrocode} |
| 133 |
% Internal scratch registers. |
| 134 |
% \begin{macrocode} |
| 135 |
declare count register={multi@temp@counta}, |
| 136 |
multi@temp@counta=0, |
| 137 |
declare toks register={multi@temp@toksa}, |
| 138 |
multi@temp@toksa={}, |
| 139 |
declare toks register={multi@temp@toksb}, |
| 140 |
multi@temp@toksb={}, |
| 141 |
% \end{macrocode} |
| 142 |
% \begin{fstep}{fosterlings,foster parents,every fosterling,every foster parent,c fosterling,c foster parent} |
| 143 |
% Convenience multi-step nodewalk steps. |
| 144 |
% \begin{macrocode} |
| 145 |
define long step={fosterlings}{}{% |
| 146 |
if multi@fosterlings={}{}{% |
| 147 |
split option={multi@fosterlings}{,}{id}% |
| 148 |
}% |
| 149 |
}, |
| 150 |
define long step={foster parents}{}{% |
| 151 |
if multi@foster@parents={}{}{% |
| 152 |
split option={multi@foster@parents}{,}{id}% |
| 153 |
}% |
| 154 |
}, |
| 155 |
define long step={every fosterling}{n args=1}{% |
| 156 |
filter={#1}{>O_=!{multi@foster@parents}{}}% |
| 157 |
}, |
| 158 |
define long step={every foster parent}{n args=1}{% |
| 159 |
filter={#1}{>O_=!{multi@fosterlings}{}}% |
| 160 |
}, |
| 161 |
define long step={c fosterling}{}{% |
| 162 |
id/.option=multi@connects@fosterling% |
| 163 |
}, |
| 164 |
define long step={c foster parent}{}{% |
| 165 |
id/.option=multi@connects@foster@parent% |
| 166 |
}, |
| 167 |
% \end{macrocode} |
| 168 |
% \end{fstep} |
| 169 |
% \begin{fstyle}{multi}% ^^A <<< |
| 170 |
% Make this node a grandchild of its current parent and insert specified parents. |
| 171 |
% \begin{macrocode} |
| 172 |
multi/.style={% |
| 173 |
%<debug> debug@multi=Execute style multi at, |
| 174 |
%<debug> debug@multi@option=id, |
| 175 |
split={#1}{,}{multi@parent}, |
| 176 |
%<debug> debug@multi@option=multi@n@parents, |
| 177 |
%<debug> debug@multi@option=multi@all@parents, |
| 178 |
before typesetting nodes={% |
| 179 |
multi@parents/.process={% |
| 180 |
OOOw |
| 181 |
{name} |
| 182 |
{multi@n@parents} |
| 183 |
{multi@all@parents} |
| 184 |
{{##1}}% |
| 185 |
}, |
| 186 |
delay n=2{% |
| 187 |
multi@edge+= {(.child anchor) }, |
| 188 |
multi@temp@counta'=0, |
| 189 |
split option={multi@all@parents}{,}{multi@also@parent}, |
| 190 |
}, |
| 191 |
delay n=3{% |
| 192 |
%<debug> debug@multi@option=id, |
| 193 |
%<debug> debug@multi@option=multi@edge, |
| 194 |
edge path'/.option=multi@edge, |
| 195 |
}, |
| 196 |
}, |
| 197 |
}, |
| 198 |
% \end{macrocode} |
| 199 |
% \end{fstyle}% ^^A >>> |
| 200 |
% \begin{fstyle}{multi@also@parent}% ^^A <<< |
| 201 |
% Auxiliary. |
| 202 |
% \begin{macrocode} |
| 203 |
multi@also@parent/.style={% |
| 204 |
%<debug> debug@multi=Execute style multi@also@parent to for #1 at, |
| 205 |
%<debug> debug@multi@option=id, |
| 206 |
multi@temp@counta'+=1, |
| 207 |
multi@edge+/.process={ |
| 208 |
OR= ? O w |
| 209 |
{multi@n@parents}{multi@temp@counta} |
| 210 |
{multi@edge@sublast}{multi@edge@subpath} |
| 211 |
{##1 (#1.parent anchor) } |
| 212 |
}, |
| 213 |
}, |
| 214 |
% \end{macrocode} |
| 215 |
% \end{fstyle}% ^^A >>> |
| 216 |
% \begin{fstyle}{multi@parent}% ^^A <<< |
| 217 |
% Insert a co-parent. |
| 218 |
% |
| 219 |
% Note \texttt{delay} required in case \texttt{name} specified by user. |
| 220 |
% \begin{macrocode} |
| 221 |
multi@parent/.style={% |
| 222 |
%<debug> debug@multi=Execute style multi@parent to add #1 at, |
| 223 |
%<debug> debug@multi@option=id, |
| 224 |
%<debug> debug@multi@option=every parent, |
| 225 |
multi@n@parents'+=1, |
| 226 |
delay/.process={Ow{multi@n@parents}{% |
| 227 |
multi@all@parents+/.process={Ow{name}{parent ##1 of ####1}}, |
| 228 |
insert before/.process={% |
| 229 |
OOw2{name}{every parent} |
| 230 |
{% |
| 231 |
[#1,name=parent ##1 of ####1,multi@parent@of=####1, |
| 232 |
####2]% |
| 233 |
}% |
| 234 |
}, |
| 235 |
}% |
| 236 |
}, |
| 237 |
}, |
| 238 |
% \end{fstyle}% ^^A >>> |
| 239 |
% \begin{fstyle}{multi@parents}% ^^A <<< |
| 240 |
% Adjust relns. |
| 241 |
% |
| 242 |
% Arguments: name, no.~parents, parents |
| 243 |
% \begin{macrocode} |
| 244 |
multi@parents/.style n args=3{% |
| 245 |
%<debug> debug@multi=Executing style multi@parents with, |
| 246 |
%<debug> debug@multi=options #1 #2 and #3, |
| 247 |
if={>nw+P{#2}{isodd(##1)}}{% |
| 248 |
multi@temp@counta/.expanded=\inteval{(#2 + 1)/2}, |
| 249 |
for nodewalk={% |
| 250 |
name/.expanded=parent \foresteregister{multi@temp@counta} of #1 % |
| 251 |
}{% |
| 252 |
append=#1, |
| 253 |
}, |
| 254 |
}{% |
| 255 |
multi@temp@counta/.expanded=\inteval{#2/2}, |
| 256 |
%<debug> debug@multi@register=multi@temp@counta, |
| 257 |
for nodewalk={% |
| 258 |
name/.expanded=parent \foresteregister{multi@temp@counta} of #1 % |
| 259 |
}{% |
| 260 |
insert after={% |
| 261 |
[,coordinate,no edge, |
| 262 |
tier=multi@tier@#1@parents, |
| 263 |
delay={% |
| 264 |
%<debug> debug@multi=Appending #1 to, |
| 265 |
%<debug> debug@multi@option=name, |
| 266 |
append=#1, |
| 267 |
}, |
| 268 |
]% |
| 269 |
}, |
| 270 |
}, |
| 271 |
}, |
| 272 |
}, |
| 273 |
% \end{macrocode} |
| 274 |
% \end{fstyle}% ^^A >>> |
| 275 |
% \begin{macrocode} |
| 276 |
% \end{macrocode} |
| 277 |
% \begin{fstyle}{multi@add@parent}% ^^A <<< |
| 278 |
% Connect an additional parent. |
| 279 |
% |
| 280 |
% Argument: id of current node; dynamic tree operation; keylist for child; id of additional parent (extant). |
| 281 |
% \begin{macrocode} |
| 282 |
multi@add@parent/.style n args=4{% |
| 283 |
%<debug> debug@multi=Execute style multi@add@parent to add #4 at, |
| 284 |
%<debug> debug@multi@option=id, |
| 285 |
%<debug> debug@multi=Arguments: #1: #2: #3: #4, |
| 286 |
%<debug> debug@multi@option=every parent, |
| 287 |
delay n=2{% |
| 288 |
for nodewalk={% |
| 289 |
id=#4% |
| 290 |
}{% |
| 291 |
multi@fosterlings+=#1, |
| 292 |
%<debug> debug@multi=dynamic action #2, |
| 293 |
%<debug> debug@multi@option=parent anchor, |
| 294 |
#2={% |
| 295 |
[, |
| 296 |
multi@phantom, |
| 297 |
multi@connector, |
| 298 |
multi@connects@fosterling=#1, |
| 299 |
multi@connects@foster@parent=#4, |
| 300 |
for current/.option=!{id=#1}.every parent, |
| 301 |
delay n=3{% |
| 302 |
do dynamics, |
| 303 |
edge path'/.process={% |
| 304 |
Ow {!{id=#1}.multi@edge@route} {% |
| 305 |
(!c fosterling.child anchor) |
| 306 |
##1 (!c foster parent.parent anchor) % |
| 307 |
}% |
| 308 |
}, |
| 309 |
also={#3}, |
| 310 |
%<debug> debug@multi@option=id, |
| 311 |
%<debug> debug@multi=edge path and edge, |
| 312 |
%<debug> typeout/.option=edge path, |
| 313 |
%<debug> debug@multi@option=edge, |
| 314 |
}, |
| 315 |
]% |
| 316 |
},% |
| 317 |
}, |
| 318 |
}, |
| 319 |
}, |
| 320 |
% \end{macrocode} |
| 321 |
% \end{fstyle}% ^^A >>> |
| 322 |
% \begin{fstyle}{also parent,+also parent,also parent+}% ^^A <<< |
| 323 |
% Make an existing node in the tree an additional parent of the current node. |
| 324 |
% What actually happens is that the specified node gets a new child with a copy of the current node's content. |
| 325 |
% However, this child is just like a \texttt{phantom}, except that it has a visible edge. |
| 326 |
% This edge can then be defined to look as if it connects the current node to the additional parent. |
| 327 |
% |
| 328 |
% Arguments: dynamic tree operation; parent:options for new node |
| 329 |
% |
| 330 |
% Why do I need to double hashes twice here? |
| 331 |
% \begin{macrocode} |
| 332 |
also parent/.style 2 args={% |
| 333 |
%<debug> debug@multi=Executing style also parent at, |
| 334 |
%<debug> debug@multi@option=id, |
| 335 |
delay={% |
| 336 |
split={#2}{:}{multi@temp@toksa,multi@temp@toksb}, |
| 337 |
%<debug> debug@multi@register=multi@temp@toksa, |
| 338 |
%<debug> debug@multi@register=multi@temp@toksb, |
| 339 |
if nodewalk valid={name/.register=multi@temp@toksa}{% |
| 340 |
multi@temp@counta/.option=!{name/.register=multi@temp@toksa}.id, |
| 341 |
}{% |
| 342 |
multi@temp@counta/.option/.process={Rw{multi@temp@toksa}{##1.id}}, |
| 343 |
}, |
| 344 |
%<debug> debug@multi@register=multi@temp@counta, |
| 345 |
multi@foster@parents+/.register=multi@temp@counta, |
| 346 |
multi@add@parent/.process={% |
| 347 |
O_RwR |
| 348 |
{id} |
| 349 |
{#1} |
| 350 |
{multi@temp@toksb} |
| 351 |
{{##1}} |
| 352 |
{multi@temp@counta}% |
| 353 |
}, |
| 354 |
}, |
| 355 |
}, |
| 356 |
+also parent/.style={% |
| 357 |
%<debug> debug@multi=Executing style +also parent at, |
| 358 |
%<debug> debug@multi@option=id, |
| 359 |
also parent={prepend}{#1}, |
| 360 |
}, |
| 361 |
also parent+/.style={% |
| 362 |
%<debug> debug@multi=Executing style also parent+ at, |
| 363 |
%<debug> debug@multi@option=id, |
| 364 |
also parent={append}{#1}, |
| 365 |
}, |
| 366 |
% \end{macrocode} |
| 367 |
% \end{fstyle}% ^^A >>> |
| 368 |
% \begin{fstyle}{}% ^^A <<< |
| 369 |
% \begin{macrocode} |
| 370 |
% \end{macrocode} |
| 371 |
% \end{fstyle}% ^^A >>> |
| 372 |
% \begin{fstyle}{multi@phantom}% ^^A <<< |
| 373 |
% Not really phantoms. |
| 374 |
% \begin{macrocode} |
| 375 |
multi@phantom/.style={ |
| 376 |
before drawing tree={% |
| 377 |
%<debug> if debug multi phantoms={% |
| 378 |
%<debug> rectangle, |
| 379 |
%<debug> if content={}{, |
| 380 |
%<debug> draw=red, |
| 381 |
%<debug> }{% |
| 382 |
%<debug> red, |
| 383 |
%<debug> }, |
| 384 |
%<debug> }{% |
| 385 |
coordinate, |
| 386 |
%<debug> }, |
| 387 |
typeset node, |
| 388 |
}, |
| 389 |
}, |
| 390 |
% \end{macrocode} |
| 391 |
% \end{fstyle}% ^^A >>> |
| 392 |
% \begin{fstyle}{add parent}% ^^A <<< |
| 393 |
% Add a new node to the tree and connect it to the current node. |
| 394 |
% \begin{macrocode} |
| 395 |
% \end{macrocode} |
| 396 |
% \end{fstyle}% ^^A >>> |
| 397 |
% \begin{fstyle}{debug@multi,debug@multi@register,debug@multi@option}% ^^A <<< |
| 398 |
% Internal styles for debugging. |
| 399 |
% Should not be used directly, but may be applied by loading the debugging code. |
| 400 |
% \begin{macrocode} |
| 401 |
%<debug> debug@multi/.code={% |
| 402 |
%<debug> \ExpandArgs {e} \typeout{[Forest ext.multi debug]:: \detokenize{#1}}% |
| 403 |
%<debug> }, |
| 404 |
%<debug> debug@multi@register/.code={% |
| 405 |
%<debug> \ExpandArgs {e} \typeout{[Forest ext.multi debug]:: \detokenize{#1} |
| 406 |
%<debug> = \foresteregister{#1}% |
| 407 |
%<debug> }% |
| 408 |
%<debug> }, |
| 409 |
%<debug> debug@multi@option/.code={% |
| 410 |
%<debug> \ExpandArgs {e} \typeout{[Forest ext.multi debug]:: \detokenize{#1} |
| 411 |
%<debug> = \foresteoption{#1}% |
| 412 |
%<debug> }% |
| 413 |
%<debug> }, |
| 414 |
% \end{macrocode} |
| 415 |
% \end{fstyle}% ^^A >>> |
| 416 |
% \begin{fstyle}{debug multi phantoms,not debug multi phantoms}% ^^A <<< |
| 417 |
% Supply a code key as substitute for the boolean if the debugging code isn't loaded. |
| 418 |
% \begin{macrocode} |
| 419 |
%<!debug> debug multi phantoms/.code={% |
| 420 |
%<!debug> \PackageWarning{forest-lib-ext.multi}{% |
| 421 |
%<!debug> You requested the style 'debug multi phantoms', |
| 422 |
%<!debug> but did not load the debugging code. |
| 423 |
%<!debug> Either load 'ext.multi-debug' instead of |
| 424 |
%<!debug> 'ext.multi' or remove this style. |
| 425 |
%<!debug> }% |
| 426 |
%<!debug> }, |
| 427 |
%<!debug> node debug multi phantoms/.code={% |
| 428 |
%<!debug> \PackageWarning{forest-lib-ext.multi}{% |
| 429 |
%<!debug> You requested the style 'not debug multi phantoms', |
| 430 |
%<!debug> but did not load the debugging code. |
| 431 |
%<!debug> Either load 'ext.multi-debug' instead of |
| 432 |
%<!debug> 'ext.multi' or remove this style. |
| 433 |
%<!debug> }% |
| 434 |
%<!debug> }, |
| 435 |
% \end{macrocode} |
| 436 |
% \end{fstyle}% ^^A >>> |
| 437 |
% We need empty defaults here so that e.g.~\pkg{ext.ling} can be loaded without \pkg{edges}, in which case the set of default is empty. |
| 438 |
% If \pkg{edges} is loaded, we overwrite this style in a hook at \texttt{begindocument}. |
| 439 |
% \begin{macrocode} |
| 440 |
%<!debug> libraries/ext.multi/defaults/.style= |
| 441 |
%<debug> libraries/ext.multi-debug/defaults/.style= |
| 442 |
{}, |
| 443 |
} |
| 444 |
% \end{macrocode} |
| 445 |
% We need conditional code in case \pkg{edges} is loaded. |
| 446 |
% \begin{macrocode} |
| 447 |
\AddToHook{begindocument}{% |
| 448 |
\IfPackageLoadedT{forest-lib-edges}{% |
| 449 |
%<!debug> \PackageInfo{forest-lib-ext.multi} |
| 450 |
%<debug> \PackageInfo{forest-lib-ext.multi-debug} |
| 451 |
{Found the edges library. Enabling support code.}% |
| 452 |
\usetikzlibrary{ext.paths.ortho}% |
| 453 |
\forestset{% |
| 454 |
% \end{macrocode} |
| 455 |
% \begin{fstyle}{multi@forked@edge}% ^^A <<< |
| 456 |
% I wish \pkg{forest} used booleans or similar a bit more extensively here so this was easier to handle (without clobbering). |
| 457 |
% \begin{macrocode} |
| 458 |
multi@forked@edge/.style={% |
| 459 |
/forest/.cd, |
| 460 |
/tikz/ext/ortho/distance/.process={Ow{fork sep}{-##1}}, |
| 461 |
every parent+={% |
| 462 |
forked edge, |
| 463 |
/tikz/ext/ortho/distance/.process={Ow{fork sep}{-##1}}, |
| 464 |
}, |
| 465 |
multi@edge@subpath={% |
| 466 |
(.child anchor) -|- |
| 467 |
}, |
| 468 |
multi@edge@sublast={% |
| 469 |
(.child anchor) -|- |
| 470 |
}, |
| 471 |
multi@edge@route={% |
| 472 |
-|- |
| 473 |
}, |
| 474 |
}, |
| 475 |
% \end{macrocode} |
| 476 |
% \end{fstyle}% ^^A >>> |
| 477 |
% Setup some (hopefully) intuitive defaults. |
| 478 |
% |
| 479 |
% A negative value for \texttt{ext/ortho/distance} is measured from the target coordinate rather than the start. |
| 480 |
% We are constructing the paths backwards in comparison with \pkg{forest}. |
| 481 |
% \texttt{0.5em} is the \pkg{forest} default. |
| 482 |
% Do \textbf{not} try passing the option value here! |
| 483 |
% \begin{macrocode} |
| 484 |
%<!debug> libraries/ext.multi/defaults/.style= |
| 485 |
%<debug> libraries/ext.multi-debug/defaults/.style= |
| 486 |
{% |
| 487 |
default preamble+={ |
| 488 |
Autoforward={fork sep}{% |
| 489 |
every parent+={% |
| 490 |
fork sep=##1, |
| 491 |
edge+={/tikz/ext/ortho/distance=-##1}, |
| 492 |
}, |
| 493 |
edge+={/tikz/ext/ortho/distance=-##1}, |
| 494 |
}, |
| 495 |
fork sep'=0.5em, |
| 496 |
forked edge'/.forward to=/forest/multi@forked@edge, |
| 497 |
}, |
| 498 |
}, |
| 499 |
% \end{macrocode} |
| 500 |
% There's no ‘hook’ mechanism for this, so there is not really a nice or robust way of doing this, I don't think. |
| 501 |
% For the \pkg{edges} library, in particular, there are, in fact, no defaults at all .... |
| 502 |
% |
| 503 |
% \begin{macrocode} |
| 504 |
libraries/edges/defaults/.append style={% |
| 505 |
%<!debug> libraries/ext.multi/defaults, |
| 506 |
%<debug> libraries/ext.multi-debug/defaults, |
| 507 |
/utils/exec={% |
| 508 |
%<!debug> \PackageInfo{forest-lib-ext.multi} |
| 509 |
%<debug> \PackageInfo{forest-lib-ext.multi-debug} |
| 510 |
{% |
| 511 |
Appending compatibility code for forked edges to default settings.% |
| 512 |
}% |
| 513 |
}, |
| 514 |
}% |
| 515 |
}% |
| 516 |
}% |
| 517 |
% \end{macrocode} |
| 518 |
% \changes{v0.2}{2026-01-21}{Try to add something if tagging. But order is wrong. I think the whole specific approach here is misguided. But the basic infrastructure I think is maybe OK. Just I don't think producing alt text for arbitrary trees is good like this. Maybe just drop the structural descriptions? And just read the node content? Or what?} |
| 519 |
% \begin{macrocode} |
| 520 |
\ifcsname l_forestext_tagging_custom_bool\endcsname |
| 521 |
%<!debug> \PackageInfo{forest-lib-ext.multi} |
| 522 |
%<debug> \PackageInfo{forest-lib-ext.multi-debug} |
| 523 |
{% |
| 524 |
Found the ext.tagging or ext.tagging-debug library. |
| 525 |
Enabling support code.% |
| 526 |
}% |
| 527 |
\forestset{% |
| 528 |
%<!debug> libraries/ext.multi/defaults/.append style= |
| 529 |
%<debug> libraries/ext.multi-debug/defaults/.append style= |
| 530 |
{% |
| 531 |
also parent/.append style={% |
| 532 |
before collating tags={% |
| 533 |
alt text+/.process={Ow{##2.content}{ also child of ####1 }}, |
| 534 |
}, |
| 535 |
}, |
| 536 |
multi/.append style={% |
| 537 |
before collating tags={% |
| 538 |
alt text+={multiple parents: }, |
| 539 |
split={#1}{,}{multi@to@alt}, |
| 540 |
}, |
| 541 |
multi@to@alt/.style={% |
| 542 |
alt text+={#1, }, |
| 543 |
}, |
| 544 |
}, |
| 545 |
}, |
| 546 |
}% |
| 547 |
\fi |
| 548 |
} |
| 549 |
% \end{macrocode} |
| 550 |
%</sty> |
| 551 |
%^^A >>> |
| 552 |
% |
| 553 |
% ^^A \Finale |
| 554 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 555 |
%^^A vim: et:tw=0:sw=2:ts=2:foldmethod=marker:fmr=<<<,>>>: |