-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathforest.dtx
9914 lines (9895 loc) · 392 KB
/
forest.dtx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% \CheckSum{12797}
% \iffalse meta-comment
% forest.dtx
%% `forest' is a `pgf/tikz'-based package for drawing (linguistic) trees.
%%
%% Copyright (c) 2012 Saso Zivanovic
%% (Sa\v{s}o \v{Z}ivanovi\'{c})
%% saso.zivanovic@guest.arnes.si
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Saso Zivanovic.
%%
%% This work consists of the files forest.dtx and forest.ins
%% and the derived file forest.sty.
%%
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage{fullpage}
\usepackage[external]{forest}
%\tikzexternalize
\tikzset{
external/prefix={forest.for.dir/},
external/system call={
pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=nonstopmode
-jobname "\image" "\texsource"},
}
%\usepackage[trace]{trace-pgfkeys}
\usepackage[colorlinks=true,linkcolor=blue,citecolor=blue,hyperindex=false]{hyperref}
\usepackage{url}
\usepackage[numbers]{natbib}
\usepackage[multiple]{footmisc}
\usepackage{tipa}
\usepackage{paralist}
\usepackage{printlen}
\makeatletter
\DeleteShortVerb\|
\newcommand\OR{\ensuremath{\,|\,}}%
%%%%%%%%
%\usepackage{lstdoc} %%% copy/paste most of the file, but omit and adjust some stuff like
%section-modifications
\usepackage{listings}
\def\lst@sampleInput{%
\MakePercentComment\catcode`\^^M=10\relax
\small\lst@sample
{\setkeys{lst}{SelectCharTable=\lst@ReplaceInput{\^\^I}%
{\lst@ProcessTabulator}}%
\leavevmode \input{\jobname.tmp}}\MakePercentIgnore}
\definecolor{darkgreen}{rgb}{0,0.5,0}
\def\rstyle{\color{red}}
\def\advise{\par\list\labeladvise
{\advance\linewidth\@totalleftmargin
\@totalleftmargin\z@
\@listi
\let\small\footnotesize \small\sffamily
\parsep \z@ \@plus\z@ \@minus\z@
\topsep6\p@ \@plus1\p@\@minus2\p@
\def\makelabel##1{\hss\llap{##1}}}}
\let\endadvise\endlist
\def\advisespace{\hbox{}\qquad}
\def\labeladvise{$\to$}
\newenvironment{syntax}
{\list{}{\itemindent-\leftmargin
\def\makelabel##1{\hss\lst@syntaxlabel##1,,,,\relax}}}
{\endlist}
\def\lst@syntaxlabel#1,#2,#3,#4\relax{%
\llap{\scriptsize\itshape#3}%
\def\lst@temp{#2}%
\expandafter\lst@syntaxlabel@\meaning\lst@temp\relax
\rlap{\hskip-\itemindent\hskip\itemsep\hskip\linewidth
\llap{\ttfamily\lst@temp}\hskip\labelwidth
\def\lst@temp{#1}%
\ifx\lst@temp\lstdoc@currversion#1\fi}}
\def\lst@syntaxlabel@#1>#2\relax
{\edef\lst@temp{\zap@space#2 \@empty}}
\newcommand*\syntaxnewline{\newline\hbox{}\kern\labelwidth}
\newcommand*\syntaxor{\qquad or\qquad}
\newcommand*\syntaxbreak
{\hfill\kern0pt\discretionary{}{\kern\labelwidth}{}}
\let\syntaxfill\hfill
\def\alternative#1{\lst@true \alternative@#1,\relax,}
\def\alternative@#1,{%
\ifx\relax#1\@empty
\expandafter\@gobble
\else
\ifx\@empty#1\@empty\else %\if
\lst@if \lst@false \else $\vert$\fi
\textup{\texttt{#1}}%
\fi
\fi
\alternative@}
\lst@RequireAspects{writefile}
\lst@InstallKeywords{p}{point}{pointstyle}\relax{keywordstyle}{}ld
\def\pstyle{\color{darkgreen}}
\lstset{language={[LaTeX]TeX},tabsize=4,gobble=4,%
basicstyle=\small\ttfamily,basewidth=0.51em,boxpos=t,pointstyle=\pstyle,moredelim=[is][\pstyle]{~}{~}}%
\newbox\sampleoutputbox
\newbox\lst@samplebox
\newdimen\forestexample@code
\newdimen\forestexample@sample
\newdimen\forestexample@hsep
\forestexample@hsep=1em
\lst@Key{hsep}\relax{\forestexample@hsep=#1}%
\pgfqkeys{/forestexample}{%
samplebox/.code={\let\sampleoutputbox#1},
codebox/.code={\let\lst@samplebox#1},
pos/.initial=l, % example is left of the code
before/.code={\gdef\lst@sample{#1}},
labelformat/.initial={\def\@currentlabel{#1}},
no numbering/.code={\addtocounter{lstlisting}{-1}\pgfkeysalso{labelformat={}}},
.unknown/.code={\lstset{\pgfkeyscurrentname={#1}}},
ekeynames/.code={\def\myindex@for@temp##1{\ekeyname[example]{##1}}\forcsvlist\myindex@for@temp{#1}},
ecmdnames/.code={\forcsvlist{\ecmdname[example]}{#1}},
filename/.initial={},
}
\lstnewenvironment{forestexample}[1][]{%
\global\let\lst@intname\@empty
\def\@currentlabel{(\arabic{lstlisting})}%
\addtocounter{lstlisting}{1}%
\gdef\lst@sample{}%
\pgfqkeys{/forestexample}{#1}%
\setbox\lst@samplebox=\hbox\bgroup
\xdef\samplebox@baselineskip{\the\baselineskip}%
\catcode`~=9\relax
\lst@BeginAlsoWriteFile{\jobname.tmp}%
}{%
\lst@EndWriteFile\egroup
\immediate\write18{cat \jobname.tmp}%
\pgfkeysgetvalue{/forestexample/pos}\fe@pos
\if x\fe@pos %%%%%%%% user position: boxes are stored in cs given in samplebox and codebox args
\forest@temp@count=\@listdepth
\pgfutil@tempdima=0pt
\loop
\ifnum\forest@temp@count>0
\advance\pgfutil@tempdima\csname leftmargin\romannumeral\the\forest@temp@count\endcsname\relax
\advance\forest@temp@count-1
\repeat
\global\setbox\lst@samplebox=\hbox{\hskip-\pgfutil@tempdima\box\lst@samplebox\hskip\pgfutil@tempdima}%
\global\setbox\sampleoutputbox=\hbox{\lst@sampleInput}%
\else
\if l\fe@pos %%%% example is left of the code
% move the code left for each list's \leftmargin ... have no idea why this must be done
\forest@temp@count=\@listdepth
\pgfutil@tempdima=0pt
\loop
\ifnum\forest@temp@count>0
\advance\pgfutil@tempdima\csname leftmargin\romannumeral\the\forest@temp@count\endcsname\relax
\advance\forest@temp@count-1
\repeat
\setbox\lst@samplebox=\hbox{\hskip-\pgfutil@tempdima\box\lst@samplebox\hskip\pgfutil@tempdima}%
\setbox\sampleoutputbox=\hbox{\lst@sampleInput}%
\pgfutil@tempdima=\wd\sampleoutputbox
\advance\pgfutil@tempdima\wd\lst@samplebox
\advance\pgfutil@tempdima\forestexample@hsep
\ifdim\pgfutil@tempdima>\linewidth
\forestexample@code=\linewidth
\advance\forestexample@code-\wd\lst@samplebox
\forestexample@sample=\forestexample@code
\advance\forestexample@sample-\forestexample@hsep
\advance\forestexample@sample-\wd\sampleoutputbox
\else
\pgfutil@tempdima=\wd\sampleoutputbox
\advance\pgfutil@tempdima\forestexample@hsep
\ifdim\pgfutil@tempdima>.5\linewidth
\forestexample@sample=0pt
\forestexample@code=\wd\sampleoutputbox
\advance\forestexample@code\forestexample@hsep
\else
\pgfutil@tempdima=\wd\lst@samplebox
\advance\pgfutil@tempdima\forestexample@hsep
\ifdim\pgfutil@tempdima>.5\linewidth
\forestexample@code=\linewidth
\advance\forestexample@code-\wd\lst@samplebox
\forestexample@sample=0pt
\else
\forestexample@sample=0pt
\forestexample@code=.5\linewidth
\fi
\fi
\fi
\begin{trivlist}\item\relax
$%
\vcenter{
\hbox{%
\hbox to 0pt{\hskip\linewidth\llap{\@currentlabel}}%
\hbox to 0pt{%
\hskip\forestexample@code
\raise\samplebox@baselineskip\box\lst@samplebox
}%
}%
}%
\vcenter{%
\hbox to 0pt{%
\hskip\forestexample@sample
\box\sampleoutputbox
}%
}%
$%
\end{trivlist}%
\else
\if t\fe@pos %%%% example is above the code
\forest@temp@count=\@listdepth
\pgfutil@tempdima=0pt
\loop
\ifnum\forest@temp@count>0
\advance\pgfutil@tempdima\csname leftmargin\romannumeral\the\forest@temp@count\endcsname\relax
\advance\forest@temp@count-1
\repeat
\setbox\lst@samplebox=\hbox{\hskip-\pgfutil@tempdima\box\lst@samplebox\hskip\pgfutil@tempdima}%
\setbox\sampleoutputbox=\hbox{\lst@sampleInput}%
\begin{trivlist}%
\item
\hfil\box\sampleoutputbox\hfil
\item
\hbox{%
\hbox to 0pt{\hskip\linewidth\llap{\@currentlabel}}%
\hbox to 0pt{%
\raise\samplebox@baselineskip\box\lst@samplebox
}%
}%
\end{trivlist}%
\else
\if b\fe@pos %%% example is below the code
\forest@temp@count=\@listdepth
\pgfutil@tempdima=0pt
\loop
\ifnum\forest@temp@count>0
\advance\pgfutil@tempdima\csname leftmargin\romannumeral\the\forest@temp@count\endcsname\rel ax
\advance\forest@temp@count-1
\repeat
\setbox\lst@samplebox=\hbox{\hskip-\pgfutil@tempdima\box\lst@samplebox\hskip\pgfutil@tempdima}%
\setbox\sampleoutputbox=\hbox{\lst@sampleInput}%
\begin{trivlist}%
\item
\hbox{%
\hbox to 0pt{\hskip\linewidth\llap{\@currentlabel}}%
\hbox to 0pt{%
\raise\samplebox@baselineskip\box\lst@samplebox
}%
}%
\item
\hfil\box\sampleoutputbox\hfil
\end{trivlist}%
\else %%% insert other pos here....
\fi
\fi
\fi
\fi
}%
\def\myisaspect#1#2#3{% #1=aspect id, #2=aspect display, #3=entry ids
\csdef{myaspect@display@#1}{#2}%
\edef\myisaspect@##1{%
\csdef{myaspect@of@##1}{#1}%
}%
\forcsvlist\myisaspect@{#3}%
}
\def\my@index#1#2#3#4{% #1=entry id,#2=entry display,#3=aspect id,#4=pagestyle
\ifstrempty{#3}{%
\edef\mytemp{%
\noexpand\index{#1=\unexpanded{#2}#4}%
}%
}{%
\edef\mytemp{%
\noexpand\index{%
#1=\unexpanded{#2}\protect\noexpand\space
{\protect\noexpand\scriptsize
\expandafter\expandafter\expandafter\unexpanded
\expandafter\expandafter\expandafter
{\csname myaspect@display@#3\endcsname}%
}%
#4%
}%
\noexpand\index{#3=\expandafter\expandafter\expandafter\unexpanded
\expandafter\expandafter\expandafter
{\csname myaspect@display@#3\endcsname}\levelchar
#1=\unexpanded{#2}%
#4%
}%
}%
}%
\mytemp
}%
\newcommand\myindex[1]{%
\@bsphack
\pgfqkeys{/myindex}{#1}%
\pgfkeysgetvalue{/myindex/id}\myindex@temp@entryid
\pgfkeysgetvalue{/myindex/display}\myindex@temp@entrydisplay
\pgfkeysgetvalue{/myindex/aspect}\myindex@temp@aspectid
\pgfkeysgetvalue{/myindex/pagestyle}\myindex@temp@pagestyle
\edef\myindex@temp{\noexpand\my@index
{\expandonce{\myindex@temp@entryid}}{\expandonce{\myindex@temp@entrydisplay}}{\expandonce{\myindex@temp@aspectid}}{\myindex@temp@pagestyle}%
}\myindex@temp
\@esphack
\pgfkeysvalueof{/myindex/text}%
}
\def\stripfirst#1#2\stripfirst{#2}%
\pgfqkeys{/myindex}{%
/handlers/.wrap/.code={%
\edef\myindex@currentpath{\pgfkeyscurrentpath}%
\pgfkeysgetvalue{\myindex@currentpath}\myindex@keyvalue
\forest@def@with@pgfeov\myindex@wrap@code{#1}%
\expandafter\edef\expandafter\myindex@wrapped@value\expandafter{\expandafter\expandonce\expandafter{\expandafter\myindex@wrap@code\myindex@keyvalue\pgfeov}}%
\pgfkeysalso{\myindex@currentpath/.expand once=\myindex@wrapped@value}%
},
/handlers/.ewrap/.code={% not used!
\edef\myindex@currentpath{\pgfkeyscurrentpath}%
\pgfkeysgetvalue{\myindex@currentpath}\myindex@keyvalue
\forest@def@with@pgfeov\myindex@wrap@code{#1}%
\edef\myindex@wrapped@value{\expandafter\myindex@wrap@code\expandafter{\myindex@keyvalue}\pgfeov}%
\pgfkeysalso{\myindex@currentpath/.expand once=\myindex@wrapped@value}%
},
id/.code={%
\pgfkeyssetvalue{/myindex/id}{#1}%
\pgfkeysgetvalue{/myindex/id}\myindex@temp
\pgfkeyslet{/myindex/display}\myindex@temp
\pgfkeyslet{/myindex/text}\myindex@temp
\pgfkeyssetvalue{/myindex/pagestyle}{}%
\pgfkeyssetvalue{/myindex/version}{}%
\ifcsname myaspect@of@#1\endcsname
\pgfkeysalso{aspect/.expand once=\csname myaspect@of@#1\endcsname}%
\else
\pgfkeyssetvalue{/myindex/aspect}{}%
\pgfkeyssetvalue{/myindex/margin}{}%
\fi
},
id'/.code={\pgfkeyssetvalue{/myindex/id}{#1}},
.unknown/.code={%
\edef\myindex@temp{%
\noexpand\pgfkeysalso{id={\pgfkeyscurrentname}}%
}\myindex@temp
},
display/.initial={},
pagestyle/.initial={},
text/.initial={},
aspect/.code={%
\edef\myindex@temp{%
\noexpand\pgfkeyssetvalue{/myindex/aspect}{#1}%
}\myindex@temp
\ifcsname myaspect@display@#1\endcsname
\edef\myindex@temp{%
\noexpand\pgfkeyslet{/myindex/margin}\expandonce{\csname myaspect@display@#1\endcsname}%
}\myindex@temp
\else
\pgfkeyssetvalue{/myindex/margin}{}%
\fi
},
nfc/.style={% no first char (in id)
id'/.expanded={\expandafter\stripfirst\romannumeral-`0\pgfkeysvalueof{/myindex/id}\stripfirst}
},
rstyle/.style={text/.wrap={\begingroup\rstyle##1\endgroup}},
example/.style={pagestyle=|indextextexample},
def/.style={pagestyle=|indextextdef},
normal/.style={pagestyle=|indextextnormal},
item/.style={% #1=default
text/.wrap={% ##1=current text
\item[\pgfkeysvalueof{/myindex/version},#1,\pgfkeysvalueof{/myindex/margin}]{##1}%
}
},
item/.default={},
version/.initial={},
margin/.initial={},
}
\newcommand\indextextexample[1]{\hyperlink{page.#1}{\textcolor{darkgreen}{#1}}}
\newcommand\indextextdef[1]{\hyperlink{page.#1}{\textcolor{red}{#1}}}
\newcommand\indextextnormal[1]{\hyperlink{page.#1}{\textcolor{blue}{#1}}}
\let\keyname\texttt
\newcommand\rkeyname[2][]{\myindex{%
#2,
display/.wrap=\protect\texttt{##1},
text/.wrap=\hypertarget{\pgfkeysvalueof{/myindex/id}}{{\rstyle\keyname{##1}}},
def,
#1
}}
\newcommand\ikeyname[2][]{\myindex{%
#2,
display/.wrap=\protect\texttt{##1},
text/.wrap=\hyperlink{\pgfkeysvalueof{/myindex/id}}{\keyname{##1}},
normal,
#1
}}
\newcommand\ekeyname[2][]{\myindex{%
#2,
display/.wrap=\protect\texttt{##1},
text={},
normal,
#1
}}
\newcommand\rmeta[2][]{\myindex{%
#2,
display/.wrap=\protect\meta{##1},
%text/.wrap=\begingroup\rstyle\meta{##1}\endgroup,
text/.wrap=\hypertarget{\pgfkeysvalueof{/myindex/id}}{{\rstyle\meta{##1}}},
def,
#1
}}
\newcommand\imeta[2][]{\myindex{%
#2,
display/.wrap=\protect\meta{##1},
text/.wrap=\hyperlink{\pgfkeysvalueof{/myindex/id}}{\meta{##1}},
normal,
#1
}}
\newcommand\cmdname[1]{\expandafter\texttt\expandafter{\expandafter\string\csname#1\endcsname}}
\newcommand\rcmdname[2][]{\myindex{%
#2,
id'/.expanded=\pgfkeysvalueof{/myindex/id} macro,
display/.wrap=\protect\cmdname{##1},
text/.wrap=\hypertarget{\pgfkeysvalueof{/myindex/id}}{{\rstyle\cmdname{##1}}},
def,
#1
}}
\newcommand\icmdname[2][]{\myindex{%
#2,
id'/.expanded=\pgfkeysvalueof{/myindex/id} macro,
text/.wrap=\hyperlink{\pgfkeysvalueof{/myindex/id}}{\cmdname{##1}},
normal,
#1
}}
\newcommand\ecmdname[2][]{\myindex{%
#2,
id'/.expanded=\pgfkeysvalueof{/myindex/id} macro,
display/.wrap=\protect\cmdname{##1},
text={},
normal,
#1
}}
\makeatother
\myisaspect{environment}{environment}{forest}
\myisaspect{option}{option}{align,content,content format,node format,base,node options,phantom,anchor,calign,calign primary angle,calign secondary angle,calign primary child,calign secondary child,fit,grow,ignore,ignore edge,reversed,l,s,l sep,s sep,tier,x,y,child anchor,edge,edge label,edge path,parent anchor,name,tikz,anchor,level,n,n',n children,id,max x,max y,min x,min y}
\myisaspect{propagator}{propagator}{for,if,where,for tree,repeat,delay,delay n,if have delayed,for ancestors,for ancestors',for children,for descendants,for descendants',for all next,for all previous,for previous siblings,before typesetting nodes,before packing,before computing xy,before drawing tree,repeat}
\myisaspect{type}{type}{toks,autowrapped toks,keylist,dimen,count,boolean}%relative node name,node walk,step}
\myisaspect{handler}{handler}{.pgfmath,.wrap value,.wrap pgfmath arg,.wrap $n$ pgfmath args,.wrap 2 pgfmath args,.wrap 3 pgfmath args,.wrap 4 pgfmath args,.wrap 5 pgfmath args,.wrap 6 pgfmath args,.wrap 7 pgfmath args,.wrap 8 pgfmath args,.wrap 9 pgfmath args}
\myisaspect{key prefix}{key prefix}{if in ,where in ,if ,where ,not ,for }
\myisaspect{key suffix}{key suffix}{',+,-,*,:,'+,'-,'*,':}
\myisaspect{key}{}{afterthought,baseline,label,pin,alias,TeX,TeX',TeX'',no edge,typeset node,repeat,use as bounding box,use as bounding box',draw tree box}
\myisaspect{style}{style}{stages,typeset nodes stage,pack stage,compute xy stage,draw tree
stage,math content}
\myisaspect{stage}{stage}{typeset nodes,typeset nodes',pack,compute xy,draw tree,draw tree'}
\myisaspect{package option}{package option}{external,tikzcshack,tikzinstallkeys}
\myisaspect{dynamic tree}{dynamic tree}{create,remove,prepend,append,insert after,insert before,set
root,replace by,prepend',append',insert after',insert before',replace by',prepend'',append'',insert after'',insert before'',replace by'',copy name template}
\myisaspect{forest cs}{forest cs}{}
\myisaspect{calign}{\keyname{calign} value}{}%{child,first,last,child edge,midpoint,center,edge midpoint,fixed angles,fixed edge angles}
\myisaspect{align}{\keyname{align} value}{}%{left,center,right}
\myisaspect{fit}{\keyname{fit} value}{}%{tight,rectangle,band}
\myisaspect{base}{\keyname{base} value}{}%{top,bottom}
\myisaspect{step}{\meta{step}}{current,next,previous,parent,sibling,previous leaf,next leaf,
linear next,linear previous,first leaf,last leaf,to tier,next on tier,previous on tier,
root,embed,trip,group,first,last
%,n,n',name,id, % these equal option names
}
\myisaspect{short step}{\meta{short step}}{1,2,3,4,5,6,7,8,9,u,p,%
%,n,l,s equal option names
P,N,F,L,<,%> is a level char
c,r}
\myisaspect{generic anchor}{generic anchor}{}%
{\catcode`\|=12 \gdef\myindexgt{\texttt{>}}}
{\makeatletter % an dirty patch: \lst@nolig can sneak in the name...
\gdef\myexampleindex#1{{\def\lst@nolig{}\lstaspectindex{#1}{}}}
}
\lstset{indexstyle={[1]\myexampleindex}}
\makeindex
%%% end lst-related stuff
\EnableCrossrefs
%\DisableCrossrefs % Say \DisableCrossrefs if index is ready
%\CodelineIndex
%\RecordChanges % Gather update information
%\OnlyDescription % comment out for implementation details
\setlength\hfuzz{15pt} % dont make so many
\hbadness=7000 % over and under full box warnings
\def\partname{Part}
\def\TikZ;{{\rm Ti\emph{k}Z}}\def\PGF;{\textsc{pgf}}\def\foRest;{\textsc{Forest}}\def\FoRest;{\textsc{Forest}}
\usetikzlibrary{intersections}
\tikzset{>=latex}
\forestset{
background tree/.style={
for tree={text opacity=0.2,draw opacity=0.2,edge={draw opacity=0.2}}}
}
\def\getforestversion#1/#2/#3 v#4 #5\getforestversion{v#4}
\edef\forestversion{\expandafter\expandafter\expandafter\getforestversion\csname ver@forest.sty\endcsname\getforestversion}
\def\getforestdate#1/#2/#3 v#4 #5\getforestdate{#1/#2/#3}
\edef\forestdate{\expandafter\expandafter\expandafter\getforestdate\csname ver@forest.sty\endcsname\getforestdate}
\title{\FoRest;: a \PGF;/\TikZ;-based package for drawing linguistic trees\\\normalsize\forestversion}
\author{Sa\v so \v Zivanovi\'c\footnote{e-mail:
\href{mailto:saso.zivanovic@guest.arnes.si}{saso.zivanovic@guest.arnes.si};
web:
\href{http://spj.ff.uni-lj.si/zivanovic/}{http://spj.ff.uni-lj.si/zivanovic/}}}
\def\settodayfromforestdateA#1/#2/#3 v#4 #5\settodayfromforestdateA{\def\year{#1}\def\month{#2}\def\day{#3}}
\def\settodayfromforestdate{\expandafter\expandafter\expandafter\settodayfromforestdateA\csname ver@forest.sty\endcsname\settodayfromforestdateA}
\begin{document}
\DocInput{forest.dtx}
\end{document}
%</driver>
% \fi
%
% ^^A short verbatim: | (changes spaces into _)
% \DeleteShortVerb\|
% {\catcode`\_=12 \def\marshal{^^A
% \lstMakeShortInline[basicstyle=\ttfamily,literate={_}{ }1 {__}{_}1]}^^A
% \expandafter}\marshal |
%
% \newbox\treebox
% \newbox\codebox
%
%
%
% {\settodayfromforestdate\maketitle}
%
% \begin{abstract}
% \FoRest; is a \PGF;/\TikZ;-based package for drawing linguistic (and
% other kinds of) trees. Its main features are
% \begin{inparaenum}[(i)]
% \item a packing algorithm which can produce very compact trees;
% \item a user-friendly interface consisting of the familiar bracket encoding of trees plus the
% key--value interface to option-setting;
% \item many tree-formatting options, with control over option values of individual nodes and
% mechanisms for their manipulation;
% \item the possibility to decorate the tree using the full power of \PGF;/\TikZ;;
% \item an externalization mechanism sensitive to code-changes.
% \end{inparaenum}
% \end{abstract}
%
% {\lstset{basicstyle=\ttfamily\scriptsize}^^A
% \begin{forestexample}[samplebox=\treebox,codebox=\codebox,pos=x,ekeynames={content,{id=.pgfmath,nfc},if,repeat,append,before drawing tree,where,y,alias,for ,name,for children,edge,before typesetting nodes,for tree,s sep,l,+,,for ancestors',typeset node}]
% \pgfmathsetseed{14285}
% \begin{forest}
% random tree/.style n args={3}{% #1=max levels, #2=max children, #3=max content
% content/.pgfmath={random(0,#3)},
% if={#1>0}{repeat={random(0,#2)}{append={[,random tree={#1-1}{#2}{#3}]}}}{}},
% for deepest/.style={before drawing tree={
% alias=deepest,
% where={y()<y("deepest")}{alias=deepest}{},
% for name={deepest}{#1}}},
% colorone/.style={fill=yellow,for children=colortwo}, colortwo/.style={fill=green,for children=colorone},
% important/.style={draw=red,line width=1.5pt,edge={red,line width=1.5pt,draw}},
% before typesetting nodes={colorone, for tree={draw,s sep=2pt,rotate={int(30*rand)},l+={5*rand}}},
% for deepest={for ancestors'={important,typeset node}}
% [,random tree={9}{3}{100}]
% \end{forest}
% \end{forestexample}%
% \begin{center}\mbox{}\box\treebox\\\box\codebox\end{center}}
% \newpage
% {\parskip 0pt ^^A We have to reset \parskip
% ^^A (bug in \LaTeX)
% \tableofcontents
% }
%
% \newpage
% \part{User's Guide}
% \section{Introduction}
%
% Over several years, I had been a grateful user of various packages
% for typesetting linguistic trees. My main experience was with
% |qtree| and |synttree|, but as far as I can tell, all of the tools
% on the market had the same problem: sometimes, the trees were just
% too wide. They looked something like the tree on the left,
% while I wanted something like the tree on the right.
% \begin{center}
% \begin{forest}
% baseline,
% for tree={parent anchor=south,child anchor=north,l=7ex,s sep=10pt},
% for children={fit=rectangle}
% [CP
% [DP
% [D][NP[N][CP[C][TP[T][vP[v][VP[DP][V'[V][DP]]]]]]]]
% [TP
% [T][vP[v][VP[DP][V'[V][DP]]]]]
% ]
% \end{forest}
% \hfill
% \begin{forest}
% baseline,
% for tree={parent anchor=south,child anchor=north,l=7ex,s sep=10pt},
% [CP
% [DP
% [D][NP[N][CP[C][TP[T][vP[v][VP[DP][V'[V][DP]]]]]]]]
% [TP
% [T][vP[v][VP[DP][V'[V][DP]]]]]
% ]
% \end{forest}
% \end{center}
%
% Luckily, it was possible to tweak some parameters by hand to get a
% narrower tree, but as I quite dislike constant manual adjustments, I
% eventually started to develop \foRest;. It started out as
% xyforest, but lost the xy prefix as I became increasingly fond
% of \PGF;/\TikZ;, which offered not only a drawing package but also a
% `programming paradigm.' It is due to the awesome power of the
% supplementary facilities of \PGF;/\TikZ; that \foRest; is now, I
% believe, the most flexible tree typesetting package for \LaTeX\ you can get.
%
% After all the advertising, a disclaimer. Although the present version
% is definitely usable (and has been already used), the package and
% its documentation are still under development: comments, criticism,
% suggestions and code are all very welcome!
%
% \FoRest; is \href{http://www.ctan.org/pkg/forest}{available} at \href{http://www.ctan.org}{CTAN},
% and I have also started a \href{https://github.com/sasozivanovic/forest-styles}{style repository}
% at \href{https://github.com}{GitHub}.
%
% \section{Tutorial}
% \label{sec:tutorial}
%
% This short tutorial progresses from basic through useful to
% obscure \dots
%
% \subsection{Basic usage}
% \label{sec:basic-usage}
%
% A tree is input by enclosing its specification in a \ikeyname{forest}
% environment. The tree is encoded by \emph{the bracket syntax}:
% every node is enclosed in square brackets; the children of a
% node are given within its brackets, after its content.
% {\lstdefinelanguage[my]{TeX}[LaTeX]{TeX}{keywords=forest,
% otherkeywords={[,]},keywordstyle=\pstyle,texcsstyle={}}^^A
% \lstset{language={[my]TeX}}^^A
% \begin{forestexample}
% \begin{forest}
% [VP
% [DP]
% [V'
% [V]
% [DP]
% ]
% ]
% \end{forest}
% \end{forestexample}}
% Binary trees are nice, but not the only thing this package can draw.
% Note that by default, the children are vertically centered with
% respect to their parent, i.e.\ the parent is vertically aligned with the midpoint between the
% first and the last child.
% \begin{forestexample}
% \begin{forest}
% [VP
% [DP[John]]
% [V'
% [V[sent]]
% [DP[Mary]]
% [DP[D[a]][NP[letter]]]
% ]
% ]
% \end{forest}
% \end{forestexample}
% Spaces around brackets are ignored --- format your code as you
% desire!
% \begin{forestexample}
% \begin{forest}
% [VP[DP][V'[V][DP]]]
% \end{forest}
% \quad
% \begin{forest}[VP
% [DP ] [ V'[V][ DP]]
% ]\end{forest}
% \end{forestexample}
% If you need a square bracket as part of a node's content, use
% braces. The same is true for the other characters which have a
% special meaning in the \foRest; package: comma
% |,| and equality sign |=|.
% \begin{forestexample}
% \begin{forest}
% [V{P,}
% [{[DP]}]
% [V'
% [V]
% [{===DP===}]]]
% \end{forest}
% \end{forestexample}
% Macros in a node specification will be expanded when the node is
% drawn --- you can freely use formatting commands inside nodes!
% \begin{forestexample}
% \begin{forest}
% [VP
% [{~\textbf~{DP}}]
% [V'
% [V]
% [DP]]]
% \end{forest}
% \end{forestexample}
%
% \newbox\GPone
% \begin{forestexample}[pos=x,samplebox=\treebox,codebox=\GPone]
% \newbox\standardnodestrutbox
% \setbox\standardnodestrutbox=\hbox to 0pt{\phantom{\forestOve{standard node}{content}}}
% \def\standardnodestrut{\copy\standardnodestrutbox}
% \forestset{
% ~GP1~/.style 2 args={
% for n={1}{baseline},
% s sep=0pt, l sep=0pt,
% for descendants={
% l sep=0pt, l={#1},
% anchor=base,calign=first,child anchor=north,
% inner xsep=1pt,inner ysep=2pt,outer sep=0pt,s sep=0pt,
% },
% delay={
% if content={}{phantom}{for children={no edge}},
% for tree={
% if content={O}{tier=OR}{},
% if content={R}{tier=OR}{},
% if content={N}{tier=N}{},
% if content={x}{
% tier=x,content={$\times$},outer xsep={#2},
% for tree={calign=center},
% for descendants={content format={\standardnodestrut\forestoption{content}}},
% before drawing tree={outer xsep=0pt,delay={typeset node}},
% s sep=4pt
% }{},
% },
% },
% before drawing tree={where content={}{parent anchor=center,child anchor=center}{}},
% },
% GP1/.default={5ex}{8.0pt},
% associate/.style={%
% tikz+={\draw[densely dotted](!)--(!#1);}},
% spread/.style={
% before drawing tree={tikz+={\draw[dotted](!)--(!#1);}}},
% govern/.style={
% before drawing tree={tikz+={\draw[->](!)--(!#1);}}},
% p-govern/.style={
% before drawing tree={tikz+={\draw[->](.north) to[out=150,in=30] (!#1.north);}}},
% no p-govern/.style={
% before drawing tree={tikz+={\draw[->,loosely dashed](.north) to[out=150,in=30] (!#1.north);}}},
% encircle/.style={before drawing tree={circle,draw,inner sep=0pt}},
% fen/.style={pin={[font=\footnotesize,inner sep=1pt,pin edge=<-]10:\textsc{Fen}}},
% el/.style={content=\textsc{\textbf{##1}}},
% head/.style={content=\textsc{\textbf{\underline{##1}}}}
% }
% \end{forestexample}
% \input{\jobname.tmp}
%
% All the examples given above produced top-down trees with centered
% children. The other sections of this manual explain how various
% properties of a tree can be changed, making it possible to typeset
% radically different-looking trees. However, you don't have to learn
% everything about this package to profit from its power. Using
% styles, you can draw predefined types of trees with ease. For
% example, a phonologist can use the \ikeyname{GP1} style from \S\ref{sec:gallery} to easily typeset
% (Government Phonology) phonological
% representations. The style is applied simply by writing its name
% before the first (opening) bracket of the tree.
% \begin{forestexample}[label=ex:gp1-frost]
% \begin{forest} ~GP1~ [
% [O[x[f]][x[r]]]
% [R[N[x[o]]][x[s]]]
% [O[x[t]]]
% [R[N[x]]]
% ]\end{forest}
% \end{forestexample}
% Of course, someone needs to develop the style --- you, me, your
% local \TeX nician \dots\@ Furtunately, designing styles is not very
% difficult once you know your \foRest; options. If you write one,
% please contribute!
%
% I have started a \href{https://github.com/sasozivanovic/forest-styles}{style repository} at
% GitHub. Hopefully, it will grow \dots\@ Check it out, download the styles \dots\ and contribute
% them!
%
% \subsection{Options}
% \label{sec:options}
%
% A node can be given various options, which control various
% properties of the node and the tree. For example, at the end of
% section~\ref{sec:basic-usage}, we have seen that the \ikeyname{GP1} style
% vertically aligns the parent with the first
% child. This is achieved by setting option \ikeyname{calign} (for
% \emph{c}hild-\emph{align}ment) to \ikeyname{first,aspect=calign} (child).
%
% Let's try. Options are given inside the brackets, following the
% content, but separated from it by a comma. (If multiple options are
% given, they are also separated by commas.) A single option
% assignment takes the form \meta{option name}|=|\meta{option value}. (There are
% also options which do not require a value or have a default value:
% these are given simply as \meta{option name}.)
% \begin{forestexample}[label=ex:numerals-simple,ekeynames={calign,{first,aspect=calign}}]
% \begin{forest}
% [\LaTeX\ numerals, ~calign=first~
% [arabic[1][2][3][4]]
% [roman[i][ii][iii][iv]]
% [alph[a][b][c][d]]
% ]
% \end{forest}
% \end{forestexample}
%
% The experiment has succeeded only partially. The root node's
% children are aligned as desired (so \ikeyname{calign}|=|\ikeyname{first,aspect=calign} applied to the
% root node), but the value of the \ikeyname{calign} option didn't get
% automatically assigned to the root's children! \emph{An option given
% at some node applies only to that node.} In \foRest;, the options
% are passed to the node's relatives via special options, called
% \emph{propagators}. (We'll
% call the options that actually change some property of the node
% \emph{node options}.) What we need above is the \ikeyname{for tree} propagator. Observe:
% \begin{forestexample}[label=ex:numerals-manual]
% \begin{forest}
% [\LaTeX\ numerals,
% ~for tree~={calign=first}
% [arabic[1][2][3][4]]
% [roman[i][ii][iii][iv]]
% [alph[a][b][c][d]]
% ]
% \end{forest}
% \end{forestexample}
% The value of propagator \ikeyname{for tree} is the option string that we
% want to process. This option string is propagated to all the nodes in
% the subtree\footnote{It might be more precise to call this option
% \texttt{for subtree} \dots\@ but this name at least saves some typing.}
% rooted in the current node (i.e.\ the node where \ikeyname{for tree} was
% given), including the node itself. (Propagator \ikeyname{for descendants} is
% just like \ikeyname{for tree}, only that it excludes the node itself. There
% are many other \ikeyname{id={{for }}}|...| propagators; for the complete list, see
% sections~\ref{ref:propagators} and \ref{ref:node-walk}.)
%
% Some other useful options are \ikeyname{parent anchor}, \ikeyname{child anchor}
% and \ikeyname{tier}. The \ikeyname{parent anchor} and \ikeyname{child anchor} options tell
% where the parent's and child's endpoint of the edge between them
% should be, respectively: usually, the value is either empty
% (meaning a smartly determined border point \citep[see][\S16.11]{tikzpgf2.10}; this is the default)
% or a compass direction \citep[see][\S16.5.1]{tikzpgf2.10}. (Note: the \ikeyname{parent anchor}
% determines where the
% edge from the child will arrive to this node, not where the node's
% edge to its parent will start!)
%
% Option \ikeyname{tier} is what makes the
% skeletal points $\times$ in example \ref{ex:gp1-frost} align horizontally although they
% occur at different levels in the logical structure of the tree.
% Using option \ikeyname{tier} is very simple: just set |tier=tier_name| at
% all the nodes that you want to align horizontally. Any tier name
% will do, as long as the tier names of different tiers are
% different \dots\@ (Yes, you can have multiple tiers!)
% \begin{forestexample}[point={tier},ekeynames={parent anchor,child anchor,tier},label=ex:tier-manual]
% \begin{forest}
% [VP, for tree={~parent anchor~=south, ~child anchor~=north}
% [DP[John,tier=word]]
% [V'
% [V[sent,tier=word]]
% [DP[Mary,tier=word]]
% [DP[D[a,tier=word]][NP[letter,tier=word]]]
% ]
% ]
% \end{forest}
% \end{forestexample}
% Before discussing the variety of \foRest;'s options, it is worth
% mentioning that \foRest;'s node accepts all options \citep[see
% \S16]{tikzpgf2.10} that \TikZ;'s node does --- mostly, it just passes
% them on to \TikZ;. For example, you can easily encircle a node like
% this:\footnote{If option \texttt{draw} was not given, the shape of the node
% would still be circular, but the edge would not be drawn. For
% details, see \cite[\S16]{tikzpgf2.10}.}
% \begin{forestexample}
% \begin{forest}
% [VP,~circle~,~draw~
% [DP][V'[V][DP]]
% ]
% \end{forest}
% \end{forestexample}
%
% Let's have another look at example \ref{ex:gp1-frost}. You will note that the skeletal
% positions were input by typing |x|s, while the result looks like
% this: $\times$ (input as |\times| in math mode). Obviously, the
% content of the node can be changed. Even more, it can be
% manipulated: added to, doubled, boldened, emphasized, etc. We will
% demonstrate this by making example \ref{ex:numerals-manual} a bit
% fancier: we'll write the input in the arabic numbers and have
% \LaTeX\ convert it to the other formats. We'll start with the
% easiest case of roman numerals: to get them, we can use the (plain)
% \TeX\ command |\romannumeral|. To change the content of the node,
% we use option \ikeyname{content}. When specifying its new value, we can use
% |#1| to insert the current content.\footnote{This mechanism is called
% \emph{wrapping}. \ikeyname{content} is the only option where wrapping works implicitely (simply
% because I assume that wrapping will be almost exclusively used with this option). To wrap values
% of other options, use handler \ikeyname{id=.wrap value,nfc}; see~\S\ref{ref:handlers}.}
% \begin{forestexample}[point={content,delay},ekeynames={for children,content,delay},label=ex:romannumeral]
% \begin{forest}
% [roman, delay={for children={content=\romannumeral#1}}
% [1][2][3][4]
% ]
% \end{forest}
% \end{forestexample}
% This example introduces another option: \ikeyname{delay}. Without it, the
% example wouldn't work: we would get arabic numerals. This is so
% because of the order in which the options are processed. The
% processing proceeds through the tree in a depth-first, parent-first fashion (first
% the parent is processed, and then its children, recursively). The option string of a node is
% processed linearly, in the order they were given. (Option \keyname{content}
% is specified implicitely and is always the first.) If a propagator
% is encountered, the options given as its value are propagated \emph{immediately}. The net effect
% is that if the
% above example contained simply |roman,for_children={content=...}|, the
% \keyname{content} option given there would be processed \emph{before} the
% implicit content options given to the children (i.e.\ numbers |1|,
% |2|, |3| and |4|). Thus, there would be nothing for the
% |\romannumeral| to change --- it would actually crash; more generally, the content assigned
% in such a way would get overridden by the implicit content. Option
% \ikeyname{delay} is true to its name. It delays the processing of its option
% string argument until the whole tree was processed. In other words,
% it introduces cyclical option processing. Whatever is delayed in
% one cycle, gets processed in the next one. The number of cycles is
% not limited --- you can nest \ikeyname{delay}s as deep as you need.
%
% Unlike \ikeyname{id={{for }}}|_...| options we have met before, option \ikeyname{delay} is not a
% spatial, but a temporal propagator. Several other temporal propagators options exist, see
% \S\ref{ref:stages}.
%
% We are now ready to learn about simple conditionals. Every node option has the corresponding
% \ikeyname{id={{if }}}|...| and \ikeyname{id={{where }}}|...| keys.
% \ikeyname{id={{if }}}\meta{option}|=|\meta{value}\meta{true options}\meta{false options} checks whether
% the value of \meta{option} equals \meta{value}. If so, \meta{true options} are
% processed, otherwise \meta{false options}. The \ikeyname{id={{where }}}|_...| keys are
% the same, but do this for the every node in the subtree; informally
% speaking, |where| = |for_tree| + |if|. To see this in action,
% consider the rewrite of the \ikeyname{tier} example \ref{ex:tier-manual} from above. We don't set
% the tiers manually, but rather put the terminal nodes (option
% \ikeyname{n children} is a read-only option containing the number
% of children) on tier \keyname{word}.\footnote{We could omit the braces around \texttt{0} because
% it is a single character. If we were hunting for nodes with 42 children, we'd have to write
% \texttt{where n children=\{42\}...}.}
% \begin{forestexample}[ekeynames={tier,where ,n children}]
% \begin{forest}
% ~where n children~=0{tier=word}{}
% [VP
% [DP[John]]
% [V'
% [V[sent]]
% [DP[Mary]]
% [DP[D[a]][NP[letter]]]
% ]
% ]
% \end{forest}
% \end{forestexample}
%
% Finally, let's talk about styles. Styles are simply collections of
% options. (They are not actually defined in the \foRest; package, but
% rather inherited from |pgfkeys|.) If you often want to have non-default
% parent/child anchors, say south/north as in example \ref{ex:tier-manual}, you would save some
% typing by defining a style. Styles are defined using \PGF;'s handler
% |.style|. (In the example below, style |ns_edges| is first defined and then used.)
% \begin{forestexample}[ekeynames={tier,parent anchor,child anchor}]
% \begin{forest}
% ~sn edges~/~.style~={for tree={
% parent anchor=south, child anchor=north}},
% ~sn edges~
% [VP,
% [DP[John,tier=word]]
% [V'
% [V[sent,tier=word]]
% [DP[Mary,tier=word]]
% [DP[D[a,tier=word]][NP[letter,tier=word]]]]]
% \end{forest}
% \end{forestexample}
% If you want to use a style in more than one tree, you have to define it outside the \ikeyname{forest}
% environment. Use macro \icmdname{forestset} to do this.
% \begin{lstlisting}
% ~\forestset~{
% sn edges/.style={for tree={parent anchor=south, child anchor=north}},
% background tree/.style={for tree={
% text opacity=0.2,draw opacity=0.2,edge={draw opacity=0.2}}}
% }
% \end{lstlisting}
%
% You might have noticed that the last two examples contain options (actually, keys) even before the
% first opening bracket, contradicting was said at the beginning of this section. This is mainly
% just syntactic sugar (it can separate the design and the content): such preamble
% keys behave as if they were given in the root node, the only difference (which often does not
% matter) being that they get processed before all other root node options, even the implicit
% content.
%
% \subsection{Decorating the tree}
% \label{sec:decorating}
%
% The tree can be decorated (think movement arrows) with arbitrary
% \TikZ; code.
% \begin{forestexample}
% \begin{forest}
% [XP
% [specifier]
% [X$'$
% [X$^0$]