Debian Codegraph @

texmf-dist/source/latex/forest-ext/forest-ext-ling.dtx

raw
1 % \iffalse meta-comment
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % forest-ext-ling.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-ling.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-ling.dtx 11668 2026-02-21 02:34:38Z cfrees $}[v0.3 \revinfo][\filebase DTX: ]
36 \DefineFileInfoSVN[forest-ext-ling]
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-ling}
42 \begin{document}
43 \DocInput{\filename}
44 \end{document}
45 %</driver>
46 % \fi
47 %
48 % \title{ext.ling}
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.ling{-debug}
61 % ^^A <<<
62 %<*sty>
63 % \permissivelines
64 % \begin{macrocode}
65 \NeedsTeXFormat{LaTeX2e}
66 %% $Id: forest-ext-ling.dtx 11668 2026-02-21 02:34:38Z cfrees $}
67 %<!debug> \ProvidesForestLibrary{ext.ling}[2025-12-05 v0.1]
68 %<debug> \ProvidesForestLibrary{ext.ling-debug}[2025-12-05 v0.1]
69 %
70 %<!debug> \disable@package@load {forest-lib-ext.ling-debug}
71 %<debug> \disable@package@load {forest-lib-ext.ling}
72 {%
73 %<!debug> \PackageWarning {ext.ling (forest library)}
74 %<debug> \PackageWarning {ext.ling-debug (forest library)}
75 {Only one of ext.ling and ext.ling-debug should be loaded.
76 Since the
77 %<!debug> ext.ling
78 %<debug> ext.ling-debug
79 library has already been loaded, I will ignore your request for
80 %<!debug> ext.ling-debug.%
81 %<debug> ext.ling.%
82 }%
83 }
84 % \end{macrocode}
85 %<*debug>
86 % ^^A Paid รข defnyddio \GetFileInfoSVN*/\GetFileInfoSVN{} yn y fan hon!!
87 % ^^A multidom <<<
88 % \begin{drop}
89 % \begin{macrocode}
90 %<!debug> \useforestlibrary{ext.multi}
91 %<debug> \useforestlibrary{ext.multi-debug}
92 \forestset{
93 % \end{macrocode}
94 % \texseans[My answer:]{695602}.
95 % \texseans{695600}[Alan Munn], which was based on my original answer.
96 %
97 % Internal registers.
98 % \begin{macrocode}
99 declare dimen register={multidom@dimx},
100 multidom@dimx'=0pt,
101 declare dimen register={multidom@dimy},
102 multidom@dimy'=0pt,
103 declare toks register={multidom@toksa},
104 multidom@toksa={},
105 declare toks register={multidom@toksb},
106 multidom@toksb={},
107 declare toks register={multidom@toksc},
108 multidom@toksc={},
109 declare toks register={multidom@toksd},
110 multidom@toksd={},
111 % \end{macrocode}
112 % \begin{fstyle}{multidom@aux}
113 % First split the argument on colons.
114 % If there's no sixth argument, re-split to \texttt{curve to also parent}; o/w split out the first argument to (send back to) \texttt{multidom}, storing remaining arguments.
115 % \begin{macrocode}
116 multidom@aux/.style={%
117 %<debug> debug@multidom=Executing style multidom@aux at,
118 %<debug> debug@multidom@option=id,
119 if={>__={#1}{}}{}{
120 multidom@toksa={},
121 multidom@toksb={},
122 multidom@toksc={},
123 multidom@toksd={},
124 multidom@dimx'=0pt,
125 multidom@dimy'=0pt,
126 split={#1}{:}{%
127 multidom@toksa,multidom@toksa,%
128 multidom@toksa,multidom@toksb,%
129 multidom@toksc,multidom@toksd%
130 },
131 if={>{R_=}{multidom@toksd}{}}{% no sixth arg -> resplit -> curve to also parent
132 split={#1}{:}{%
133 multidom@toksa,multidom@toksb,multidom@toksc%
134 },
135 curve to also parent/.process={%
136 RRR
137 {multidom@toksa}
138 {multidom@toksb}
139 {multidom@toksc}%
140 },
141 }{% sixth arg -> (first) multidom
142 split={#1}{:}{%
143 multidom@toksa,multidom@dimx,%
144 multidom@dimy,multidom@toksb,%
145 multidom@toksc,multidom@toksd%
146 },
147 %<debug> debug@multidom@register=multidom@dimx,
148 %<debug> debug@multidom@register=multidom@dimy,
149 multidom/.process={%
150 RRRRRR
151 {multidom@toksa}{multidom@dimx}
152 {multidom@dimy}{multidom@toksb}
153 {multidom@toksc}{multidom@toksd}%
154 },
155 },
156 },
157 },
158 % \end{macrocode}
159 % \end{fstyle}
160 % \begin{fstyle}{curve to also parent,curve to also parent+,+curve to also parent}
161 % Draws a curved edge from the current node to an additional extant parent\texseans[Parameterised from \texse{}:]{249615}.
162 %
163 % Why do I need to double hashes twice here?
164 % \begin{macrocode}
165 curve to also parent/.style n args=3{%
166 %<debug> debug@multidom=Executing style curve to also parent at,
167 %<debug> debug@multidom@option=id,
168 also parent={#1}{%
169 #3:{%
170 multidom@curved@edge=from (!c fosterling.#2)
171 to (!c foster parent.parent anchor)%
172 }%
173 },
174 },
175 +curve to also parent/.style 2 args={%
176 %<debug> debug@multidom=Executing style +curve to also parent at,
177 %<debug> debug@multidom@option=id,
178 +also parent={%
179 #2:{%
180 multidom@curved@edge=from (!c fosterling.#1)
181 to (!c foster parent.parent anchor)%
182 }%
183 },
184 },
185 curve to also parent+/.style 2 args={%
186 %<debug> debug@multidom=Executing style curve to also parent+ at,
187 %<debug> debug@multidom@option=id,
188 also parent+={%
189 #2:{%
190 multidom@curved@edge=from (!c fosterling.#1)
191 to (!c foster parent.parent anchor)%
192 }%
193 },
194 },
195 % \end{macrocode}
196 % \end{fstyle}
197 % \begin{fstyle}{multidom}
198 % \texseans{695600}[Alan Munn], which was based on my original answer.
199 % Draws a curved edge from the current node to its parent and from the current node to an additional extant parent.
200 %
201 % Arguments:
202 % \begin{itemize}[label={}]
203 % \item prepend\textbar append (\textbar other??)
204 % \item xshift for tree rooted at current node
205 % \item yshift for tree rooted at current node
206 % \item out to structural parent
207 % \item out to node
208 % \item node
209 % \end{itemize}
210 % \texseans[Parameterised from]{249615}.
211 % \begin{macrocode}
212 multidom/.style n args=6{%
213 %<debug> debug@multidom=Executing style multidom at,
214 %<debug> debug@multidom@option=id,
215 %<debug> debug@multidom=Executing style also parent with #1 #5 and #6,
216 also parent={#1}{%
217 #6:{%
218 multidom@curved@edge=from (!c fosterling.#5)
219 to (#6.parent anchor)%
220 }%
221 },
222 %<debug> debug@multidom=Executing style multidom@curved@edge from #4 to parent,
223 multidom@curved@edge=from (.#4) to (!u.parent anchor),
224 %<debug> debug@multidom=Moving sub-tree by #2 and #3,
225 before drawing tree={%
226 for tree={x'+=#2,y'+=#3},
227 },
228 },
229 % \end{macrocode}
230 % \end{fstyle}
231 % \begin{fstyle}{multidom@curved@edge}
232 % Draw a curved edge from a child to its natural or additional parent.
233 % Ultra simple.
234 % \begin{macrocode}
235 multidom@curved@edge/.style args={from (#1.#2) to (#3)}{%
236 edge path'={(#1.#2) to [looseness=.5, out=#2] (#3)},
237 },
238 % \end{macrocode}
239 % \end{fstyle}
240 % \begin{fstyle}{other multidom parents}
241 % Convenience wrapper in case many additional parents are required.
242 % \begin{macrocode}
243 other multidom parents/.style={%
244 split={#1}{,}{multidom@aux},
245 },
246 % \end{macrocode}
247 % \end{fstyle}
248 % \begin{fstyle}{multidom prepend,multidom append}
249 % \begin{macrocode}
250 multidom prepend/.style n args=5{%
251 multidom={prepend}{#1}{#2}{#3}{#4}{#5}%
252 },
253 multidom append/.style n args=5{%
254 multidom={append}{#1}{#2}{#3}{#4}{#5}%
255 },
256 % \end{macrocode}
257 % \end{fstyle}
258 % Add code to default preamble to check for multi-dominance flags.
259 %
260 % Path here is based on builtin \pkg{forest} libraries, which should (hopefully?) hook into the same mechanisms, but this is not really documented??
261 %
262 % Dependence on another library is also not really documented \dots.
263 % It's not really clear to me whether other people are just not expected to write libraries \dots, but it is such a standard mechanism in \pgftikz, that would seem odd?
264 % \begin{macrocode}
265 %<!debug> libraries/ext.ling/defaults/.style={%
266 %<debug> libraries/ext.ling-debug/defaults/.style={%
267 %<!debug> libraries/ext.multi/defaults,
268 %<debug> libraries/ext.multi-debug/defaults,
269 },
270 % \end{macrocode}
271 % \begin{fstyle}{debug@multidom,debug@multidom@register,debug@multidom@option}
272 % Internal styles for debugging.
273 % Should not be used directly, but may be applied by loading the debugging code.
274 % \begin{macrocode}
275 %<debug> debug@multidom/.code={%
276 %<debug> \ExpandArgs {e} \typeout{[Forest ext.ling debug]:: \detokenize{#1}}%
277 %<debug> },
278 %<debug> debug@multidom@register/.code={%
279 %<debug> \ExpandArgs {e} \typeout{[Forest ext.ling debug]:: \detokenize{#1}
280 %<debug> = \foresteregister{#1}%
281 %<debug> }%
282 %<debug> },
283 %<debug> debug@multidom@option/.code={%
284 %<debug> \ExpandArgs {e} \typeout{[Forest ext.ling debug]:: \detokenize{#1}
285 %<debug> = \foresteoption{#1}%
286 %<debug> }%
287 %<debug> },
288 %<debug> debug multidom phantoms/.forward to=/forest/debug multi phantoms,
289 % \end{macrocode}
290 % \end{fstyle}
291 % \begin{fstyle}{debug multidom phantoms}
292 % Supply a code key as substitute for the boolean if the debugging code isn't loaded.
293 % \begin{macrocode}
294 %<!debug> debug multidom phantoms/.code={%
295 %<!debug> \PackageWarning{forest-lib-ext.ling}{%
296 %<!debug> You requested the style 'debug multidom phantoms',
297 %<!debug> but did not load the debugging code.
298 %<!debug> Either load 'ext.ling-debug' instead of
299 %<!debug> 'ext.ling' or remove this style.%
300 %<!debug> }%
301 %<!debug> },
302 % \end{macrocode}
303 % \end{fstyle}
304 % \begin{macrocode}
305 }
306 % \end{macrocode}
307 % \end{drop}
308 %</debug>
309 % ^^A >>> multidom
310 %
311 % ^^A <<< pretty nice empty nodes
312 % \begin{fstyle}{pretty nice empty nodes}
313 % This is in the \pkg{ext.ling} library mostly because \texttt{nice empty nodes} is in the \pkg{linguistics} library and not because linguists are more picky about their empty nodes than anybody else.
314 %
315 % Is this even still useful?
316 %
317 % \texseans{717677} i gwestiwn \texseqn{717592}[argo]
318 % \begin{macrocode}
319 \forestset{%
320 pretty nice empty nodes/.style={%
321 for tree={%
322 calign=fixed edge angles,
323 parent anchor=children,
324 delay={%
325 if content={}{%
326 inner sep=0pt,
327 edge path'={(!u.parent anchor) -- (.children)},
328 #1,
329 }{},
330 },
331 },
332 },
333 }
334 % \end{macrocode}
335 % \end{fstyle}
336 % ^^A >>> pretty nice empty nodes
337 %</sty>
338 %^^A >>>
339 %
340 % ^^A \Finale
341 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
342 %^^A vim: et:tw=0:sw=2:ts=2:foldmethod=marker:fmr=<<<,>>>: