| 1 |
% \iffalse |
| 2 |
% Copyright 2022 Jiro Senju |
| 3 |
% |
| 4 |
% This package is free software; you can redistribute it and/or modify |
| 5 |
% it under the terms of the GNU General Public License as published by |
| 6 |
% the Free Software Foundation; either version 2 of the License, or |
| 7 |
% any later version. |
| 8 |
% |
| 9 |
% This package is distributed in the hope that it will be useful, |
| 10 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
% GNU General Public License for more details. |
| 13 |
% |
| 14 |
% You should have received a copy of the GNU General Public License |
| 15 |
% along with this package. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
% \fi |
| 17 |
% |
| 18 |
% \newcommand{\tOne}{Parent-child Relationship Box or Generations Box} |
| 19 |
% \newcommand{\tTwo}{(\texttt{ft-gens.dtx})} |
| 20 |
% \section[\tOne{} \tTwo]{\tOne\\\tTwo} |
| 21 |
% |
| 22 |
% \DescribeMacro{\pcdef} |
| 23 |
% \cmd{\pcdef |
| 24 |
% \marg{new box name} |
| 25 |
% \marg{parent box name} |
| 26 |
% \marg{child box name} |
| 27 |
% } |
| 28 |
% \medskip |
| 29 |
% |
| 30 |
% Defines a parent-child relationship box. |
| 31 |
% Connects the given \meta{parent box} and \meta{child box} by a line, |
| 32 |
% and creates a new box \meta{new box name}. |
| 33 |
% |
| 34 |
% \meta{parent box} is a box who has only one line from an individual |
| 35 |
% name to one's child. For example, the box created by |\indvdldef| with |
| 36 |
% |\maleline| attribute (and equivalent) is specified. |
| 37 |
% Obviously, \meta{child box} is a box who has a line to one's parent. |
| 38 |
% For example, the box created by |\indvdldef| with |\biological| or |
| 39 |
% |\adopted| is specified as a child mark. |
| 40 |
% |
| 41 |
% |\pcdef| is a simplified version of |\gensdef|, which is discussed next. |
| 42 |
% \bigskip |
| 43 |
% |
| 44 |
% \noindent |
| 45 |
% \DescribeMacro{\gensdef} |
| 46 |
% \cmd{\gensdef |
| 47 |
% \marg{new box name} |
| 48 |
% \marg{parent box name} |
| 49 |
% \marg{list of connection-pair} |
| 50 |
% } |
| 51 |
% |
| 52 |
% \begin{tabbing} |
| 53 |
% \hspace{4em} \=\kill |
| 54 |
% \texttt{connection-pair :=}\\ |
| 55 |
% \> \marg{individual box name in the parent box}\\ |
| 56 |
% \> \marg{child box name} |
| 57 |
% \end{tabbing} |
| 58 |
% \medskip |
| 59 |
% |
| 60 |
% Defines a two-generations box. |
| 61 |
% Same to |\pcdef|, \meta{child box} is a box who has only one line to |
| 62 |
% the parent, but \meta{parent box} can have multiple lines to one's child. |
| 63 |
% It is \meta{connection-pair} that makes it clear which parent connects |
| 64 |
% to which child box. |
| 65 |
% |
| 66 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 67 |
% \subsection{Example} |
| 68 |
% |
| 69 |
% \begin{enumerate} |
| 70 |
% \item |
| 71 |
% |\sblngdef| for daughters, |\pcdef|, and then |\sblngdef| for their |
| 72 |
% parent generation. |
| 73 |
% \srcfig{fig3Robert1} |
| 74 |
% |
| 75 |
% \needspace{2\baselineskip} |
| 76 |
% \item |
| 77 |
% two |\sblngdef|, and then |\gensdef|. The result is essentially same. |
| 78 |
% One difference is the space between the siblings which was |
| 79 |
% automatically adjusted in previous example. |
| 80 |
% \srcfig{fig3Robert2} |
| 81 |
% \end{enumerate} |
| 82 |
% |
| 83 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 84 |
% \subsection{The order of connecting multiple boxes} |
| 85 |
% \label{sec:Lily1} |
| 86 |
% |
| 87 |
% If we get |\sblngdef| as a tool to align the individual boxes in |
| 88 |
% column, then |\pcdef| and |\gensdef| are the tool to align the boxes |
| 89 |
% in row. |
| 90 |
% When the siblings have their child for each, then there are multiple |
| 91 |
% parent-child relationships, so it is better to call it generations box |
| 92 |
% rather than parent-child box. |
| 93 |
% |
| 94 |
% There are two ways to draw such tree. One is to define parent-child |
| 95 |
% first and then define the siblings of the parent generation. The other |
| 96 |
% is in the reverse order, eg. to define the siblings of the parent |
| 97 |
% generation first and then define the parent-child relationship for each. |
| 98 |
% |
| 99 |
% Let's consider about these two ways. |
| 100 |
% |
| 101 |
% \begin{enumerate} |
| 102 |
% \needspace{2\baselineskip} |
| 103 |
% \item |
| 104 |
% define two parent-child relationships, and then define the siblings. |
| 105 |
% |
| 106 |
% \srcfig{fig3Lily1} |
| 107 |
% |
| 108 |
% \needspace{3\baselineskip} |
| 109 |
% \item |
| 110 |
% define the sisters, and then define the parent-child for each. |
| 111 |
% |
| 112 |
% \srcfig{fig3Lily2} |
| 113 |
% \end{enumerate} |
| 114 |
% |
| 115 |
% As you see, by the 1st method the length of two lines to their child |
| 116 |
% differs and the positions (in horizontal) of the child generation are |
| 117 |
% not equal. That makes the tree uneasy to understand straightforward. |
| 118 |
% It is because that the feature of |\sblngdef| to set the line length |
| 119 |
% to the longest one didn't work. |
| 120 |
% The argument passed to |\sblngdef| were already connected to the child, |
| 121 |
% so if |\sblngdef| extended the line it would be much worse result. |
| 122 |
% |
| 123 |
% On the other hand, by the 2nd method, the argument passed to |
| 124 |
% |\sblngdef| were not connected to the child. So it is harmless if |
| 125 |
% |\sblngdef| extends the line. |
| 126 |
% \smallskip |
| 127 |
% |
| 128 |
% Even if you took the 1st method, there still exists to make the line |
| 129 |
% length equal. |
| 130 |
% Using |\indvdldef| feature to adjust the line length, set the length |
| 131 |
% of Lily's |\femaleline| (|\matrilineal|) to the one of Petunia's. |
| 132 |
% To achieve this, calculate the difference of the name length of these |
| 133 |
% sisters and give an optional argument of |\indvdldef|. |
| 134 |
% The result should be same to above. |
| 135 |
% \medskip |
| 136 |
% |
| 137 |
% \srcfig{fig3Lily3} |
| 138 |
% \medskip |
| 139 |
% |
| 140 |
% You can get the same result if you use |\nameboxcfg| since it has a |
| 141 |
% feature to set the length of a line to child. |
| 142 |
% But it is not a good idea to use |\nameboxcfg| every time when you |
| 143 |
% |\indvdldef|. The value set by |\nameboxcfg| should be applied wider, |
| 144 |
% and it is not supposed to use for a single |\indvdldef|. It is better |
| 145 |
% to append an optional argument to |\indvdldef|. |
| 146 |
% \smallskip |
| 147 |
% |
| 148 |
% There is one more option. It is to set the length of Lily's name to Petunia's. |
| 149 |
% By this method, the space between Lily's name and the line to child |
| 150 |
% becomes wider and the length of lines become equal. |
| 151 |
% \medskip |
| 152 |
% |
| 153 |
% \srcfig{fig3Lily4} |
| 154 |
% \medskip |
| 155 |
% |
| 156 |
% The sequence or the order to define and connect the boxes is important. |
| 157 |
% In connecting the boxes, this package considers the size of the |
| 158 |
% being connected individual boxes. For example, the sibling box |
| 159 |
% considers the height of the |
| 160 |
% individual box and makes the boxes to be never overlapped. |
| 161 |
% But in connecting a child to the already defined sibling box, this |
| 162 |
% feature doesn't work. So the children of the siblings may be |
| 163 |
% overlapped. In this case, you need to insert the interval box between |
| 164 |
% the siblings manually. |
| 165 |
% |
| 166 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 167 |
% \subsectImpl |
| 168 |
% |
| 169 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 170 |
% \subsubsection{Generations box --- core} |
| 171 |
% |
| 172 |
% \iffalse |
| 173 |
% \parag{Customization} |
| 174 |
% |
| 175 |
% \DescribeMacro{\ftgenscfg} |
| 176 |
% \NoDescription |
| 177 |
% \begin{macrocode} |
| 178 |
% \newcommand{\ftgenscfg}[1]{% |
| 179 |
% } |
| 180 |
% \end{macrocode} |
| 181 |
% \fi |
| 182 |
% |
| 183 |
% \parag{Connection pair} |
| 184 |
% |
| 185 |
% \DescribeMacro{\ft@getpair} |
| 186 |
% Extracts a connection-pair from the given list, |
| 187 |
% defines the connection-point in the parent box (the former of the pair) |
| 188 |
% as |\ft@cpoint|, and defines the child box name (the latter of the |
| 189 |
% pair) as |\ft@kids|. |
| 190 |
% \smallskip |
| 191 |
% |
| 192 |
% \begin{macrocode} |
| 193 |
\def\ft@getpair#1#2#3{% connection-pair parent-box-name |
| 194 |
\ft@dbgmsg{args #1, #2, #3}% |
| 195 |
\@ifundefined{#3#1nameCY}{% |
| 196 |
\@ifundefined{#3#1mrrgCY}{% |
| 197 |
\xdef\ft@cpoint{#1nameCY}% |
| 198 |
}{% |
| 199 |
\xdef\ft@cpoint{#3#1mrrgCY}% |
| 200 |
}% |
| 201 |
}{% |
| 202 |
\xdef\ft@cpoint{#3#1nameCY}% |
| 203 |
}% |
| 204 |
\xdef\ft@kids{#2}% |
| 205 |
} |
| 206 |
% \end{macrocode} |
| 207 |
% |
| 208 |
% \parag{Top margin} |
| 209 |
% |
| 210 |
% \DescribeMacro{\def@calc@xtop} |
| 211 |
% |
| 212 |
% \begin{macrocode} |
| 213 |
\newcommand{\ft@calc@xtop}[4]{% name parent cpoint kids |
| 214 |
% top half of kids |
| 215 |
\ft@len=\dimexpr\ht\@nameuse{#4} - \@nameuse{#4nameCY}pt\relax\relax% |
| 216 |
% top half of parent cpoint |
| 217 |
\@tempskipa=\dimexpr\ht\@nameuse{#2} - \@nameuse{#3}pt\relax\relax% |
| 218 |
% |
| 219 |
\ifdim\ft@len<\@tempskipa% |
| 220 |
\ft@len=0pt% |
| 221 |
\else% |
| 222 |
\advance\ft@len -\@tempskipa% |
| 223 |
\fi% |
| 224 |
\global#1=\ft@len% |
| 225 |
} |
| 226 |
% \end{macrocode} |
| 227 |
% |
| 228 |
% \parag{Bottom margin} |
| 229 |
% |
| 230 |
% \DescribeMacro{\ft@calc@xbottom} |
| 231 |
% |
| 232 |
% \begin{macrocode} |
| 233 |
\newcommand{\ft@calc@xbottom}[4]{% name parent cpoint kids |
| 234 |
% bottom half of kids |
| 235 |
\ft@len=\@nameuse{#4nameCY}pt\relax% |
| 236 |
% bottom half of parent cpoint |
| 237 |
\@tempskipa=\@nameuse{#3}pt\relax% |
| 238 |
% |
| 239 |
\ifdim\ft@len=\@tempskipa% |
| 240 |
\ft@len=0pt% |
| 241 |
\global\setlength{\ft@depth}{\dp\@nameuse{#2}}% |
| 242 |
\ifdim\ft@depth<\dp\@nameuse{#4}% |
| 243 |
\global\setlength{\ft@depth}{\dp\@nameuse{#4}}% |
| 244 |
\fi% |
| 245 |
\else% |
| 246 |
\ifdim\ft@len<\@tempskipa% |
| 247 |
\ft@len=0pt% |
| 248 |
\global\setlength{\ft@depth}{\dp\@nameuse{#2}}% |
| 249 |
\else% |
| 250 |
\advance\ft@len -\@tempskipa% |
| 251 |
\global\setlength{\ft@depth}{\dp\@nameuse{#4}}% |
| 252 |
\fi% |
| 253 |
\fi% |
| 254 |
\global#1=\ft@len% |
| 255 |
} |
| 256 |
% \end{macrocode} |
| 257 |
% |
| 258 |
% \parag{Calculate the box size} |
| 259 |
% |
| 260 |
% \DescribeMacro{\ft@gens@size} |
| 261 |
% |
| 262 |
% \begin{macrocode} |
| 263 |
\newlength{\ft@xtop} |
| 264 |
\newlength{\ft@xbottom} |
| 265 |
\newcommand{\ft@gens@size}[2]{% parent-box connect-pair-list |
| 266 |
\@tempswatrue% |
| 267 |
\ft@width=0pt% |
| 268 |
\@for\@temptokena:=#2\do{% |
| 269 |
\expandafter\ft@getpair\@temptokena{#1}% |
| 270 |
\ft@dbgmsg{\ft@cpoint and \ft@kids}% |
| 271 |
\if@tempswa% |
| 272 |
\ft@calc@xtop{\ft@xtop}{#1}{\ft@cpoint}{\ft@kids}% |
| 273 |
\@tempswafalse% |
| 274 |
\fi% |
| 275 |
\setlength{\ft@len}{\wd\@nameuse{\ft@kids}}% |
| 276 |
\ifdim\ft@width<\ft@len% |
| 277 |
\global\ft@width=\ft@len% |
| 278 |
\fi% |
| 279 |
}% |
| 280 |
\ft@calc@xbottom{\ft@xbottom}{#1}{\ft@cpoint}{\ft@kids}% |
| 281 |
\ft@dbgmsg{xtop \the\ft@xtop, xbottom \the\ft@xbottom}% |
| 282 |
% |
| 283 |
\ft@x=\dimexpr\wd\@nameuse{#1}% - \ft@cmarkbox@length\relax% |
| 284 |
\ft@dbgmsg{x \the\ft@x}% |
| 285 |
\advance\ft@width \ft@x% |
| 286 |
\ft@dbgmsg{w \the\ft@width}% |
| 287 |
\ft@height=\dimexpr\ht\@nameuse{#1} + \ft@xtop + \ft@xbottom\relax% |
| 288 |
\ft@dbgmsg{kids H \the\ht\@nameuse{\ft@kids}}% |
| 289 |
\ft@dbgmsg{H \strip@pt\ft@height, D \strip@pt\ft@depth}% |
| 290 |
} |
| 291 |
% \end{macrocode} |
| 292 |
% |
| 293 |
% \parag{Layout} |
| 294 |
% |
| 295 |
% \DescribeMacro{\ft@gens@layout} |
| 296 |
% |
| 297 |
% \begin{macrocode} |
| 298 |
\newcommand{\ft@gens@layout}[3]{% |
| 299 |
% box-name parent-box-name {{parent-name} {child-name}, ...} |
| 300 |
\ft@newnamebox{#1}{% |
| 301 |
\edef\@w{\strip@pt\ft@width}% |
| 302 |
\edef\@h{\strip@pt\ft@height}% |
| 303 |
\begin{picture}(\@w,\@h)% |
| 304 |
\ft@dbgframe{\@w,\@h}% |
| 305 |
% |
| 306 |
\ft@y=\ft@xbottom% |
| 307 |
\ft@dbgplot{0,\strip@pt\ft@y}% |
| 308 |
\put(0,\strip@pt\ft@y){\usebox{\@nameuse{#2}}}% |
| 309 |
\advance\ft@y \@nameuse{#2nameCY}pt% |
| 310 |
\ft@namexdefstrip{#1nameCY}{\ft@y}% |
| 311 |
%\ft@namexdefstrip{#1#2nameCY}{\ft@y}% |
| 312 |
% |
| 313 |
\@for\@temptokena:=#3\do{%% |
| 314 |
\expandafter\ft@getpair\@temptokena{#2}% |
| 315 |
\ft@dbgmsg{\ft@cpoint and \ft@kids}% |
| 316 |
% |
| 317 |
\ft@y=\dimexpr\ft@xbottom + \@nameuse{\ft@cpoint}pt\relax% |
| 318 |
\ft@dbgmsg{parent cpoint \the\ft@y}% |
| 319 |
\ft@dbgplot{\strip@pt\ft@x,\strip@pt\ft@y}% |
| 320 |
% |
| 321 |
\advance\ft@y -\@nameuse{\ft@kids nameCY}pt% |
| 322 |
\ft@dbgmsg{final child y \the\ft@y}% |
| 323 |
\put(\strip@pt\ft@x,\strip@pt\ft@y){% |
| 324 |
\usebox{\@nameuse{\ft@kids}}}% |
| 325 |
\ft@namexdefstrip{#1\ft@kids Y}{\ft@y}% |
| 326 |
}% |
| 327 |
\end{picture}% |
| 328 |
}% |
| 329 |
} |
| 330 |
% \end{macrocode} |
| 331 |
% |
| 332 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 333 |
% \subsubsection{Generations box --- interface} |
| 334 |
% |
| 335 |
% \DescribeMacro{\ftgensdef} |
| 336 |
% |
| 337 |
% \begin{macrocode} |
| 338 |
\newcommand{\ftgensdef}[3]{% |
| 339 |
% box-name parent-box-name {{parent-name} {child-name}, ...} |
| 340 |
% |
| 341 |
% calculate the size of the new box |
| 342 |
\ft@gens@size{#2}{#3}% |
| 343 |
% |
| 344 |
% draw them all |
| 345 |
\ft@gens@layout{#1}{#2}{#3}% |
| 346 |
% |
| 347 |
\@ifundefined{#2hascmark}{}{% |
| 348 |
\ft@namexdef{#1hascmark}{\@nameuse{#2hascmark}}% |
| 349 |
}% |
| 350 |
\ft@nameboxsz{#1}{\ft@height}{\ft@depth}% |
| 351 |
} |
| 352 |
\ft@alias{gensdef} |
| 353 |
% \end{macrocode} |
| 354 |
% |
| 355 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 356 |
% \subsubsection{Parent-child box --- interface} |
| 357 |
% |
| 358 |
% \DescribeMacro{\ftpcdef} |
| 359 |
% |
| 360 |
% \begin{macrocode} |
| 361 |
\newcommand{\ftpcdef}[3]{% box-name parent-box-name child-box-name |
| 362 |
\ftgensdef{#1}{#2}{{#2}{#3}}% |
| 363 |
} |
| 364 |
\ft@alias{pcdef} |
| 365 |
% \end{macrocode} |