| 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 |
% \section{Sibling Box (\texttt{ft-sibling.dtx})} |
| 19 |
% |
| 20 |
% \DescribeMacro{\sblngdef} |
| 21 |
% \cmd{\sblngdef |
| 22 |
% \marg{new box name} |
| 23 |
% \marg{name list of individual boxes} |
| 24 |
% } |
| 25 |
% \medskip |
| 26 |
% |
| 27 |
% \marg{name list of individual boxes} is the comma separated box names |
| 28 |
% which are defined by |\indvdldef|. |
| 29 |
% They are aligned and connected by a line. |
| 30 |
% All names are NOT \CS{} (no backslash). |
| 31 |
% |
| 32 |
% If any of the siblings has a |\maleline| attribute, then the length of |
| 33 |
% all lines are set to the longest one. |
| 34 |
% \medskip |
| 35 |
% |
| 36 |
% Like |\indvdldef|, |\sblngdef| defines a few connection points (\CS) |
| 37 |
% to be used later. The origin is left-bottom of the box and the unit is |pt|. |
| 38 |
% |
| 39 |
% \begin{itemize} |
| 40 |
% \item \meta{box name}|nameCY| |
| 41 |
% \par |
| 42 |
% Center of the line which connects all the siblings. |
| 43 |
% \par |
| 44 |
% The line begins at the head of the child-mark of the |
| 45 |
% first element of the given list, and ends at the last element. |
| 46 |
% |
| 47 |
% \item \meta{box name}\meta{individual box name}|nameCY| |
| 48 |
% \par |
| 49 |
% Center of the height for each individual name. |
| 50 |
% \par |
| 51 |
% In other words, shifted \meta{individual box name}|nameCY| which |
| 52 |
% |\indvdldef| defined. |
| 53 |
% \end{itemize} |
| 54 |
% \medskip |
| 55 |
% |
| 56 |
% \noindent |
| 57 |
% \DescribeMacro{\ivaldef} |
| 58 |
% \cmd{\ivaldef |
| 59 |
% \marg{new box name} |
| 60 |
% \marg{length} |
| 61 |
% } |
| 62 |
% \medskip |
| 63 |
% |
| 64 |
% Sometimes an extra space is necessary between the siblings who have |
| 65 |
% many descendants. |
| 66 |
% For such spaces, you can define an interval box by |\ivaldef|. It |
| 67 |
% defines an blank box who has a specified size. There are three |
| 68 |
% pre-defined interval boxes, |\ival|, |\ivali|, and |\ivalii|. They |
| 69 |
% have the size of |0.5em|, |1em|, |2em| for each. |
| 70 |
% |
| 71 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 72 |
% \subsection{Customization} |
| 73 |
% |
| 74 |
% \DescribeMacro{\sblngboxcfg} |
| 75 |
% \cmd{\sblngboxcfg |
| 76 |
% \marg{space between the siblings} |
| 77 |
% } |
| 78 |
% |
| 79 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 80 |
% \subsection{Example} |
| 81 |
% |
| 82 |
% \begin{enumerate} |
| 83 |
% \item |
| 84 |
% \srcfig{fig2base} |
| 85 |
% |
| 86 |
% \item |
| 87 |
% \srcfig{fig2sis} |
| 88 |
% |
| 89 |
% \item |
| 90 |
% \srcfig{fig2ival} |
| 91 |
% \end{enumerate} |
| 92 |
% |
| 93 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 94 |
% \subsectImpl |
| 95 |
% |
| 96 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 97 |
% \subsubsection{Interval box} |
| 98 |
% |
| 99 |
% \DescribeMacro{\ftivaldef} |
| 100 |
% \DescribeMacro{\ivaldef} |
| 101 |
% |
| 102 |
% \begin{macrocode} |
| 103 |
\newcommand{\ftivaldef}[2]{% box-name length |
| 104 |
\ft@newnamebox{#1}{\vbox to #2{\hsize=1pt}}% |
| 105 |
\ft@len=#2% |
| 106 |
\ft@namexdefstrip{#1ival}{\ft@len}% just a flag |
| 107 |
\divide\ft@len 2% |
| 108 |
\ft@namexdefstrip{#1nameCY}{\ft@len}% |
| 109 |
} |
| 110 |
\ft@alias{ivaldef} |
| 111 |
% \end{macrocode} |
| 112 |
% |
| 113 |
% \parag{Pre-defined interval boxes} |
| 114 |
% |
| 115 |
% \DescribeMacro{\ftival} |
| 116 |
% \DescribeMacro{\ival} |
| 117 |
% \NoDescription |
| 118 |
% \begin{macrocode} |
| 119 |
\ftivaldef{ftival}{.5\ft@unit} |
| 120 |
\ft@alias{ival} |
| 121 |
\ft@alias{ivalnameCY} |
| 122 |
\ft@alias{ivalival} |
| 123 |
% \end{macrocode} |
| 124 |
% |
| 125 |
% \DescribeMacro{\ftivali} |
| 126 |
% \DescribeMacro{\ivali} |
| 127 |
% \NoDescription |
| 128 |
% \begin{macrocode} |
| 129 |
\ftivaldef{ftivali}{1\ft@unit} |
| 130 |
\ft@alias{ivali} |
| 131 |
\ft@alias{ivalinameCY} |
| 132 |
\ft@alias{ivaliival} |
| 133 |
% \end{macrocode} |
| 134 |
% |
| 135 |
% \DescribeMacro{\ftivalii} |
| 136 |
% \DescribeMacro{\ivalii} |
| 137 |
% \NoDescription |
| 138 |
% \begin{macrocode} |
| 139 |
\ftivaldef{ftivalii}{2\ft@unit} |
| 140 |
\ft@alias{ivalii} |
| 141 |
\ft@alias{ivaliinameCY} |
| 142 |
\ft@alias{ivaliiival} |
| 143 |
% \end{macrocode} |
| 144 |
% |
| 145 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 146 |
% \parag{Customization} |
| 147 |
% |
| 148 |
% \DescribeMacro{\ftsblngboxcfg} |
| 149 |
% \DescribeMacro{\sblngboxcfg} |
| 150 |
% |
| 151 |
% \begin{macrocode} |
| 152 |
\newlength{\ft@sblng@vsp} |
| 153 |
\setlength{\ft@sblng@vsp}{.5\baselineskip}% |
| 154 |
\newcommand{\ftsblngboxcfg}[1]{% space-length |
| 155 |
\global\ft@sblng@vsp=#1% |
| 156 |
} |
| 157 |
\ft@alias{sblngboxcfg} |
| 158 |
% \end{macrocode} |
| 159 |
% |
| 160 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 161 |
% \subsubsection{Sibling box --- core} |
| 162 |
% |
| 163 |
% If any of the siblings has an attributes |\maleline| or alike, then |
| 164 |
% finds the longest one and sets its length to all others. |
| 165 |
% Between the name and |\maleline|, insert a space |
| 166 |
% |\ft@namebox@maleline@sp|. |
| 167 |
% |
| 168 |
% \begin{macrocode} |
| 169 |
\newcommand{\ft@sblng@maleline}[2]{% sibling y |
| 170 |
\@ifundefined{#1hasmaleline}{}{% |
| 171 |
\ft@x=\@nameuse{#1nameX}pt\relax% |
| 172 |
\ifdim\ft@x<\ft@width% |
| 173 |
\put(\strip@pt\ft@x,\strip@pt#2){% |
| 174 |
\line(1,0){\strip@pt\dimexpr\ft@width - \ft@x}% |
| 175 |
}% |
| 176 |
\fi% |
| 177 |
}% |
| 178 |
} |
| 179 |
% \end{macrocode} |
| 180 |
% |
| 181 |
% \DescribeMacro{\ft@sblng@connect} |
| 182 |
% |
| 183 |
% \begin{macrocode} |
| 184 |
\newlength{\ft@c} |
| 185 |
\newcommand{\ft@sblng@connect}[1]{% box-name |
| 186 |
% |
| 187 |
% draw a line to connect all the siblings |
| 188 |
% length = eldest CY - youngest CY |
| 189 |
% and calculate nameCY of the box |
| 190 |
% nameCY = length/2 + youngest CY |
| 191 |
% |
| 192 |
\ft@y=\@nameuse{#1\ft@lastcmark nameCY}pt% |
| 193 |
\ft@dbgplot{1,\strip@pt\ft@y}% |
| 194 |
\ft@yy=\@nameuse{#1\ft@firstcmark nameCY}pt% |
| 195 |
\ft@dbgplot{1,\strip@pt\ft@yy}% |
| 196 |
\ft@len=\dimexpr\ft@yy - \ft@y\relax% |
| 197 |
% |
| 198 |
\ft@c=\dimexpr\ft@len/2 + \ft@y\relax% |
| 199 |
\ft@namexdefstrip{#1nameCY}{\ft@c}% |
| 200 |
\ft@dbgplot{1,\strip@pt\ft@c}% |
| 201 |
% |
| 202 |
\ifnum\@nameuse{\ft@lastcmark hascmark}=\ftadopted% |
| 203 |
\advance\ft@y -\dimexpr\ft@cmarkbox@adopted@sep/2\relax% |
| 204 |
\advance\ft@len \dimexpr\ft@cmarkbox@adopted@sep/2\relax% |
| 205 |
\fi% |
| 206 |
\ifnum\@nameuse{\ft@firstcmark hascmark}=\ftadopted% |
| 207 |
\advance\ft@len \dimexpr\ft@cmarkbox@adopted@sep/2\relax% |
| 208 |
\fi% |
| 209 |
% |
| 210 |
\ifdim\ft@len<2pt% |
| 211 |
%\ft@len=\@nameuse{\ft@firstcmark nameCY}pt\relax% |
| 212 |
\else% |
| 213 |
\advance\ft@y -\dimexpr\arrayrulewidth/2\relax% |
| 214 |
\advance\ft@len \arrayrulewidth% |
| 215 |
\put(0,\strip@pt\ft@y){\line(0,1){\strip@pt\ft@len}}% |
| 216 |
\fi% |
| 217 |
} |
| 218 |
% \end{macrocode} |
| 219 |
% |
| 220 |
% \DescribeMacro{\ft@sblng@layout} |
| 221 |
% |
| 222 |
% \begin{macrocode} |
| 223 |
\newcommand{\ft@sblng@layout}[2]{% box-name individual-name-list |
| 224 |
\ft@newnamebox{#1}{% |
| 225 |
\edef\@w{\strip@pt\ft@width}% |
| 226 |
\edef\@h{\strip@pt\ft@height}% |
| 227 |
\begin{picture}(\@w,\@h)% |
| 228 |
\ft@dbgframe{\@w,\@h}% |
| 229 |
% |
| 230 |
\@for\@temptokena:=#2\do{% |
| 231 |
\edef\ft@sblng@name{\@temptokena}% |
| 232 |
\ft@dbgmsg{H \the\ft@height,% |
| 233 |
\ft@sblng@name nameCY \@nameuse{\ft@sblng@name nameCY}pt,% |
| 234 |
\the\ft@y}% |
| 235 |
% |
| 236 |
% calculate the nameCY for each |
| 237 |
\advance\ft@height -\ht\@nameuse{\ft@sblng@name}% |
| 238 |
\global\ft@y=\dimexpr\@nameuse{\ft@sblng@name nameCY}pt% |
| 239 |
+ \ft@height\relax% |
| 240 |
\ft@dbgplot{0,\strip@pt\ft@y}% |
| 241 |
\ft@namexdefstrip{#1\ft@sblng@name nameCY}{\ft@y}% |
| 242 |
% |
| 243 |
% align the malelines |
| 244 |
\ft@sblng@maleline{\ft@sblng@name}{\ft@y}% |
| 245 |
% |
| 246 |
% place the individual boxes |
| 247 |
\put(0,\strip@pt\ft@height){\usebox{\@nameuse{\ft@sblng@name}}}% |
| 248 |
\advance\ft@height -\dimexpr\dp\@nameuse{\ft@sblng@name}% |
| 249 |
+ \ft@sblng@vsp\relax% |
| 250 |
}% |
| 251 |
% |
| 252 |
% connect them |
| 253 |
\ifx\ft@firstcmark\relax\else% |
| 254 |
\ifx\ft@firstcmark\ft@lastcmark\else% |
| 255 |
\ft@sblng@connect{#1}% |
| 256 |
\fi% |
| 257 |
\fi% |
| 258 |
\end{picture}% |
| 259 |
}% |
| 260 |
% height should hold the original value |
| 261 |
\ft@nameboxsz{#1}{\ft@height}{\ft@depth}% |
| 262 |
} |
| 263 |
% \end{macrocode} |
| 264 |
% |
| 265 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 266 |
% \subsubsection{Sibling box --- interface} |
| 267 |
% |
| 268 |
% \DescribeMacro{\ftsblngdef} |
| 269 |
% \DescribeMacro{\sblngdef} |
| 270 |
% |
| 271 |
% \begin{macrocode} |
| 272 |
\newcommand{\ftsblngdef}[2]{% box-name comma-separated-individuals |
| 273 |
% |
| 274 |
% calculate the size of the box |
| 275 |
\ft@width=0pt% |
| 276 |
\ft@height=0pt% |
| 277 |
\ft@theight=0pt% |
| 278 |
\ft@box@has@malelinefalse% |
| 279 |
\@tempswatrue% |
| 280 |
\let\ft@firstcmark=\relax% |
| 281 |
\let\ft@lastcmark=\relax% |
| 282 |
\def\ft@dpri##1{\ft@dbgmsg{##1 W \the\ft@width, H \the\ft@height,% |
| 283 |
D \the\ft@depth}}% |
| 284 |
\ft@dpri{h0}% |
| 285 |
\@for\@temptokena:=#2\do{% |
| 286 |
\if@tempswa% |
| 287 |
\xdef\ft@eldest{\@temptokena}% |
| 288 |
\@tempswafalse% |
| 289 |
\fi% |
| 290 |
\xdef\ft@youngest{\@temptokena}% |
| 291 |
\@ifundefined{ft@firstcmark}{% |
| 292 |
\@ifundefined{\ft@youngest hascmark}{}{% |
| 293 |
\global\let\ft@firstcmark=\ft@youngest% |
| 294 |
}% |
| 295 |
}{% |
| 296 |
\@ifundefined{\ft@youngest hascmark}{}{% |
| 297 |
\global\let\ft@lastcmark=\ft@youngest% |
| 298 |
}% |
| 299 |
}% |
| 300 |
\@ifundefined{\ft@youngest hasmaleline}{}{% |
| 301 |
\global\ft@box@has@malelinetrue% |
| 302 |
}% |
| 303 |
% |
| 304 |
\setlength{\ft@len}{\wd\@nameuse{\ft@youngest}}% |
| 305 |
\ifdim\ft@width<\ft@len% |
| 306 |
\global\ft@width=\ft@len% |
| 307 |
\@ifundefined{\ft@youngest hasmaleline}{% |
| 308 |
\global\ft@widest@has@no@malelinetrue% |
| 309 |
}{% |
| 310 |
\global\ft@widest@has@no@malelinefalse% |
| 311 |
}% |
| 312 |
\fi% |
| 313 |
\global\advance\ft@theight \dimexpr\ht\@nameuse{\ft@youngest}% |
| 314 |
+ \dp\@nameuse{\ft@youngest} + \ft@sblng@vsp\relax% |
| 315 |
\ft@dpri{\ft@youngest}% |
| 316 |
}% |
| 317 |
\advance\ft@theight -\ft@sblng@vsp% |
| 318 |
\ft@depth=\dp\@nameuse{\ft@youngest}% |
| 319 |
\ft@height=\ft@theight% |
| 320 |
\advance\ft@height -\ft@depth% |
| 321 |
\ifft@widest@has@no@maleline% |
| 322 |
\ifft@box@has@maleline% |
| 323 |
\global\advance\ft@width \dimexpr\ft@namebox@maleline@sp% |
| 324 |
+ \ft@namebox@maleline@length\relax% |
| 325 |
\fi% |
| 326 |
\fi% |
| 327 |
% |
| 328 |
% layout the all boxes |
| 329 |
\ft@sblng@layout{#1}{#2}% |
| 330 |
\ft@dbgbox{\@nameuse{#1}}% |
| 331 |
} |
| 332 |
\ft@alias{sblngdef} |
| 333 |
% \end{macrocode} |