| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: xcoffins.dtx |
| 4 |
% |
| 5 |
% Copyright (C) 2010-2026 The LaTeX Project |
| 6 |
% |
| 7 |
% It may be distributed and/or modified under the conditions of the |
| 8 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 9 |
% license or (at your option) any later version. The latest version |
| 10 |
% of this license is in the file |
| 11 |
% |
| 12 |
% https://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% This file is part of the "l3experimental bundle" (The Work in LPPL) |
| 15 |
% and all files in that bundle must be distributed together. |
| 16 |
% |
| 17 |
% ----------------------------------------------------------------------- |
| 18 |
% |
| 19 |
% The development version of the bundle can be found at |
| 20 |
% |
| 21 |
% https://github.com/latex3/latex3 |
| 22 |
% |
| 23 |
% for those people who are interested. |
| 24 |
% |
| 25 |
%<*driver> |
| 26 |
\documentclass[full]{l3doc} |
| 27 |
\usepackage{xcoffins} % Not yet part of expl3, so not in l3doc |
| 28 |
\usepackage{xcolor} % As coffins only loads basic color support |
| 29 |
\NewCoffin \ExampleCoffin |
| 30 |
\NewCoffin \SmallCoffin |
| 31 |
\NewCoffin \OutputCoffin |
| 32 |
\NewCoffin \RedCoffin |
| 33 |
\NewCoffin \BlueCoffin |
| 34 |
\NewCoffin \GreenCoffin |
| 35 |
\NewCoffin \YellowCoffin |
| 36 |
\NewCoffin \OrangeCoffin |
| 37 |
\begin{document} |
| 38 |
\DocInput{\jobname.dtx} |
| 39 |
\end{document} |
| 40 |
%</driver> |
| 41 |
% \fi |
| 42 |
% |
| 43 |
% \title{^^A |
| 44 |
% The \pkg{xcoffins} package\\ Design-level coffins^^A |
| 45 |
% } |
| 46 |
% |
| 47 |
% \author{^^A |
| 48 |
% The \LaTeX{} Project\thanks |
| 49 |
% {^^A |
| 50 |
% E-mail: |
| 51 |
% \href{mailto:[email protected]} |
| 52 |
% {[email protected]}^^A |
| 53 |
% }^^A |
| 54 |
% } |
| 55 |
% |
| 56 |
% \date{Released 2026-05-26} |
| 57 |
% |
| 58 |
% \maketitle |
| 59 |
% |
| 60 |
% \begin{documentation} |
| 61 |
% |
| 62 |
% \section{Introduction: the coffin concept} |
| 63 |
% |
| 64 |
% In \LaTeX3 terminology, a \enquote{coffin} is a box containing |
| 65 |
% typeset material. Along with the box itself, the coffin structure |
| 66 |
% includes information on the size and shape of the box, which makes |
| 67 |
% it possible to align two or more coffins easily. This is achieved |
| 68 |
% by providing a series of `poles' for each coffin. These |
| 69 |
% are horizontal and vertical lines through the coffin at defined |
| 70 |
% positions, for example the top or horizontal center. The points |
| 71 |
% where these poles intersect are called \enquote{handles}. Two |
| 72 |
% coffins can then be aligned by describing the relationship between |
| 73 |
% a handle on one coffin with a handle on the second. In words, an |
| 74 |
% example might then read |
| 75 |
% \begin{quote} |
| 76 |
% Align the top-left handle of coffin A with the bottom-right |
| 77 |
% handle of coffin B. |
| 78 |
% \end{quote} |
| 79 |
% |
| 80 |
% The locations of coffin handles are much easier to understand |
| 81 |
% visually. Figure~\ref{fgr:handles} shows the standard handle |
| 82 |
% positions for a coffin typeset in horizontal mode (left) and in |
| 83 |
% vertical mode (right). Notice that the later case results in a greater |
| 84 |
% number of handles being available. As illustrated, each handle |
| 85 |
% results from the intersection of two poles. For example, the center |
| 86 |
% of the coffin is marked |(hc,vc)|, i.e., it is the |
| 87 |
% point of intersection of the horizontal center pole with the |
| 88 |
% vertical center pole. New handles are generated automatically when |
| 89 |
% poles are added to a coffin: handles are \enquote{dynamic} entities. |
| 90 |
% |
| 91 |
% \begin{figure} |
| 92 |
% \hfil |
| 93 |
% \begin{minipage}{0.4\textwidth} |
| 94 |
% \SetHorizontalCoffin\ExampleCoffin |
| 95 |
% {\color{black!10!white}\rule{1 in}{1 in}} |
| 96 |
% \DisplayCoffinHandles\ExampleCoffin{blue} |
| 97 |
% \end{minipage} |
| 98 |
% \hfil |
| 99 |
% \begin{minipage}{0.4\textwidth} |
| 100 |
% \SetVerticalCoffin\ExampleCoffin{1 in} |
| 101 |
% {\color{black!10!white}\rule{1 in}{1 in}} |
| 102 |
% \DisplayCoffinHandles\ExampleCoffin{blue} |
| 103 |
% \end{minipage} |
| 104 |
% \hfil |
| 105 |
% \caption{Standard coffin handles: left, horizontal coffin; right, |
| 106 |
% vertical coffin} |
| 107 |
% \label{fgr:handles} |
| 108 |
% \end{figure} |
| 109 |
% |
| 110 |
%\section{Creating and setting coffins} |
| 111 |
% |
| 112 |
% Before any alignment can take place, coffins must be created and |
| 113 |
% their contents must be created. All coffin operations are local |
| 114 |
% to the current \TeX{} group with the exception of coffin creation. |
| 115 |
% \begin{function}{\NewCoffin} |
| 116 |
% \begin{syntax} |
| 117 |
% \cs{NewCoffin} \meta{coffin} |
| 118 |
% \end{syntax} |
| 119 |
% Before a \meta{coffin} can be used, it must be allocated using |
| 120 |
% \cs{NewCoffin}. The name of the \meta{coffin} should be a |
| 121 |
% control sequence (starting with the escape character, usually |
| 122 |
% |\|), for example |
| 123 |
% \begin{verbatim} |
| 124 |
% \NewCoffin\MyCoffin |
| 125 |
% \end{verbatim} |
| 126 |
% Coffins are allocated globally, and an error will be raised if the |
| 127 |
% name of the \meta{coffin} is not globally-unique. |
| 128 |
% \end{function} |
| 129 |
% |
| 130 |
% \begin{function}{\SetHorizontalCoffin} |
| 131 |
% \begin{syntax} |
| 132 |
% \cs{SetHorizontalCoffin} \meta{coffin} \Arg{material} |
| 133 |
% \end{syntax} |
| 134 |
% Typesets the \meta{material} in horizontal mode, storing the result |
| 135 |
% in the \meta{coffin}. The standard poles for the \meta{coffin} are |
| 136 |
% then set up based on the size of the typeset material. |
| 137 |
% \end{function} |
| 138 |
% |
| 139 |
% \begin{function}{\SetVerticalCoffin} |
| 140 |
% \begin{syntax} |
| 141 |
% \cs{SetVerticalCoffin} \meta{coffin} \Arg{width} \Arg{material} |
| 142 |
% \end{syntax} |
| 143 |
% Typesets the \meta{material} in vertical mode constrained to the |
| 144 |
% given \meta{width} and stores the result in the \meta{coffin}. The |
| 145 |
% standard poles for the \meta{coffin} are then set up based on the |
| 146 |
% size of the typeset material. |
| 147 |
% \end{function} |
| 148 |
% |
| 149 |
% \section{Controlling coffin poles} |
| 150 |
% |
| 151 |
% A number of standard poles are automatically generated when the coffin |
| 152 |
% is set or an alignment takes place. The standard poles for all coffins |
| 153 |
% are: |
| 154 |
% \begin{itemize}[font = \ttfamily] |
| 155 |
% \item[l] a pole running along the left-hand edge of the bounding |
| 156 |
% box of the coffin; |
| 157 |
% \item[hc] a pole running vertically through the center of the coffin |
| 158 |
% half-way between the left- and right-hand edges of the bounding |
| 159 |
% box (i.e., the \enquote{horizontal center}); |
| 160 |
% \item[r] a pole running along the right-hand edge of the bounding |
| 161 |
% box of the coffin; |
| 162 |
% \item[b] a pole running along the bottom edge of the bounding |
| 163 |
% box of the coffin; |
| 164 |
% \item[vc] a pole running horizontally through the center of the |
| 165 |
% coffin half-way between the bottom and top edges of the bounding |
| 166 |
% box (i.e., the \enquote{vertical center}); |
| 167 |
% \item[t] a pole running along the top edge of the bounding |
| 168 |
% box of the coffin; |
| 169 |
% \item[H] a pole running along the baseline of the typeset material |
| 170 |
% contained in the coffin. |
| 171 |
% \end{itemize} |
| 172 |
% In addition, coffins containing vertical-mode material also |
| 173 |
% feature poles which reflect the richer nature of these systems: |
| 174 |
% \begin{itemize} |
| 175 |
% \item[B] a pole running along the baseline of the material at the |
| 176 |
% bottom of the coffin. |
| 177 |
% \item[T] a pole running along the baseline of the material at the top |
| 178 |
% of the coffin. |
| 179 |
% \end{itemize} |
| 180 |
% |
| 181 |
% \begin{function}{\SetHorizontalPole} |
| 182 |
% \begin{syntax} |
| 183 |
% \cs{SetHorizontalPole} \meta{coffin} \Arg{pole} \Arg{offset} |
| 184 |
% \end{syntax} |
| 185 |
% Sets the \meta{pole} to run horizontally through the \meta{coffin}. |
| 186 |
% The \meta{pole} will be located at the \meta{offset} from the |
| 187 |
% baseline of the \meta{coffin}. The |
| 188 |
% \meta{offset} should be given as a dimension expression; this may |
| 189 |
% include the terms \cs{TotalHeight}, \cs{Height}, \cs{Depth} and |
| 190 |
% \cs{Width}, which will evaluate to the appropriate dimensions of |
| 191 |
% the \meta{coffin}. For example, to create a pole running |
| 192 |
% horizontally through the coffin at one third of the distance from |
| 193 |
% the base of the coffin to the top, the appropriate instruction would |
| 194 |
% be |
| 195 |
% \begin{verbatim} |
| 196 |
% \SetHorizontalPole \MyCoffin {height/3} {\TotalHeight/3} |
| 197 |
% \end{verbatim} |
| 198 |
% Note that poles which run \emph{horizontally} are described in terms |
| 199 |
% of their \emph{vertical} location in the coffin. Also notice that |
| 200 |
% the total height of the coffin is described by the sum of |
| 201 |
% \cs{Height} and \cs{Depth}: these are both measured from the |
| 202 |
% horizontal baseline of the material in the coffin. |
| 203 |
% \end{function} |
| 204 |
% |
| 205 |
% \begin{function}{\SetVerticalPole} |
| 206 |
% \begin{syntax} |
| 207 |
% \cs{SetVerticalPole} \meta{coffin} \Arg{pole} \Arg{offset} |
| 208 |
% \end{syntax} |
| 209 |
% Sets the \meta{pole} to run vertically through the \meta{coffin}. |
| 210 |
% The \meta{pole} will be located at the \meta{offset} from the |
| 211 |
% left-hand edge of the bounding box of the \meta{coffin}. The |
| 212 |
% \meta{offset} should be given as a dimension expression; this may |
| 213 |
% include the terms \cs{TotalHeight}, \cs{Height}, \cs{Depth} and |
| 214 |
% \cs{Width}, which will evaluate to the appropriate dimensions of |
| 215 |
% the \meta{coffin}. For example, to create a pole running vertically |
| 216 |
% through the coffin at one third of the distance from the left-hand |
| 217 |
% edge, the appropriate instruction would be |
| 218 |
% \begin{verbatim} |
| 219 |
% \SetVerticalPole \MyCoffin {width/3} {\Width/3} |
| 220 |
% \end{verbatim} |
| 221 |
% Note that poles which run \emph{vertically} are described in terms |
| 222 |
% of their \emph{horizontal} location in the coffin. |
| 223 |
% \end{function} |
| 224 |
% |
| 225 |
% \begin{function}{\TotalHeight} |
| 226 |
% \begin{syntax} |
| 227 |
% \cs{TotalHeight} |
| 228 |
% \end{syntax} |
| 229 |
% Within the \meta{offset} argument of \cs{SetHorizontalPole} and |
| 230 |
% \cs{SetVerticalPole}, \cs{TotalHeight} will give the distance from |
| 231 |
% the base to the top of the bounding box of the relevant coffin. |
| 232 |
% \end{function} |
| 233 |
% |
| 234 |
% \begin{function}{\Height} |
| 235 |
% \begin{syntax} |
| 236 |
% \cs{Height} |
| 237 |
% \end{syntax} |
| 238 |
% Within the \meta{offset} argument of \cs{SetHorizontalPole} and |
| 239 |
% \cs{SetVerticalPole}, \cs{Height} will give the distance from the |
| 240 |
% baseline to the top of the bounding box of the relevant coffin. |
| 241 |
% \end{function} |
| 242 |
% |
| 243 |
% \begin{function}{\Depth} |
| 244 |
% \begin{syntax} |
| 245 |
% \cs{Depth} |
| 246 |
% \end{syntax} |
| 247 |
% Within the \meta{offset} argument of \cs{SetHorizontalPole} and |
| 248 |
% \cs{SetVerticalPole}, \cs{Depth} will give the distance from the |
| 249 |
% baseline to the bottom of the bounding box of the relevant coffin. |
| 250 |
% \end{function} |
| 251 |
% |
| 252 |
% \begin{function}{\Width} |
| 253 |
% \begin{syntax} |
| 254 |
% \cs{Width} |
| 255 |
% \end{syntax} |
| 256 |
% Within the \meta{offset} argument of \cs{SetHorizontalPole} and |
| 257 |
% \cs{SetVerticalPole}, \cs{Width} will give the distance from the |
| 258 |
% right edge to the left edge of the bounding box of the relevant |
| 259 |
% coffin. |
| 260 |
% \end{function} |
| 261 |
% |
| 262 |
% \section{Rotating coffins} |
| 263 |
% |
| 264 |
% \begin{function}{\RotateCoffin} |
| 265 |
% \begin{syntax} |
| 266 |
% \cs{RotateCoffin} \meta{coffin} \Arg{angle} |
| 267 |
% \end{syntax} |
| 268 |
% Rotates the \meta{coffin} by the given \meta{angle} about its reference |
| 269 |
% point (given in degrees counter-clockwise) . This process will rotate both |
| 270 |
% the coffin content and poles. Multiple rotations will not result in |
| 271 |
% the bounding box of the coffin growing unnecessarily. |
| 272 |
% |
| 273 |
% The effect of rotation on a coffin is illustrated in |
| 274 |
% Figure~\ref{fgr:rotation}. As is shown, the coffin handles will |
| 275 |
% remain correctly positioned relative to the content of the coffin. |
| 276 |
% The \enquote{top} of a rotated coffin may of course no longer be the |
| 277 |
% edge closest to the top of the physical page. |
| 278 |
% \end{function} |
| 279 |
% |
| 280 |
% \begin{figure} |
| 281 |
% \hfil |
| 282 |
% \SetHorizontalCoffin\ExampleCoffin |
| 283 |
% {^^A |
| 284 |
% \color{black!10!white}\rule{0.5 in}{1 in}^^A |
| 285 |
% \color{black!20!white}\rule{0.5 in}{1 in}^^A |
| 286 |
% } |
| 287 |
% \begin{minipage}{0.4\textwidth} |
| 288 |
% \DisplayCoffinHandles\ExampleCoffin{blue} |
| 289 |
% \end{minipage} |
| 290 |
% \hfil |
| 291 |
% \begin{minipage}{0.4\textwidth} |
| 292 |
% \RotateCoffin\ExampleCoffin{45} |
| 293 |
% \DisplayCoffinHandles\ExampleCoffin{blue} |
| 294 |
% \end{minipage} |
| 295 |
% \hfil |
| 296 |
% \caption{Coffin rotation: left, unrotated; right, rotated by |
| 297 |
% $45$\textdegree.} |
| 298 |
% \label{fgr:rotation} |
| 299 |
% \end{figure} |
| 300 |
% |
| 301 |
% \section{Resizing coffins} |
| 302 |
% |
| 303 |
% \begin{function}{\ResizeCoffin} |
| 304 |
% \begin{syntax} |
| 305 |
% \cs{ResizeCoffin} \meta{coffin} \Arg{width} \Arg{total-height} |
| 306 |
% \end{syntax} |
| 307 |
% Resized the \meta{coffin} to \meta{width} and \meta{total-height}, |
| 308 |
% both of which should be given as dimension expressions. |
| 309 |
% \end{function} |
| 310 |
% |
| 311 |
% \begin{function}{\ScaleCoffin} |
| 312 |
% \begin{syntax} |
| 313 |
% \cs{ScaleCoffin} \meta{coffin} \Arg{x-scale} \Arg{y-scale} |
| 314 |
% \end{syntax} |
| 315 |
% Scales the \meta{coffin} by a factors \meta{x-scale} and |
| 316 |
% \meta{y-scale} in the horizontal and vertical directions, |
| 317 |
% respectively. The two scale factors should be given as real numbers. |
| 318 |
% \end{function} |
| 319 |
% |
| 320 |
% \cs{ResizeCoffin} and \cs{ScaleCoffin} can be used interchangeably: |
| 321 |
% whether scale factors or absolute values are the best form for the |
| 322 |
% resizing will depend upon the context (Figure~\ref{fgr:resizing}). |
| 323 |
% |
| 324 |
% \begin{figure} |
| 325 |
% \hfil |
| 326 |
% \SetHorizontalCoffin\ExampleCoffin |
| 327 |
% {^^A |
| 328 |
% \color{black!10!white}\rule{0.5 in}{1 in}^^A |
| 329 |
% \color{black!20!white}\rule{0.5 in}{1 in}^^A |
| 330 |
% } |
| 331 |
% \begin{minipage}{0.4\textwidth} |
| 332 |
% \ResizeCoffin \ExampleCoffin {4 cm} {3 cm} |
| 333 |
% \DisplayCoffinHandles \ExampleCoffin {blue} |
| 334 |
% \end{minipage} |
| 335 |
% \hfil |
| 336 |
% \begin{minipage}{0.4\textwidth} |
| 337 |
% \ScaleCoffin \ExampleCoffin {2.0} {0.5} |
| 338 |
% \DisplayCoffinHandles \ExampleCoffin {blue} |
| 339 |
% \end{minipage} |
| 340 |
% \hfil |
| 341 |
% \caption{Coffin resizing: left, resized to exactly $4$\,cm by |
| 342 |
% $6$\,cm; right, scaled a factors of $2$ and $0.5$ in |
| 343 |
% $x$ and $y$, respectively (example coffin as in |
| 344 |
% Figure~\ref{fgr:rotation}).} |
| 345 |
% \label{fgr:resizing} |
| 346 |
% \end{figure} |
| 347 |
% |
| 348 |
% \section{Joining coffins} |
| 349 |
% |
| 350 |
% The key operation for coffins is joining coffins to each other. This |
| 351 |
% is always carried out such that the first coffin is the |
| 352 |
% \enquote{parent}, and is updated by the alignment. The second |
| 353 |
% \enquote{child} coffin is not altered by the alignment process. |
| 354 |
% |
| 355 |
% \begin{function}{\JoinCoffins} |
| 356 |
% \begin{syntax} |
| 357 |
% \cs{JoinCoffins} * |
| 358 |
% ~~\meta{coffin1} [ \meta{coffin1-pole1} , \meta{coffin1-pole2} ] |
| 359 |
% ~~\meta{coffin2} [ \meta{coffin2-pole1} , \meta{coffin2-pole2} ] |
| 360 |
% ~~( \meta{x-offset} , \meta{y-offset} ) |
| 361 |
% \end{syntax} |
| 362 |
% Joining of two coffins is carried out by the \cs{JoinCoffins} |
| 363 |
% function, which takes two mandatory arguments: the \enquote{parent} |
| 364 |
% \meta{coffin1} and the \enquote{child} \meta{coffin2}. All of the |
| 365 |
% other arguments shown are optional. |
| 366 |
% \end{function} |
| 367 |
% |
| 368 |
% The standard \cs{JoinCoffins} functions joins \meta{coffin2} to |
| 369 |
% \meta{coffin1} such that the bounding box of \meta{coffin1} after the |
| 370 |
% process will expand. The new bounding box will be the smallest |
| 371 |
% rectangle covering the bounding boxes of the two input coffins. |
| 372 |
% When the starred variant of \cs{JoinCoffins} is used, the bounding |
| 373 |
% box of \meta{coffin1} is not altered, i.e., \meta{coffin2} may |
| 374 |
% protrude outside of the bounding box of the updated \meta{coffin1}. |
| 375 |
% The difference between the two forms of alignment is best illustrated |
| 376 |
% using a visual example. In Figure~\ref{fgr:alignment}, the two |
| 377 |
% processes are contrasted. In both cases, the small red coffin has been |
| 378 |
% aligned with the large grey coffin. In the left-hand illustration, |
| 379 |
% the \cs{JoinCoffins} function was used, resulting in an expanded |
| 380 |
% bounding box. In contrast, on the right \cs{JoinCoffins}|*| was used, |
| 381 |
% meaning that the bounding box does not include the area of the |
| 382 |
% smaller coffin. |
| 383 |
% |
| 384 |
% \begin{figure} |
| 385 |
% \fboxsep 0 pt\relax |
| 386 |
% \SetHorizontalCoffin\ExampleCoffin |
| 387 |
% {\color{black!20!white}\rule{1 in}{1 in}} |
| 388 |
% \SetHorizontalCoffin \SmallCoffin |
| 389 |
% {\color{red!20!white}\rule{0.1 in}{0.1 in}} |
| 390 |
% \hfil |
| 391 |
% \begin{minipage}{0.4\textwidth} |
| 392 |
% \centering |
| 393 |
% \JoinCoffins\ExampleCoffin[vc,r]\SmallCoffin[vc,l] |
| 394 |
% \fbox{\TypesetCoffin\ExampleCoffin} |
| 395 |
% \end{minipage} |
| 396 |
% \hfil |
| 397 |
% \begin{minipage}{0.4\textwidth} |
| 398 |
% \centering |
| 399 |
% \JoinCoffins*\ExampleCoffin[vc,r]\SmallCoffin[vc,l] |
| 400 |
% \fbox{\TypesetCoffin\ExampleCoffin}% |
| 401 |
% \end{minipage} |
| 402 |
% \hfil |
| 403 |
% \caption{Contrast between \cs{JoinCoffins} (left) and |
| 404 |
% \cs{JoinCoffins*} (right); the bounding box of the coffin is show |
| 405 |
% in black.} |
| 406 |
% \label{fgr:alignment} |
| 407 |
% \end{figure} |
| 408 |
% |
| 409 |
% The alignment is carried out by first calculating \meta{handle1}, the |
| 410 |
% point of intersection of \meta{coffin1-pole1} and |
| 411 |
% \meta{coffin1-pole2}, and \meta{handle2}, the point of intersection |
| 412 |
% of \meta{coffin2-pole1} and \meta{coffin2-pole2}. If the two |
| 413 |
% \meta{poles} are not specified, \cs{JoinCoffins} will use the |
| 414 |
% default value |(H,l)|, i.e., the reference point used by \TeX\ |
| 415 |
% for the underlying box. Once the two \meta{handles} have been |
| 416 |
% located, \meta{coffin2} is then attached to \meta{coffin1} such that |
| 417 |
% the relationship between \meta{handle1} and \meta{handle2} is |
| 418 |
% described by the \meta{x-offset} and \meta{y-offset}. This |
| 419 |
% \meta{offset} is an optional argument, and if it is not given then |
| 420 |
% |(0 pt, 0 pt)| is used. |
| 421 |
% |
| 422 |
% Notice that when \cs{JoinCoffins} is used the new bounding box is |
| 423 |
% the smallest rectangle containing the bounding boxes of the two input |
| 424 |
% coffins. As a result, it will include additional white space unless |
| 425 |
% one coffin entirely overlaps the other (Figure~\ref{fgr:bounding}, |
| 426 |
% left). Rotation of coffins will take account of the extent of the |
| 427 |
% material after rotation when re-calculating the bounding box. This |
| 428 |
% means that no \emph{unnecessary} white space will be added on |
| 429 |
% rotation (Figure~\ref{fgr:bounding}, right). |
| 430 |
% |
| 431 |
% \begin{figure} |
| 432 |
% \fboxsep 0 pt\relax |
| 433 |
% \SetHorizontalCoffin\ExampleCoffin |
| 434 |
% {\color{black!20!white}\rule{1 in}{1 in}} |
| 435 |
% \SetHorizontalCoffin\SmallCoffin |
| 436 |
% {\color{red!20!white}\rule{0.1 in}{0.1 in}} |
| 437 |
% \JoinCoffins\ExampleCoffin[vc,r]\SmallCoffin[vc,l] |
| 438 |
% \hfil |
| 439 |
% \begin{minipage}{0.4\textwidth} |
| 440 |
% \centering |
| 441 |
% \fbox{\copy\ExampleCoffin} |
| 442 |
% \end{minipage} |
| 443 |
% \hfil |
| 444 |
% \begin{minipage}{0.4\textwidth} |
| 445 |
% \centering |
| 446 |
% \RotateCoffin\ExampleCoffin{135} |
| 447 |
% \fbox{\copy\ExampleCoffin} |
| 448 |
% \end{minipage} |
| 449 |
% \hfil |
| 450 |
% \caption{The effect of rotation of a joined coffin: the black line |
| 451 |
% shows the coffin bounding box.} |
| 452 |
% \label{fgr:bounding} |
| 453 |
% \end{figure} |
| 454 |
% |
| 455 |
% As part of the joining procedure, the poles of the two input coffins |
| 456 |
% are preserved within the structure of the updated coffin. In this way |
| 457 |
% it is possible to carry out complex alignment procedures. The poles of |
| 458 |
% a coffin after alignment may therefore be divided into three groups: |
| 459 |
% \begin{enumerate} |
| 460 |
% \item The \enquote{native} poles of the updated coffin, such as |
| 461 |
% \texttt{l}, \texttt{r}, \texttt{hc}, \emph{etc}. |
| 462 |
% \item Poles derived from \meta{coffin1}, such as |
| 463 |
% \texttt{\meta{coffin1}-l}, \texttt{\meta{coffin1}-r}, |
| 464 |
% \texttt{\meta{coffin1}-hc}, etc. |
| 465 |
% \item Poles derived from \meta{coffin2}, such as |
| 466 |
% \texttt{\meta{coffin2}-l}, \texttt{\meta{coffin2}-r}, |
| 467 |
% \texttt{\meta{coffin2}-hc}, etc. |
| 468 |
% \end{enumerate} |
| 469 |
% |
| 470 |
% Applying this ability allows a series of joining operations to |
| 471 |
% take place, as illustrated in Figure~\ref{fgr:nested}. In this |
| 472 |
% example, the scheme used for alignment was as follows: |
| 473 |
% \begin{verbatim} |
| 474 |
% \SetHorizontalCoffin\OutputCoffin{} |
| 475 |
% \SetHorizontalCoffin\RedCoffin |
| 476 |
% {\color{red!20!white}\rule{0.2 in}{0.2 in}} |
| 477 |
% \JoinCoffins\OutputCoffin[vc,hc]\RedCoffin[vc,hc] |
| 478 |
% \SetHorizontalCoffin\BlueCoffin |
| 479 |
% {\color{blue!20!white}\rule{0.2 in}{0.2 in}} |
| 480 |
% \JoinCoffins\OutputCoffin[\RedCoffin-vc,\RedCoffin-hc] |
| 481 |
% \BlueCoffin[b,l] |
| 482 |
% \SetHorizontalCoffin\GreenCoffin |
| 483 |
% {\color{green!20!white}\rule{0.2 in}{0.2 in}} |
| 484 |
% \JoinCoffins\OutputCoffin[\BlueCoffin-vc,\BlueCoffin-hc] |
| 485 |
% \GreenCoffin[b,l] |
| 486 |
% \SetHorizontalCoffin\YellowCoffin |
| 487 |
% {\color{yellow!20!white}\rule{0.2 in}{0.2 in}} |
| 488 |
% \JoinCoffins\OutputCoffin[\GreenCoffin-vc,\GreenCoffin-hc] |
| 489 |
% \YellowCoffin[b,l] |
| 490 |
% \SetHorizontalCoffin \OrangeCoffin |
| 491 |
% {\color{orange!20!white}\rule{0.2 in}{0.2 in}} |
| 492 |
% \JoinCoffins\OutputCoffin[\BlueCoffin-t,\BlueCoffin-l] |
| 493 |
% \OrangeCoffin[b,r] |
| 494 |
% \TypesetCoffin\OutputCoffin |
| 495 |
% \end{verbatim} |
| 496 |
% This process begins by setting up \cs{OutputCoffin} to hold the joined |
| 497 |
% output. Each join then takes place placing the new addition relative |
| 498 |
% to the previous one. As each coffin joined has a unique name it is |
| 499 |
% possible to align relative to each one of the component parts of the |
| 500 |
% assembly. This is illustrated by the addition of the final |
| 501 |
% \cs{OrangeCoffin} based on the earlier placement of the |
| 502 |
% \cs{BlueCoffin}. |
| 503 |
% |
| 504 |
% \begin{figure} |
| 505 |
% \centering |
| 506 |
% \SetHorizontalCoffin\OutputCoffin{} |
| 507 |
% \SetHorizontalCoffin\RedCoffin |
| 508 |
% {\color{red!20!white}\rule{0.2 in}{0.2 in}} |
| 509 |
% \JoinCoffins\OutputCoffin[vc,hc]\RedCoffin[vc,hc] |
| 510 |
% \SetHorizontalCoffin\BlueCoffin |
| 511 |
% {\color{blue!20!white}\rule{0.2 in}{0.2 in}} |
| 512 |
% \JoinCoffins\OutputCoffin[\RedCoffin-vc,\RedCoffin-hc] |
| 513 |
% \BlueCoffin[b,l] |
| 514 |
% \SetHorizontalCoffin\GreenCoffin |
| 515 |
% {\color{green!20!white}\rule{0.2 in}{0.2 in}} |
| 516 |
% \JoinCoffins\OutputCoffin[\BlueCoffin-vc,\BlueCoffin-hc] |
| 517 |
% \GreenCoffin[b,l] |
| 518 |
% \SetHorizontalCoffin\YellowCoffin |
| 519 |
% {\color{yellow!20!white}\rule{0.2 in}{0.2 in}} |
| 520 |
% \JoinCoffins\OutputCoffin[\GreenCoffin-vc,\GreenCoffin-hc] |
| 521 |
% \YellowCoffin[b,l] |
| 522 |
% \SetHorizontalCoffin \OrangeCoffin |
| 523 |
% {\color{orange!20!white}\rule{0.2 in}{0.2 in}} |
| 524 |
% \JoinCoffins\OutputCoffin[\BlueCoffin-t,\BlueCoffin-l] |
| 525 |
% \OrangeCoffin[b,r] |
| 526 |
% \TypesetCoffin\OutputCoffin |
| 527 |
% \caption{Aligning coffins using poles from previous operations.} |
| 528 |
% \label{fgr:nested} |
| 529 |
% \end{figure} |
| 530 |
% |
| 531 |
% \section{Typesetting coffins} |
| 532 |
% |
| 533 |
% \begin{function}{\TypesetCoffin} |
| 534 |
% \begin{syntax} |
| 535 |
% \cs{TypesetCoffin} |
| 536 |
% ~~\meta{coffin} [ \meta{pole1} , \meta{pole2} ] |
| 537 |
% ~~( \meta{x-offset} , \meta{y-offset} ) |
| 538 |
% \end{syntax} |
| 539 |
% Typesetting is carried out by first calculating \meta{handle}, the |
| 540 |
% point of intersection of \meta{pole1} and \meta{pole2}. This is an |
| 541 |
% optional argument, and if not given then |(H,l)|, the \TeX{} |
| 542 |
% reference point of the underlying box, is used. The coffin |
| 543 |
% is then typeset such that the relationship between the current |
| 544 |
% reference point in the document and the \meta{handle} is described |
| 545 |
% by the \meta{x-offset} and \meta{y-offset}. This \meta{offset} is |
| 546 |
% optional, and if not given |(0 pt, 0 pt)| is used. Typesetting a |
| 547 |
% coffin is therefore analogous to carrying out an alignment where the |
| 548 |
% \enquote{parent} coffin is the current insertion point. |
| 549 |
% \end{function} |
| 550 |
% |
| 551 |
% \section{Measuring coffins} |
| 552 |
% |
| 553 |
% There are places in the design process where it is useful to be able to |
| 554 |
% measure coffins outside of pole-setting procedures. |
| 555 |
% |
| 556 |
% \begin{function}{\CoffinDepth} |
| 557 |
% \begin{syntax} |
| 558 |
% \cs{CoffinDepth} \meta{coffin} |
| 559 |
% \end{syntax} |
| 560 |
% Calculates the depth (below the baseline) of the \meta{coffin} |
| 561 |
% in a form suitable for use in a \meta{dimension expression}, for example |
| 562 |
% |\setlength{\mylength}{\CoffinDepth\ExampleCoffin}|. |
| 563 |
% \end{function} |
| 564 |
% |
| 565 |
% \begin{function}{\CoffinHeight} |
| 566 |
% \begin{syntax} |
| 567 |
% \cs{CoffinHeight} \meta{coffin} |
| 568 |
% \end{syntax} |
| 569 |
% Calculates the height (above the baseline) of the \meta{coffin} |
| 570 |
% in a form suitable for use in a \meta{dimension expression}, for example |
| 571 |
% |\setlength{\mylength}{\CoffinHeight\ExampleCoffin}|. |
| 572 |
% \end{function} |
| 573 |
% |
| 574 |
% \begin{function}{\CoffinTotalHeight} |
| 575 |
% \begin{syntax} |
| 576 |
% \cs{CoffinTotalHeight} \meta{coffin} |
| 577 |
% \end{syntax} |
| 578 |
% Calculates the total height of the \meta{coffin} |
| 579 |
% in a form suitable for use in a \meta{dimension expression}, for example |
| 580 |
% |\setlength{\mylength}{\CoffinTotalHeight\ExampleCoffin}|. |
| 581 |
% \end{function} |
| 582 |
% |
| 583 |
% \begin{function}{\CoffinWidth} |
| 584 |
% \begin{syntax} |
| 585 |
% \cs{CoffinWidth} \meta{coffin} |
| 586 |
% \end{syntax} |
| 587 |
% Calculates the width of the \meta{coffin} in a form |
| 588 |
% suitable for use in a \meta{dimension expression}, for example |
| 589 |
% |\setlength{\mylength}{\CoffinWidth\ExampleCoffin}|. |
| 590 |
% \end{function} |
| 591 |
% |
| 592 |
% \section{Diagnostic functions} |
| 593 |
% |
| 594 |
% Diagnostic data for following the coffin-building process is |
| 595 |
% available both graphically and at the terminal. This reflects the |
| 596 |
% fact that coffins are visual constructs. |
| 597 |
% |
| 598 |
% \begin{function}{\DisplayCoffinHandles} |
| 599 |
% \begin{syntax} |
| 600 |
% \cs{DisplayCoffinHandles} \meta{coffin} \Arg{color} |
| 601 |
% \end{syntax} |
| 602 |
% This function first calculates the intersections between all of |
| 603 |
% the \meta{poles} of the \meta{coffin} to give a set of |
| 604 |
% \meta{handles}. It then prints the \meta{coffin} at the current |
| 605 |
% location in the source, with the position of the \meta{handles} |
| 606 |
% marked on the coffin. The \meta{handles} will be labeled as part |
| 607 |
% of this process: the locations of the \meta{handles} and the labels |
| 608 |
% are both printed in the \meta{color} specified. |
| 609 |
% \end{function} |
| 610 |
% |
| 611 |
% \begin{function}{\MarkCoffinHandle} |
| 612 |
% \begin{syntax} |
| 613 |
% \cs{MarkCoffinHandle} \meta{coffin} |
| 614 |
% ~~[ \meta{pole1} , \meta{pole2} ] \Arg{color} |
| 615 |
% \end{syntax} |
| 616 |
% This function first calculates the \meta{handle} for the |
| 617 |
% \meta{coffin} as defined by the intersection of \meta{pole1} and |
| 618 |
% \meta{pole2}. It then marks the position of the \meta{handle} |
| 619 |
% on the \meta{coffin}. The \meta{handle} will be labeled as part of |
| 620 |
% this process: the location of the \meta{handle} and the label are |
| 621 |
% both printed in the \meta{color} specified. If no \meta{poles} are |
| 622 |
% give, the default |(H,l)| is used. |
| 623 |
% \end{function} |
| 624 |
% |
| 625 |
% \begin{function}{\ShowCoffinStructure} |
| 626 |
% \begin{syntax} |
| 627 |
% \cs{ShowCoffinStructure} \meta{coffin} |
| 628 |
% \end{syntax} |
| 629 |
% This function shows the structural information about the |
| 630 |
% \meta{coffin} in the terminal. The width, height and depth of the |
| 631 |
% typeset material are given, along with the location of all of the |
| 632 |
% poles of the coffin. For example, for the rotated coffin in |
| 633 |
% Figure~\ref{fgr:rotation}, the output of \cs{ShowCoffinStructure} |
| 634 |
% is: |
| 635 |
% \begin{verbatim} |
| 636 |
% Size of coffin \ExampleCoffin: |
| 637 |
% > ht = 72.26999pt |
| 638 |
% > dp = 0.0pt |
| 639 |
% > wd = 72.26999pt |
| 640 |
% Poles of coffin \ExampleCoffin: |
| 641 |
% > l => {0pt}{0pt}{0pt}{1000pt} |
| 642 |
% > B => {0pt}{0pt}{1000pt}{0pt} |
| 643 |
% > H => {0pt}{0pt}{1000pt}{0pt} |
| 644 |
% > T => {0pt}{0pt}{1000pt}{0pt} |
| 645 |
% > hc => {36.135pt}{0pt}{0pt}{1000pt} |
| 646 |
% > r => {72.26999pt}{0pt}{0pt}{1000pt} |
| 647 |
% > vc => {0pt}{36.135pt}{1000pt}{0pt} |
| 648 |
% > t => {0pt}{72.26999pt}{1000pt}{0pt} |
| 649 |
% > b => {0pt}{0.0pt}{1000pt}{0pt}. |
| 650 |
% <recently read> } |
| 651 |
% \end{verbatim} |
| 652 |
% Notice that the poles of a coffin are defined by four values: |
| 653 |
% the $x$ and $y$ coordinates of a point that the pole |
| 654 |
% passes through and the $x$- and $y$-components of a |
| 655 |
% vector denoting the direction of the pole. It is the ratio between |
| 656 |
% the later, rather than the absolute values, which determines the |
| 657 |
% direction of the pole. |
| 658 |
% \end{function} |
| 659 |
% |
| 660 |
% \end{documentation} |
| 661 |
% |
| 662 |
% \begin{implementation} |
| 663 |
% |
| 664 |
% \section{Implementation} |
| 665 |
% |
| 666 |
% \begin{macrocode} |
| 667 |
%<*package> |
| 668 |
% \end{macrocode} |
| 669 |
% |
| 670 |
% \begin{macrocode} |
| 671 |
%<@@=coffin> |
| 672 |
% \end{macrocode} |
| 673 |
% |
| 674 |
% \begin{macrocode} |
| 675 |
\ProvidesExplPackage{xcoffins}{2026-05-26}{} |
| 676 |
{L3 Experimental design level coffins} |
| 677 |
% \end{macrocode} |
| 678 |
% |
| 679 |
% \begin{variable} |
| 680 |
% { |
| 681 |
% \l_@@_A_hpole_tl , |
| 682 |
% \l_@@_A_vpole_tl , |
| 683 |
% \l_@@_B_hpole_tl , |
| 684 |
% \l_@@_B_vpole_tl , |
| 685 |
% \l_@@_bound_box_grow_bool , |
| 686 |
% \l_@@_hoffset_dim , |
| 687 |
% \l_@@_voffset_dim |
| 688 |
% } |
| 689 |
% Key--value definitions for the alignment system. With the exception |
| 690 |
% of \texttt{grow-bounding-box}, all of these have to be given with a |
| 691 |
% value. |
| 692 |
% \begin{macrocode} |
| 693 |
\keys_define:nn { coffin } |
| 694 |
{ |
| 695 |
coffin1-hpole .tl_set:N = \l_@@_A_hpole_tl , |
| 696 |
coffin1-hpole .value_required:n = true , |
| 697 |
coffin1-vpole .tl_set:N = \l_@@_A_vpole_tl , |
| 698 |
coffin1-vpole .value_required:n = true , |
| 699 |
coffin2-hpole .tl_set:N = \l_@@_B_hpole_tl , |
| 700 |
coffin2-hpole .value_required:n = true , |
| 701 |
coffin2-vpole .tl_set:N = \l_@@_B_vpole_tl , |
| 702 |
coffin2-vpole .value_required:n = true , |
| 703 |
grow-bounding-box .bool_set:N = \l_@@_bound_box_grow_bool , |
| 704 |
grow-bounding-box .default:n = true , |
| 705 |
hoffset .dim_set:N = \l_@@_hoffset_dim , |
| 706 |
hoffset .value_required:n = true , |
| 707 |
voffset .dim_set:N = \l_@@_voffset_dim , |
| 708 |
voffset .value_required:n = true |
| 709 |
} |
| 710 |
\keys_set:nn { coffin } |
| 711 |
{ |
| 712 |
coffin1-hpole = H , |
| 713 |
coffin1-vpole = l , |
| 714 |
coffin2-hpole = H , |
| 715 |
coffin2-vpole = l , |
| 716 |
grow-bounding-box = true , |
| 717 |
hoffset = 0 pt , |
| 718 |
voffset = 0 pt |
| 719 |
} |
| 720 |
% \end{macrocode} |
| 721 |
% \end{variable} |
| 722 |
% |
| 723 |
% \begin{macro}{\@@_design_names:N} |
| 724 |
% \begin{variable}{\Height, \Depth, \Width, \TotalHeight} |
| 725 |
% \begin{variable} |
| 726 |
% {\l_@@_height_dim, \l_@@_depth_dim, \l_@@_width_dim, \l_@@_totalheight_dim} |
| 727 |
% Sets up design-level names for the various coffin dimensions. These are |
| 728 |
% not defined outside of this scope, and are dimensions so that they work |
| 729 |
% correctly inside for example \cs{fp_eval:n}. |
| 730 |
% \begin{macrocode} |
| 731 |
\cs_new_protected:Npn \@@_design_names:N #1 |
| 732 |
{ |
| 733 |
\dim_set:Nn \l_@@_height_dim { \coffin_ht:N #1 } |
| 734 |
\dim_set:Nn \l_@@_depth_dim { \coffin_dp:N #1 } |
| 735 |
\dim_set:Nn \l_@@_width_dim { \coffin_wd:N #1 } |
| 736 |
\dim_set:Nn \l_@@_totalheight_dim |
| 737 |
{ \l_@@_height_dim + \l_@@_depth_dim } |
| 738 |
\cs_set_eq:NN \Height \l_@@_height_dim |
| 739 |
\cs_set_eq:NN \Depth \l_@@_depth_dim |
| 740 |
\cs_set_eq:NN \Width \l_@@_width_dim |
| 741 |
\cs_set_eq:NN \TotalHeight \l_@@_totalheight_dim |
| 742 |
} |
| 743 |
\dim_new:N \l_@@_height_dim |
| 744 |
\dim_new:N \l_@@_depth_dim |
| 745 |
\dim_new:N \l_@@_width_dim |
| 746 |
\dim_new:N \l_@@_totalheight_dim |
| 747 |
% \end{macrocode} |
| 748 |
% \end{variable} |
| 749 |
% \end{variable} |
| 750 |
% \end{macro} |
| 751 |
% |
| 752 |
% A lot of this is more-or-less just passing data straight through. |
| 753 |
% |
| 754 |
% \begin{macro}{\NewCoffin} |
| 755 |
% This is a very easy conversion. |
| 756 |
% \begin{macrocode} |
| 757 |
\NewDocumentCommand \NewCoffin { m } |
| 758 |
{ \coffin_new:N #1 } |
| 759 |
% \end{macrocode} |
| 760 |
% \end{macro} |
| 761 |
% |
| 762 |
% \begin{macro}{\SetHorizontalCoffin} |
| 763 |
% \begin{macro}{\SetVerticalCoffin} |
| 764 |
% These are again straight-forward translations. |
| 765 |
% \begin{macrocode} |
| 766 |
\NewDocumentCommand \SetHorizontalCoffin { m +m } |
| 767 |
{ \hcoffin_set:Nn #1 {#2} } |
| 768 |
\NewDocumentCommand \SetVerticalCoffin { m m +m } |
| 769 |
{ \vcoffin_set:Nnn #1 {#2} {#3} } |
| 770 |
% \end{macrocode} |
| 771 |
% \end{macro} |
| 772 |
% \end{macro} |
| 773 |
% |
| 774 |
% \begin{macro}{\SetHorizontalPole} |
| 775 |
% \begin{macro}{\SetVerticalPole} |
| 776 |
% Here, there is a need to set up the design-level names for coffin |
| 777 |
% dimensions. This requires grouping, but the coffin work has to occur |
| 778 |
% outside of the group. Hence there is a bit of expansion trickery. |
| 779 |
% \begin{macrocode} |
| 780 |
\NewDocumentCommand \SetHorizontalPole { m m m } |
| 781 |
{ |
| 782 |
\group_begin: |
| 783 |
\@@_design_names:N #1 |
| 784 |
\use:e |
| 785 |
{ |
| 786 |
\group_end: |
| 787 |
\coffin_set_horizontal_pole:Nnn #1 |
| 788 |
{ \exp_not:n {#2} } { \dim_eval:n {#3} } |
| 789 |
} |
| 790 |
} |
| 791 |
\NewDocumentCommand \SetVerticalPole { m m m } |
| 792 |
{ |
| 793 |
\group_begin: |
| 794 |
\@@_design_names:N #1 |
| 795 |
\use:e |
| 796 |
{ |
| 797 |
\group_end: |
| 798 |
\coffin_set_vertical_pole:Nnn #1 |
| 799 |
{ \exp_not:n {#2} } { \dim_eval:n {#3} } |
| 800 |
} |
| 801 |
} |
| 802 |
% \end{macrocode} |
| 803 |
% \end{macro} |
| 804 |
% \end{macro} |
| 805 |
% |
| 806 |
% \begin{macro}{\JoinCoffins} |
| 807 |
% The \cs{JoinCoffins} function needs to do a bit of work on the input |
| 808 |
% syntax, as there are a number of optional arguments to worry about. |
| 809 |
% The idea here is that \cs{JoinCoffins} can be used to either expand |
| 810 |
% the bounding box of \meta{coffin1} or add \meta{coffin2} without any |
| 811 |
% expansion of the bounding box. There are also the two handle positions |
| 812 |
% and the offset to sort out. |
| 813 |
% \begin{macrocode} |
| 814 |
\NewDocumentCommand \JoinCoffins |
| 815 |
{ |
| 816 |
o |
| 817 |
s |
| 818 |
m |
| 819 |
> { \SplitArgument { 1 } { , } } O { H , l } |
| 820 |
m |
| 821 |
> { \SplitArgument { 1 } { , } } O { H , l } |
| 822 |
> { \SplitArgument { 1 } { , } } D ( ) { 0 pt , 0 pt } |
| 823 |
} |
| 824 |
{ |
| 825 |
\IfNoValueTF {#1} |
| 826 |
{ |
| 827 |
\IfBooleanTF #2 |
| 828 |
{ \coffin_attach:NnnNnnnn #3 #4 #5 #6 #7 } |
| 829 |
{ \coffin_join:NnnNnnnn #3 #4 #5 #6 #7 } |
| 830 |
} |
| 831 |
{ |
| 832 |
\group_begin: |
| 833 |
\keys_set:nn { coffin } {#1} |
| 834 |
\tl_set:Ne \l_@@_tmp_tl |
| 835 |
{ |
| 836 |
\group_end: |
| 837 |
\bool_if:NTF \l_@@_bound_box_grow_bool |
| 838 |
{ \coffin_join:NnnNnnnn } |
| 839 |
{ \coffin_attach:NnnNnnnn } |
| 840 |
\exp_not:N #3 |
| 841 |
{ \exp_not:o { \l_@@_A_hpole_tl } } |
| 842 |
{ \exp_not:o { \l_@@_A_vpole_tl } } |
| 843 |
\exp_not:N #5 |
| 844 |
{ \exp_not:o { \l_@@_B_hpole_tl } } |
| 845 |
{ \exp_not:o { \l_@@_B_vpole_tl } } |
| 846 |
{ \dim_use:N \l_@@_hoffset_dim } |
| 847 |
{ \dim_use:N \l_@@_voffset_dim } |
| 848 |
} |
| 849 |
\l_@@_tmp_tl |
| 850 |
} |
| 851 |
} |
| 852 |
% \end{macrocode} |
| 853 |
% \end{macro} |
| 854 |
% |
| 855 |
% \begin{macro}{\TypesetCoffin} |
| 856 |
% For typesetting coffins there are two optional arguments, both of |
| 857 |
% which need to be split. This is a simpler case of the code needed for |
| 858 |
% \cs{JoinCoffins}. |
| 859 |
% \begin{macrocode} |
| 860 |
\NewDocumentCommand \TypesetCoffin |
| 861 |
{ |
| 862 |
m |
| 863 |
> { \SplitArgument { 1 } { , } } O { H , l } |
| 864 |
> { \SplitArgument { 1 } { , } } D ( ) { 0 pt , 0 pt } |
| 865 |
} |
| 866 |
{ \coffin_typeset:Nnnnn #1 #2 #3 } |
| 867 |
% \end{macrocode} |
| 868 |
% \end{macro} |
| 869 |
% |
| 870 |
% \begin{macro}{\RotateCoffin} |
| 871 |
% \begin{macro}{\ResizeCoffin} |
| 872 |
% \begin{macro}{\ScaleCoffin} |
| 873 |
% Mores straight-forward copies. |
| 874 |
% \begin{macrocode} |
| 875 |
\NewDocumentCommand \RotateCoffin { m m } |
| 876 |
{ \coffin_rotate:Nn #1 {#2} } |
| 877 |
\NewDocumentCommand \ResizeCoffin { m m m } |
| 878 |
{ \coffin_resize:Nnn #1 {#2} {#3} } |
| 879 |
\NewDocumentCommand \ScaleCoffin { m m m } |
| 880 |
{ \coffin_scale:Nnn #1 {#2} {#3} } |
| 881 |
% \end{macrocode} |
| 882 |
% \end{macro} |
| 883 |
% \end{macro} |
| 884 |
% \end{macro} |
| 885 |
% |
| 886 |
% \begin{macro}{\CoffinDepth, \CoffinHeight, \CoffinTotalHeigth, \CoffinWidth} |
| 887 |
% Nothing too complex, except that the total height is set up as an |
| 888 |
% expression so that it will act correctly if prefixed with a negative |
| 889 |
% sign, etc. |
| 890 |
% \begin{macrocode} |
| 891 |
\NewDocumentCommand \CoffinDepth { m } |
| 892 |
{ \dim_eval:n { \coffin_dp:N #1 } } |
| 893 |
\NewDocumentCommand \CoffinHeight { m } |
| 894 |
{ \dim_eval:n { \coffin_ht:N #1 } } |
| 895 |
\NewDocumentCommand \CoffinTotalHeight { m } |
| 896 |
{ \dim_eval:n { \coffin_ht:N #1 + \coffin_dp:N #1 } } |
| 897 |
\NewDocumentCommand \CoffinWidth { m } |
| 898 |
{ \dim_eval:n { \coffin_wd:N #1 } } |
| 899 |
% \end{macrocode} |
| 900 |
% \end{macro} |
| 901 |
% |
| 902 |
% \begin{macro}{\DisplayCoffinHandles} |
| 903 |
% Displaying all of the handles is a bit easier, as there is no need |
| 904 |
% to worry about the handle. |
| 905 |
% \begin{macrocode} |
| 906 |
\NewDocumentCommand \DisplayCoffinHandles { m m } |
| 907 |
{ \coffin_if_exist:NT #1 { \coffin_display_handles:Nn #1 {#2} } } |
| 908 |
% \end{macrocode} |
| 909 |
% \end{macro} |
| 910 |
% |
| 911 |
% \begin{macro}{\MarkCoffinHandle} |
| 912 |
% Marking a handle requires a bit of work with the input, so that |
| 913 |
% the design-level interface is \enquote{nice}. |
| 914 |
% \begin{macrocode} |
| 915 |
\NewDocumentCommand \MarkCoffinHandle |
| 916 |
{ m > { \SplitArgument { 1 } { , } } O { H , l } m } |
| 917 |
{ \coffin_if_exist:NT #1 { \coffin_mark_handle:Nnnn #1 #2 {#3} } } |
| 918 |
% \end{macrocode} |
| 919 |
% \end{macro} |
| 920 |
% |
| 921 |
% \begin{macro}{\ShowCoffinStructure} |
| 922 |
% Back again to easy-to-implement functions. |
| 923 |
% \begin{macrocode} |
| 924 |
\NewDocumentCommand \ShowCoffinStructure { m } |
| 925 |
{ \coffin_show_structure:N #1 } |
| 926 |
% \end{macrocode} |
| 927 |
% \end{macro} |
| 928 |
% |
| 929 |
% \begin{macrocode} |
| 930 |
%</package> |
| 931 |
% \end{macrocode} |
| 932 |
% |
| 933 |
% \end{implementation} |
| 934 |
% |
| 935 |
% \PrintIndex |