summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/gtrlib-largetrees/gtrlib.largetrees.dtx
blob: 2540c14ca34deff4878548fd1822c958e89e187d (plain)
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
% \iffalse meta-comment
%
% Copyright (C) 2015-2018 by Richard Grewe <r-g+tex@posteo.net>
% -------------------------------------------------------
% 
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% 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.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{gtrlib.largetrees.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{gtrlib.largetrees}
%<*package>
    [2018/11/02 v1.2b Package providing extended options for the genealogytree package]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[columns=2]{idxlayout}
\usepackage{enumitem}
\usepackage[style=alphabetic,backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{GenealogyTreeDoc,
	author = {Thomas F. Sturm},
	date   = {2016-07-29},
	title  = {genealogytree -- Manual for version 1.01},
	url    = {http://mirrors.ctan.org/macros/latex/contrib/genealogytree/genealogytree.pdf},
	urldate= {2016-12-23},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{filecontents}{example.gauss.graph}
parent {
  g[id=GauxCarl1777]{
    male,
    name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
    birth={1777-04-30}{Braunschweig (Niedersachsen)},
    death={1855-02-23}{G\"ottingen (Niedersachsen)},
    comment={Mathematiker, Astronom, Geod\"at und Physiker},
    image={Carl_Friedrich_Gauss.jpg},
  }
  parent[id=GoosEgge1735]{
    g[id=GauxGebh1743]{
      male,
      name={\pref{Gebhard} Dietrich \surn{Gau\ss{}}},
      birth={1743-02-13}{Braunschweig (Niedersachsen)},
      death={1808-04-14}{Braunschweig (Niedersachsen)},
      %comment={G\"artner, Wasserkunstmeister, Rechnungsf\"uhrer},
    }
    parent[id=GoosLbtk1705]{
      g[id=GoosJyrg1715]{
        male,
        name={\pref{J\"urgen} \surn{Gooss}},
        birth={1715}{V\"olkenrode (Niedersachen)},
        death={1774-07-05}{Braunschweig (Niedersachsen)},
        comment={Lehmmaurer},
      }
      p[id=GoosHinr1655]{
        male,
        name={\pref{Hinrich} \surn{Gooss}},
        birth={(caAD)1655}{},
        death={1726-10-25}{V\"olkenrode (Niedersachen)},
      }
      p[id=LxtkKath1674]{
        female,
        name={\pref{Katharina} \surn{L\"utken}},
        birth={1674-08-19}{V\"olkenrode (Niedersachen)},
        marriage={1705-11-24}{V\"olkenrode (Niedersachen)},
        death={1749-04-15}{V\"olkenrode (Niedersachen)},
      }
    }
    p[id=EggeKath1710]{
      female,
      name={\pref{Katharina} Magdalena \surn{Eggenlings}},
      birth={(caAD)1710}{Rethen},
      marriage={(caAD)1735}{V\"olkenrode (Niedersachen)},
      death={1774-04-03}{Braunschweig (Niedersachsen)},
    }
  }
  parent[id=BentKron1740]{
    g[id=BenzDoro1743]{
      female,
      name={\pref{Dorothea} \surn{Benze}},
      birth={1743-06-18}{Velpke (Niedersachsen)},
      marriage={1776-04-25}{Velpke (Niedersachsen)},
      death={1839-04-18}{G\"ottingen (Niedersachsen)},
      comment={Steinhauerstochter},
    }
    parent[id=BentBbbb1740]{
      g[id=BentChri1717]{
        male,
        name={\pref{Christoph} \surn{Bentze}},
        birth={1717}{Velpke (Niedersachsen)},
        death={1748-09-01}{Velpke (Niedersachsen)},
        %comment={Steinhauer},
      }
      p[id=BentAndr1687]{
        male,
        name={\pref{Andreas} \surn{Bentze}},
        birth={1687-02}{},
        death={(caAD)1750}{Velpke (Niedersachsen)},
      }
    }
    p[id=KronKath1710]{
      female,
      name={\pref{Katharina} \surn{Krone}},
      birth={(caAD)1710}{},
      death={1743/}{Velpke (Niedersachsen)},
    }
  }
}
\end{filecontents}
\usepackage{showexpl}
\lstset{gobble=2,frame=trbl,rframe={},backgroundcolor=\color{black!5!white}}
\lstset{explpreset={numbers=none,columns=fixed,basicstyle=\footnotesize\ttfamily}}
\lstset{overhang=2cm,pos=r,varwidth=true}
\lstset{preset={\small\sffamily
  \renewcommand\gtruselibrary[1]{}}}
\usepackage{pbox}
\newcommand\NiceDescribeStuff[2]{% #1=margin text, #2=body text
  \medskip\par\noindent\leavevmode%
  \marginpar{\hfill\pbox[t]{2\marginparwidth}{\ttfamily #1}%
    \hspace*{-\marginparsep}}%
  \ifstrempty{#2}{}{#2\smallskip\\}}
\newcommand\NiceDescribeEnv[2]{% #1=envname, #2=parameters
  \NiceDescribeStuff{%
    \textcolor{gray}{\cs{begin}}\string{#1\string}\\
    \textcolor{gray}{\cs{end}}\string{#1\string}}{#2}}
\newcommand\NiceDescribeMacro[2]{% #1=macro, #2=parameters
  \NiceDescribeStuff{\hbox to 0pt{\hss\string#1}}{#2}}
\newcommand\NiceDescribeConstant[1]{% #1=constant
  \NiceDescribeStuff{\hbox to 0pt{\hss #1\quad}}{}\ignorespaces}
\usepackage[templates]{genealogytree}[2017/01/29 version 1.10]
\gtruselibrary{largetrees}
\usepackage{hypdoc}
\usepackage[capitalise,nameinlink]{cleveref}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{gtrlib.largetrees.dtx}
  \PrintChanges
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \changes{v1.0}{2016/12/23}{Initial version}
% \changes{v1.1}{2017/01/24}{Split into package and library}
% \changes{v1.2}{2017/02/19}{Profession field went to genealogytree package}
% \changes{v1.2b}{2018/11/02}{Package author's name change}
%
% \GetFileInfo{gtrlib.largetrees.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment,\def,\gdef,\edef}
%
%
% \title{The \textsf{gtrlib.largetrees} package\thanks{This document
%   corresponds to \textsf{gtrlib.largetrees}~\fileversion, dated \filedate.
%   The package is available online at
%   \url{https://github.com/Ri-Ga/gtrlib.largetrees}.}}
% \author{Richard Grewe \\ \texttt{r-g+tex@posteo.net}}
%
% \maketitle
%
% \section{Introduction}
%
% The main goal of the \textsf{gtrlib.largetrees} package is to offer
% additional database fields and formats for the \textsf{genealogytree}
% package, particularly for typesetting large trees.
% This package is the side product of typesetting an actual genealogy tree
% with almost 400 persons on 16 levels and on a DIN-A0 poster.
% The package provides the following extensions:
% \begin{description}
% \item[database fields:]\leavevmode
%   \begin{itemize}[nosep]
%   \item spouse, spousebirth, spousedeath
%   \item children
%   \end{itemize}
% \item[formats:]\leavevmode
%   \begin{itemize}[nosep]
%   \item Person+Marriage+Children+Profession
%   \end{itemize}
% \item[node processors:]\leavevmode
%   \begin{itemize}[nosep]
%   \item sparse node processor
%   \end{itemize}
% \end{description}
% In the following, each of the extensions is described and illustrated
% individually.
%
% To use the package, use
% \begin{LTXexample}
% \usepackage{genealogytree}
% \gtruselibrary{largetrees}
% \end{LTXexample}
% or
% \begin{LTXexample}
% \usepackage{gtrlib.largetrees}
% \end{LTXexample}
% Note that the following approach does \emph{not} work:
% \begin{itemize}[nosep]
% \item |\usepackage[largetrees]{genealogytree}|
% \end{itemize}
%
% \section{Database Fields}
%
% \subsection{Spouse}
%
% Sometimes, basic information about the spouse of a person is nice to
% have in a genealogy tree but a separate node in the tree would occupy
% too much space. For instance, if you have a person in the main line of
% ancestors, then you might also want to show a node for the sister of
% that person. However, a separate node for her spouse might be too much.
% In such a case, the database fields |spouse|, |spousebirth|, and
% |spousedeath| can come handy.
%
% The |spouse| field can be used for the specification of the name of
% the spouse. The |spousebirth| and |spousedeath| fields can be used
% for specifying the birth and death events of the spouse. For these
% events, the values are expected to be of the same format as other
% events, such as the |birth| and |death| fields. In particular this
% means that date and location can be specified.
% The following example shows the usage of the fields at the example of
% Gauss' first wife:
% \begin{LTXexample}
% \begin{genealogypicture}[processing=database,
%   database format=person marriage children profession]
% sandclock{ child{
%   g[id=GauxCarl1777]{male,
%     name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
%     birth={1777-04-30}{Braunschweig (Niedersachsen)},
%     death={1855-02-23}{G\"ottingen (Niedersachsen)},
%     marriage={1805-10-09}{Braunschweig (Niedersachsen)},
%     spouse={\pref{Johanna} Elisabeth Rosina \surn{Osthoff}},
%     spousebirth={1780-05-08}{Braunschweig (Niedersachsen)},
%     spousedeath={1809-10-11}{G\"ottingen (Niedersachsen)},
%   }}}
% \end{genealogypicture}
% \end{LTXexample}
%
% Note that currently only information about a single spouse can be
% specified through the fields provided by this package.
%
% \subsection{Children}
%
% When one wants to have information about children in a genealogy tree
% but cannot spend the space for separate nodes, then one can use the
% |children|, |children-|, and |children+| keys provided by this package.
% The following describes the individual keys and provides an illustration,
% again using data from Gauss' first marriage \cite[Section~2.3.5]{GenealogyTreeDoc}.
% \begin{itemize}
% \item Use |children+={some infos}| for providing arbitrarily formatted
%   information about children.
%   \begin{LTXexample}
% \begin{genealogypicture}[processing=database,
%   database format=person marriage children profession]
% sandclock{ child{
%   g[id=GauxCarl1777]{male,
%     name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
%     birth={1777-04-30}{Braunschweig (Niedersachsen)},
%     death={1855-02-23}{G\"ottingen (Niedersachsen)},
%     children+={Carl (\gtrsymBorn\,1806),
%       Wilhelmina (\gtrsymBorn\,1808),
%       Ludwig (\gtrsymBorn\,1809)},
%   }}}
% \end{genealogypicture}
%   \end{LTXexample}
% \item Use |children={D}{S}| to specify that the person has |D|
%   daughters and |S| sons.
%   \begin{LTXexample}
% \begin{genealogypicture}[processing=database,
%   database format=person marriage children profession]
% sandclock{ child{
%   g[id=GauxCarl1777]{male,
%     name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
%     birth={1777-04-30}{Braunschweig (Niedersachsen)},
%     death={1855-02-23}{G\"ottingen (Niedersachsen)},
%     children={1}{2},
%   }}}
% \end{genealogypicture}
%   \end{LTXexample}
% \item Use |children-=N| for providing only the overall number of
%   children of the person.
%   \begin{LTXexample}
% \gtrset{language=german}
% \begin{genealogypicture}[processing=database,
%   database format=person marriage children profession]
% sandclock{ child{
%   g[id=GauxCarl1777]{male,
%     name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
%     birth={1777-04-30}{Braunschweig (Niedersachsen)},
%     death={1855-02-23}{G\"ottingen (Niedersachsen)},
%     children-={3},
%   }}}
% \end{genealogypicture}
%   \end{LTXexample}
%   Note that we show here also that the text ``children'' changes
%   with the selected language.
% \end{itemize}
%
% \section{Database Formats}
% \label{sec:db-formats}
%
% This package extends \textsf{genealogytree}'s list of formats for
% displaying database entries \cite[Section~7.3.5]{GenealogyTreeDoc}.
%
% \subsection{Person+Marriage+Children+Profession}
% \label{sec:format-PMCP}
%
% This format is close to the format ``medium marriage below'', which
% is defined by the \textsf{genealogytree} package. The format can be
% selected by the |database format| key, as shown in the previous examples.
% The format displays
% \begin{enumerate}[nosep]
% \item name, birth, and death of the person
% \item a comment, if provided
% \item the marriage event and the spouse
% \item the children
% \item the profession
% \end{enumerate}
% The following long example shows a full example, based on combined
% data from the previous examples.
% \begin{LTXexample}
% \begin{genealogypicture}[processing=database,
%   database format=person marriage children profession]
% sandclock{ child{
%   g[id=GauxCarl1777]{male,
%     name={Johann \pref{Carl Friedrich} \surn{Gau\ss{}}},
%     birth={1777-04-30}{Braunschweig (Niedersachsen)},
%     death={1855-02-23}{G\"ottingen (Niedersachsen)},
%     marriage={1805-10-09}{Braunschweig (Niedersachsen)},
%     spouse={\pref{Johanna} Elisabeth Rosina \surn{Osthoff}},
%     spousebirth={1780-05-08}{Braunschweig (Niedersachsen)},
%     spousedeath={1809-10-11}{G\"ottingen (Niedersachsen)},
%     children={1}{2},
%     profession={Mathematiker, Astronom, Geod\"at und Physiker},
%   }}}
% \end{genealogypicture}
% \end{LTXexample}
%
% \section{Node Processors}
%
% \subsection{Sparse node processor}
%
% The sparse node processor serves the purpose of saving space by
% rotating nodes for which only few database fields are set.
% This follows the consideration that horizontally displayed nodes
% have the advantage of being easily readable, but require a rather wide
% display for a nice appearance. In a large genealogy tree with many nodes
% on a level, space can be saved by rotating those nodes for which only
% few database fields are set. The sparse node processor allows one
% to enable rotation dependent on how much information is available for
% a node, rather than merely on the level of the node or whether the
% node is a leaf or inner node.
% The sparse node processor inherits from the ``fit'' processor defined
% by the \textsf{genealogytree} package \cite[Section~6.2.1]{GenealogyTreeDoc}.
%
% The sparse node processor can be configured by several options.
% Some of these options can be set globally, some also for individual levels.
% The following options are defined:
% \begin{description}[style=nextline]
% \item[|sparse display|:] enables the node processor.
% \item[\texttt{sparse node size from=\meta{min} to \meta{max}}:]
%   sets minimum and maximum width of sparse nodes.
% \item[\texttt{sparse max fields=\meta{N}}:]
%   defines the maximum number \meta{N} of database fields
%   of a person with which the node is still considered sparse and,
%   therefore, displayed specially (rotated).
% \item[\texttt{sparse inner from level=\meta{N}}:]
%   specifies that inner nodes shall be
%   displayed specially only if they are above or on level \meta{N}.
% \item[\texttt{sparse leaf from level=\meta{N}}:]
%   specifies that leaf nodes shall be
%   displayed specially only if they are above or on level \meta{N}.
% \item[|sparse inner never|:] specifies that inner nodes shall never
%   be displayed specially.
% \end{description}
%
% The following example shows the use and the effect of the options in an
% example, again based on the tree for Gauss. Concretely, the example
% demonstrates the following settings:
% \begin{itemize}[nosep]
% \item a node is considered sparse if at most 2 fields are defined:
%    Hinrich Gooss (2 fields) is rotated,
%    Katharina Lütken (3 fields) is not rotated;
% \item inner nodes get special display earliest from level 2:
%    Christoph Bentze (2 fields and on level 2) is rotated,
%    Gebhard Dietrich Gau\ss{} (sparse due to only 2 fields,
%    but on level 1) is not rotated);
% \item leaf nodes get special display earliest from level 3:
%    Katharina Krone (2 fields but on level 2) is not rotated,
%    Andreas Bentze (2 fields and on level 3) is rotated;
% \item sparse nodes on levels 3 and 2 have different width settings.
% \end{itemize}
% \begin{LTXexample}[pos=t,justification=\centering]
% \usepackage[templates]{genealogytree}
% \begin{genealogypicture}[template=database pole,
%     database format=person marriage children profession,
%     level size=2.5cm, node size=3cm,
%     level 3/.style={sparse node size from=0.4cm to 1.2cm},
%     sparse node size from=1cm to 2cm,
%     sparse max fields=2,
%     sparse inner from level=2,
%     sparse leaf from level=3,
%     sparse display,
%     options for node={GauxCarl1777}{pivot},
%   ]
%   input{example.gauss.graph}
% \end{genealogypicture}
% \end{LTXexample}
%
% Note that sparse node display currently is only possible for the
% database formats defined in \cref{sec:db-formats}. For enabling it
% in combination with other database formats, the
% |\gtrltDeclareFieldCount|\marg{db-format}\marg{macro} has to be used
% (see the use of this macro in the implementation of the database formats
% provided by this package).
%
% \printbibliography
% \clearpage
% \appendix
%
% \StopEventually{}
% \section{Implementation}
%
% \subsection{Wrapper Package}
%
%\iffalse
%<*package>
%\fi
% The package has the following dependencies:
%    \begin{macrocode}
\RequirePackage{genealogytree}[2017/01/29 version 1.10]
\gtruselibrary{largetrees}
%    \end{macrocode}
%
% The remaining code provides the \textsf{largetrees} library
% for the \textsf{genealogytree} package.
%\iffalse
%</package>
%<*gtrlib>
%\fi
%
% \subsection{Dependencies}
%
% The library has the following dependencies:
%    \begin{macrocode}
\RequirePackage{etoolbox}
%    \end{macrocode}
%
% \subsection{Database Fields}
%
% \subsubsection{Spouse}
% This adds three new fields for providing information about the spouse
% of a person, within the same node. The fields are for specifying
% the name of the spouse as well as the birth date and the day of death.
% \begin{macro}{\gtrDBspouse}
% The |\gtrDBspouse| macro holds what is provided for the
% |spouse| key of a database entry (this macro is defined
% by |\gtr@db@new@store|).
%    \begin{macrocode}
\gtr@db@new@store{spouse}
\gtr@db@new@event@store{spousebirth}
\gtr@db@new@event@store{spousedeath}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\gtrifspousedefined}
% The |\gtrifspousedefined|\marg{true}\marg{false} macro expands to
% \meta{true} if the spouse of a database entry is defined, and
% expands to \meta{false} otherwise. The distinction is made solely
% on the |spouse| field -- i.e., |spousebirth| and |spousedeath|
% are ignored.
% This macro can be used, for instance, by database formats
% (see \cref{sec:impl-database-formats}).
%    \begin{macrocode}
\def\gtrifspousedefined#1#2{\ifdefvoid{\gtrDBspouse}{#2}{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\gtrPrintSpouse}
% \begin{macro}{\gtrPrintSpouseDetails}
% The |\gtrPrintSpouseDetails| macro prints the name of the spouse
% as well as the birth and death of the spouse, if provided by the
% database entry. The |\gtrPrintSpouse| macro only prints the name.
%    \begin{macrocode}
\newcommand\gtrPrintSpouse{\gtrDBspouse}
\newcommand\gtrPrintSpouseDetails{%
  \gtrPrintSpouse
  \begin{gtrprintlist}{\unskip\ (}{\unskip,\ }{\unskip)}{\unskip}%
    \gtrifeventdefined{spousebirth}%
      {\gtrlistseparator\gtrPrintEventPrefix{birth}\,%
       \gtrPrintDate{spousebirth}}%
      {}%
    \gtrifeventdefined{spousedeath}%
      {\gtrlistseparator\gtrPrintEventPrefix{death}\,%
       \gtrPrintDate{spousedeath}}%
      {}%
  \end{gtrprintlist}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Children}
% This adds a field for providing information about the
% children of a person, within the same node.
% \begin{macro}{\gtrDBchildren}
% \begin{macro}{\gtrDBdaughters}
% \begin{macro}{\gtrDBsons}
% If detailed information about children is provided through the
% |children+| key, then the |\gtrDBchildren| holds this detailed
% information. Otherwise, i.e., if information about children is
% provided through the |children-| or |children| key, then
% |\gtrDBchildren| holds the number of children of the person.
% The |\gtrDBdaughters| and |\gtrDBsons| macros store the number
% of daughters and, respectively, sons of the person.
%    \begin{macrocode}
\gtrset{%
  database/children/.code n args={2}{%
    \numdef\gtrDBchildren{#1+#2}%
    \def\gtrDBdaughters{#1}%
    \def\gtrDBsons{#2}},%
  database/children-/.store in=\gtrDBchildren,
  database/children+/.store in=\gtrDBchildren,
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\gtrifchildrendefined}
% The |\gtrifchildrendefined|\marg{true}\marg{false} macro expands to
% \meta{true} if information about children of a database entry is
% defined, and expands to \meta{false} otherwise.
% This macro can be used, for instance, by database formats
% (see \cref{sec:impl-database-formats}).
%    \begin{macrocode}
\def\gtrifchildrendefined#1#2{\ifdefvoid{\gtrDBchildren}{#2}{#1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\gtrPrintChildren}
% The |\gtrPrintChildren| macro prints information about the children of
% a person.
%    \begin{macrocode}
\def\gtrPrintChildren{%
  \gtrTranslatedChildren:
%    \end{macrocode}
% If |\gtrDBdaughters| is defined, then information about children
% must have been provided by the |children| key -- that is, numbers of
% daughters and sons have been provided. Otherwise information about
% children was provided though the |children+| (arbitrarily formatted
% information) or |children-| (number of children in total) keys,
% in which cases this information is printed as is.
%    \begin{macrocode}
    \ifdefvoid{\gtrDBdaughters}%
      {\gtrDBchildren}%
      {\gtrDBdaughters\kern0.5pt\gtrsymFemale~%
       \gtrDBsons\kern0.5pt\gtrsymMale}}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Node Processors}
%
% \subsubsection{Sparse Node Processor}
%
% The following defines the keys that can be used for enabling and
% configuring sparse node display.
%    \begin{macrocode}
\gtrset{%
%    \end{macrocode}
% The |sparse display| key enables the node processor.
%    \begin{macrocode}
  sparse display/.style={node processor=\gtrltSparseNodeProcessor},
%    \end{macrocode}
% The |sparse node size from| sets minimum and maximum width of
% sparse nodes.
%    \begin{macrocode}
  sparse node size from/.code args={#1 to #2}{%
    \dimdef\gtr@@kv@@gtrlt@sparsenode@minsize{#1}%
    \dimdef\gtr@@kv@@gtrlt@sparsenode@maxsize{#2}},
%    \end{macrocode}
% The |sparse max fields| defines the maximum number of fields
% of a person with which the node is still considered sparse.
%    \begin{macrocode}
  sparse max fields/.code={%
    \gdef\gtrlt@sparse@maxfields{#1}},%
%    \end{macrocode}
% The following three options specify when sparse nodes are displayed specially.
% The |sparse inner from level| option specifies that inner nodes shall be
% displayed specially only if they are above or equal a particular level.
%    \begin{macrocode}
  sparse inner from level/.code={\def\gtrlt@sparseinner@level{#1}},
%    \end{macrocode}
% The |sparse leaf from level| option specifies that leaf nodes shall be
% displayed specially only if they are above or equal a particular level.
%    \begin{macrocode}
  sparse leaf from level/.code={\def\gtrlt@sparseleaf@level{#1}},
%    \end{macrocode}
% The |sparse inner never| option specifies that inner nodes shall never
% be displayed specially.
%    \begin{macrocode}
  sparse inner never/.code={\undef\gtrlt@sparseinner@level},
}
%    \end{macrocode}
%
% The following registers the level-local macros used by the above
% options.
%    \begin{macrocode}
\gtr@proc@register@level@local{\gtrlt@sparsenode@minsize}
\gtr@proc@register@level@local{\gtrlt@sparsenode@maxsize}
%    \end{macrocode}
%
% \begin{macro}{\gtrltSparseNodeProcessor}
% The |\gtrltSparseNodeProcessor| is a node processor that inherits
% from the ``fit'' node processor, which it augments by means for
% displaying sparse nodes rotated.
%    \begin{macrocode}
\newcommand\gtrltSparseNodeProcessor{%
  \gtrltIfSparseEnabled{\gtrltIfSparse{%
    \let\gtrNodeMinWidth=\gtrlt@sparsenode@minsize%
    \let\gtrNodeMaxWidth=\gtrlt@sparsenode@maxsize%
    \gtrkeysappto\gtrNodeBoxOptions{%
      rotate=90,gtrNodeDimensionsLandscape,%
    }%
  }{}}{}%
  \csuse{gtr@boxcontent@fit}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\gtrltIfSparseEnabled}
% Sparse display is enabled for leaf parent and leaf nodes
% and (if sparse display is desired for inner nodes) for
% inner nodes above the configured level. The
% |\gtrltIfSparseEnabled|\marg{true}\marg{false} macro checks
% the current node for whether these properties are satisfied
% and expands to \meta{true} if this is the case and \meta{false}
% otherwise.
%    \begin{macrocode}
\newcommand\gtrltIfSparseEnabled{%
  \gtrifleaf
    {\ifdef\gtrlt@sparseleaf@level%
%    \end{macrocode}
% For leaf nodes, if a mimimum level is specified (via
% |sparse leaf from level|), then
% sparse display is enabled if the node's level is greater or equal
% than the specified minimum:
%    \begin{macrocode}
      {\ifnumgreater{1+\gtrnodelevel}{\gtrlt@sparseleaf@level}}%
%    \end{macrocode}
% If a mimimum level for leaf nodes is not specified, then sparse
% display is enabled no matter the node's level:
%    \begin{macrocode}
      {\@firstoftwo}}%
    {\ifdef\gtrlt@sparseinner@level%
%    \end{macrocode}
% For inner nodes, if a mimimum level is specified (via
% |sparse inner from level|), then
% sparse display is enabled if the node's level is greater or equal
% than the specified minimum:
%    \begin{macrocode}
      {\ifnumgreater{1+\gtrnodelevel}{\gtrlt@sparseinner@level}}%
%    \end{macrocode}
% If a mimimum level for inner nodes is not specified, then sparse
% display is disabled no matter the node's level:
%    \begin{macrocode}
      {\@secondoftwo}}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\gtrltFieldCount}
% \begin{macro}{\gtrltIfSparse}
% The |\gtrltIfSparse|\marg{true}\marg{false} macro uses database format
% specific code to count the number of fields available for a node
% and expands to \meta{true} if this number is less than or equal the
% maximum number of fields for sparse display (specified by
% |sparse max fields|). Otherwise, the macro expands to \meta{false}.
% |\gtrltFieldCount| is a counter used internally by the macro.
%    \begin{macrocode}
\newcount\gtrltFieldCount
\newcommand\gtrltIfSparse{%
  \gtrltFieldCount=0\relax
  \gtrltCountDatabaseFields
%    \end{macrocode}
% Decrement the counter for using |\ifnumless| comparison below
% rather than ``less-or-equal'' (for which there is no conditional):
%    \begin{macrocode}
  \advance\gtrltFieldCount by-1\relax%
  \ifnumless{\the\gtrltFieldCount}{\gtrlt@sparse@maxfields}}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
% \begin{macro}{\gtrltDeclareFieldCount}
% The |\gtrltDeclareFieldCount|\marg{db-format}\marg{macro}
% registers, for the given database format \meta{db-format},
% macro code \marg{macro} for counting the number of
% displayed database fields. The \meta{macro} must ensure that,
% after expansion, the counter |\gtrltFieldCount| holds the
% number of fields.
%    \begin{macrocode}
\newcommand\gtrltDeclareFieldCount[2]{%
  \gtrset{database format/#1/.append code={%
    \def\gtrltCountDatabaseFields{#2}}}}
%    \end{macrocode}
%  \end{macro}
%
% \begin{macro}{\gtrltFieldCountByConditionals}
% The |\gtrltFieldCountByConditionals|\marg{cond-list} macro counts
% the number of satisfied conditionals in the comma-separated list
% \meta{cond-list} of conditionals. This number is returned in the
% |\gtrltFieldCount| counter.
%    \begin{macrocode}
\newcommand\gtrltFieldCountByConditionals[1]{%
%    \end{macrocode}
% The |\do|\marg{conditional} macro increases |\gtrltFieldCount|
% if \meta{conditional} is true and otherwise does nothing. For this,
% the \meta{conditional} must be a macro with two argument, expanding
% to the first argument if the conditional is true, and to the second
% argument otherwise.
%    \begin{macrocode}
  \def\do##1{%
    ##1{\advance\gtrltFieldCount by1\relax}{}}%
  \gtrltFieldCount=0\relax
  \docsvlist{#1}}
%    \end{macrocode}
%  \end{macro}
%
%
% \subsection{Database Formats}
% \label{sec:impl-database-formats}
%
% \subsubsection{Person+Marriage+Children+Profession}
% The following code defines the format
% ``\texttt{person marriage children profession}''.
%    \begin{macrocode}
\gtrDeclareDatabaseFormat{person marriage children profession}{}{%
  \gtrPrintName%
  \begin{gtreventlist}%
    \gtr@list@event@birth%
    \gtr@list@event@death%
  \end{gtreventlist}%
  \gtrifcommentdefined{\gtrPrintComment}{}%
  \gtr@ifmarriagedefined{\tcbline
    \begin{gtreventlist}
       \gtr@list@event@marriage
       \gtrifspousedefined{
         \gtrTranslatedWith\ \gtrPrintSpouseDetails}{}%
       \gtrifchildrendefined{, \gtrPrintChildren}{}%
    \end{gtreventlist}}{%
    \gtrifchildrendefined{\tcbline\gtrPrintChildren}{}}%
  \gtrifprofessiondefined{\tcbline\gtrPrintProfession}{}%
}
%    \end{macrocode}
% Specify how the number of displayed database fields of a node
% are counted:
%    \begin{macrocode}
\gtrltDeclareFieldCount{person marriage children profession}{%
  \gtrltFieldCountByConditionals{%
    \gtrifeventdefined{birth},
    \gtrifeventdefined{death},
    \gtrifeventdefined{marriage},
    \gtrifcommentdefined,
    \gtrifspousedefined,
    \gtrifchildrendefined,
    \gtrifprofessiondefined,
  }}
%    \end{macrocode}
%
%
% \subsection{Translations}
% For text to be displayed in nodes (for instance because there is no
% established symbol for the respective), we provide some additional
% small translation facility. This feature is complementary to the
% symbols facility provided by the \textsf{genealogytree} package.
% \begin{macro}{\gtrlt@texttranslation@add}
% The |\gtrlt@texttranslation@add|\marg{identifier} adds the
% \meta{identifier} to the list of understood translatables
% and provides a macro \cs{gtrTranslated\meta{identifier}} through
% which the translation for the chosen language can be accessed.
%    \begin{macrocode}
\newcommand\gtrlt@texttranslation@add[1]{%
  \begingroup\edef\x{\endgroup\noexpand\gtrset{%
    textlang/#1/.store in=\expandonce{%
      \csname gtrTranslated#1\endcsname}}}\x}
%    \end{macrocode}
% \end{macro}
% The following are the identifiers for which there are translations.
%    \begin{macrocode}
\gtrlt@texttranslation@add{Children}
\gtrlt@texttranslation@add{With}
%    \end{macrocode}
% The following are the actual translations used by this library.
% We encapsulate the code in an |\AtBeginDocument| such that the
% |append code| portion is ensured to be run after
% \textsf{genealogytree} set its language code. This allows the
% user of the library to use |\gtrset{language=XXX}| in the
% preamble as well as in the document without any changes to the
% normal use in \textsf{genealogytree}.
%    \begin{macrocode}
\AtBeginDocument{
  \gtrset{language@/english/.append code={%
    \gtrset{textlang/.cd,
      Children=children,
      With=with,
    }
  }}
  \gtrset{language@/german/.append code={%
    \gtrset{textlang/.cd,
      Children=Kinder,
      With=mit,
    }
  }}
  \gtrset{language=\gtrlanguagename}}
%    \end{macrocode}
%
%\iffalse
%</gtrlib>
%\fi
% \Finale
\endinput