Debian Codegraph @

texmf-dist/source/latex/l3kernel/l3coffins.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: l3coffins.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 "l3kernel 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,kernel]{l3doc}
27 \begin{document}
28 \DocInput{\jobname.dtx}
29 \end{document}
30 %</driver>
31 % \fi
32 %
33 % \title{^^A
34 % The \pkg{l3coffins} module\\ Coffin code layer^^A
35 % }
36 %
37 % \author{^^A
38 % The \LaTeX{} Project\thanks
39 % {^^A
40 % E-mail:
41 % \href{mailto:[email protected]}
42 % {[email protected]}^^A
43 % }^^A
44 % }
45 %
46 % \date{Released 2026-05-15}
47 %
48 % \maketitle
49 %
50 % \begin{documentation}
51 %
52 % In \pkg{expl3} terminology, a \enquote{coffin} is a box containing
53 % typeset material. Along with the box itself, the coffin structure
54 % includes information on the size and shape of the box, which makes
55 % it possible to align two or more coffins easily. This is achieved
56 % by providing a series of \enquote{poles} for each coffin. These
57 % are horizontal and vertical lines through the coffin at defined
58 % positions, for example the top or horizontal center. The points
59 % where these poles intersect are called \enquote{handles}. Two
60 % coffins can then be aligned by describing the relationship between
61 % a handle on one coffin with a handle on the second. In words, an
62 % example might then read
63 % \begin{quote}
64 % Align the top-left handle of coffin A with the bottom-right
65 % handle of coffin B.
66 % \end{quote}
67 %
68 % The locations of coffin handles are much easier to understand
69 % visually. Figure~\ref{fgr:handles} shows the standard handle
70 % positions for a coffin typeset in horizontal mode (left) and in
71 % vertical mode (right). Notice that the later case results in a greater
72 % number of handles being available. As illustrated, each handle
73 % results from the intersection of two poles. For example, the center
74 % of the coffin is marked |(hc,vc)|, i.e., it is the
75 % point of intersection of the horizontal center pole with the
76 % vertical center pole. New handles are generated automatically when
77 % poles are added to a coffin: handles are \enquote{dynamic} entities.
78 %
79 % \begin{figure}
80 % \hfil
81 % \begin{minipage}{0.4\textwidth}
82 % \ExplSyntaxOn
83 % \hcoffin_set:Nn \l_tmpa_coffin
84 % { \color_select:n { black!10!white } \rule { 1in } { 1in } }
85 % \coffin_display_handles:Nn \l_tmpa_coffin { blue }
86 % \end{minipage}
87 % \hfil
88 % \begin{minipage}{0.4\textwidth}
89 % \ExplSyntaxOn
90 % \vcoffin_set:Nnn \l_tmpa_coffin { 1in }
91 % { \color_select:n { black!10!white } \rule { 1in } { 1in } }
92 % \coffin_display_handles:Nn \l_tmpa_coffin { blue }
93 % \end{minipage}
94 % \hfil
95 % \caption{Standard coffin handles: left, horizontal coffin; right,
96 % vertical coffin}
97 % \label{fgr:handles}
98 % \end{figure}
99 %
100 % \section{Controlling coffin poles}
101 %
102 % A number of standard poles are automatically generated when the coffin
103 % is set or an alignment takes place. The standard poles for all coffins
104 % are:
105 % \begin{itemize}[font = \ttfamily]
106 % \item[l] a pole running along the left-hand edge of the bounding
107 % box of the coffin;
108 % \item[hc] a pole running vertically through the center of the coffin
109 % half-way between the left- and right-hand edges of the bounding
110 % box (i.e., the \enquote{horizontal center});
111 % \item[r] a pole running along the right-hand edge of the bounding
112 % box of the coffin;
113 % \item[b] a pole running along the bottom edge of the bounding
114 % box of the coffin;
115 % \item[vc] a pole running horizontally through the center of the
116 % coffin half-way between the bottom and top edges of the bounding
117 % box (i.e., the \enquote{vertical center});
118 % \item[t] a pole running along the top edge of the bounding
119 % box of the coffin;
120 % \item[H] a pole running along the baseline of the typeset material
121 % contained in the coffin.
122 % \end{itemize}
123 % In addition, coffins containing vertical-mode material also
124 % feature poles which reflect the richer nature of these systems:
125 % \begin{itemize}
126 % \item[B] a pole running along the baseline of the material at the
127 % bottom of the coffin.
128 % \item[T] a pole running along the baseline of the material at the top
129 % of the coffin.
130 % \end{itemize}
131 %
132 % \section{Creating and initializing coffins}
133 %
134 % \begin{function}[added = 2011-08-17]{\coffin_new:N, \coffin_new:c}
135 % \begin{syntax}
136 % \cs{coffin_new:N} \meta{coffin}
137 % \end{syntax}
138 % Creates a new \meta{coffin} or raises an error if the name is
139 % already taken. The declaration is global. The \meta{coffin} is
140 % initially empty.
141 % \end{function}
142 %
143 % \begin{function}[added = 2011-08-17, updated = 2019-01-21]
144 % {
145 % \coffin_clear:N, \coffin_clear:c,
146 % \coffin_gclear:N, \coffin_gclear:c
147 % }
148 % \begin{syntax}
149 % \cs{coffin_clear:N} \meta{coffin}
150 % \end{syntax}
151 % Clears the content of the \meta{coffin}.
152 % \end{function}
153 %
154 % \begin{function}[added = 2011-08-17, updated = 2019-01-21]
155 % {
156 % \coffin_set_eq:NN, \coffin_set_eq:Nc,
157 % \coffin_set_eq:cN, \coffin_set_eq:cc,
158 % \coffin_gset_eq:NN, \coffin_gset_eq:Nc,
159 % \coffin_gset_eq:cN, \coffin_gset_eq:cc
160 % }
161 % \begin{syntax}
162 % \cs{coffin_set_eq:NN} \meta{coffin_1} \meta{coffin_2}
163 % \end{syntax}
164 % Sets both the content and poles of \meta{coffin_1} equal to those
165 % of \meta{coffin_2}.
166 % \end{function}
167 %
168 % \begin{function}[EXP, pTF, added = 2012-06-20]
169 % {\coffin_if_exist:N, \coffin_if_exist:c}
170 % \begin{syntax}
171 % \cs{coffin_if_exist_p:N} \meta{coffin}
172 % \cs{coffin_if_exist:NTF} \meta{coffin} \Arg{true code} \Arg{false code}
173 % \end{syntax}
174 % Tests whether the \meta{coffin} is currently defined.
175 % \end{function}
176 %
177 % \section{Setting coffin content and poles}
178 %
179 % \begin{function}[added = 2011-08-17, updated = 2019-01-21]
180 % {
181 % \hcoffin_set:Nn, \hcoffin_set:cn,
182 % \hcoffin_gset:Nn, \hcoffin_gset:cn
183 % }
184 % \begin{syntax}
185 % \cs{hcoffin_set:Nn} \meta{coffin} \Arg{material}
186 % \end{syntax}
187 % Typesets the \meta{material} in horizontal mode, storing the result
188 % in the \meta{coffin}. The standard poles for the \meta{coffin} are
189 % then set up based on the size of the typeset material.
190 % \end{function}
191 %
192 % \begin{function}[added = 2011-09-10, updated = 2019-01-21]
193 % {
194 % \hcoffin_set:Nw, \hcoffin_set:cw, \hcoffin_set_end:,
195 % \hcoffin_gset:Nw, \hcoffin_gset:cw, \hcoffin_gset_end:
196 % }
197 % \begin{syntax}
198 % \cs{hcoffin_set:Nw} \meta{coffin} \meta{material} \cs{hcoffin_set_end:}
199 % \end{syntax}
200 % Typesets the \meta{material} in horizontal mode, storing the result
201 % in the \meta{coffin}. The standard poles for the \meta{coffin} are
202 % then set up based on the size of the typeset material.
203 % These functions are useful for setting the entire contents of an
204 % environment in a coffin.
205 % \end{function}
206 %
207 % \begin{function}[added = 2011-08-17, updated = 2023-02-03]
208 % {
209 % \vcoffin_set:Nnn, \vcoffin_set:cnn,
210 % \vcoffin_gset:Nnn, \vcoffin_gset:cnn
211 % }
212 % \begin{syntax}
213 % \cs{vcoffin_set:Nnn} \meta{coffin} \Arg{width} \Arg{material}
214 % \end{syntax}
215 % Typesets the \meta{material} in vertical mode constrained to the
216 % given \meta{width} and stores the result in the \meta{coffin}. The
217 % standard poles for the \meta{coffin} are then set up based on the
218 % size of the typeset material.
219 % \end{function}
220 %
221 % \begin{function}[added = 2011-09-10, updated = 2023-02-03]
222 % {
223 % \vcoffin_set:Nnw, \vcoffin_set:cnw, \vcoffin_set_end:,
224 % \vcoffin_gset:Nnw, \vcoffin_gset:cnw, \vcoffin_gset_end:
225 % }
226 % \begin{syntax}
227 % \cs{vcoffin_set:Nnw} \meta{coffin} \Arg{width} \meta{material} \cs{vcoffin_set_end:}
228 % \end{syntax}
229 % Typesets the \meta{material} in vertical mode constrained to the
230 % given \meta{width} and stores the result in the \meta{coffin}. The
231 % standard poles for the \meta{coffin} are then set up based on the
232 % size of the typeset material.
233 % These functions are useful for setting the entire contents of an
234 % environment in a coffin.
235 % \end{function}
236 %
237 % \begin{function}[added = 2012-07-20, updated = 2019-01-21]
238 % {
239 % \coffin_set_horizontal_pole:Nnn, \coffin_set_horizontal_pole:cnn,
240 % \coffin_gset_horizontal_pole:Nnn, \coffin_gset_horizontal_pole:cnn
241 % }
242 % \begin{syntax}
243 % \cs{coffin_set_horizontal_pole:Nnn} \meta{coffin}
244 % ~~\Arg{pole} \Arg{offset}
245 % \end{syntax}
246 % Sets the \meta{pole} to run horizontally through the \meta{coffin}.
247 % The \meta{pole} is placed at the \meta{offset} from the
248 % baseline of the \meta{coffin}. The
249 % \meta{offset} should be given as a dimension expression.
250 % \end{function}
251 %
252 % \begin{function}[added = 2012-07-20, updated = 2019-01-21]
253 % {
254 % \coffin_set_vertical_pole:Nnn, \coffin_set_vertical_pole:cnn,
255 % \coffin_gset_vertical_pole:Nnn, \coffin_gset_vertical_pole:cnn
256 % }
257 % \begin{syntax}
258 % \cs{coffin_set_vertical_pole:Nnn} \meta{coffin} \Arg{pole} \Arg{offset}
259 % \end{syntax}
260 % Sets the \meta{pole} to run vertically through the \meta{coffin}.
261 % The \meta{pole} is placed at the \meta{offset} from the
262 % left-hand edge of the bounding box of the \meta{coffin}. The
263 % \meta{offset} should be given as a dimension expression.
264 % \end{function}
265 %
266 % \begin{function}[added = 2023-05-17]{\coffin_reset_poles:N, \coffin_greset_poles:N}
267 % \begin{syntax}
268 % \cs{coffin_reset_poles:N} \meta{coffin}
269 % \end{syntax}
270 % Resets the poles of the \meta{coffin} to the standard set, removing any
271 % custom or inherited poles. The poles will therefore be equal to those that
272 % would be obtained from \cs{hcoffin_set:Nn} or similar; the bounding box
273 % of the coffin is not reset, so any material outside of the formal bounding box
274 % will not influence the poles.
275 % \end{function}
276 %
277 % \begin{function}[added = 2026-02-09, EXP]{\coffin_pole:Nn}
278 % \begin{syntax}
279 % \cs{coffin_pole:Nn} \meta{coffin} \Arg{pole}
280 % \end{syntax}
281 % Expands to four brace groups which contain the position of the given
282 % \meta{pole} for the \meta{coffin}:
283 % \begin{enumerate}
284 % \item The $x$ coordinate of a point on the pole.
285 % \item The $y$ coordinate of a point on the pole.
286 % \item The $x$ component of a vector denoting the direction of the pole.
287 % \item The $y$ component of a vector denoting the direction of the pole.
288 % \end{enumerate}
289 % The $x$ and $y$ coordinates are relative to the left baseline (reference
290 % point) of the coffin; the vector components are given in points with a
291 % maximum value of $1000\,\mathrm{pt}$.
292 % See also the output of \cs{coffin_show_structure:N}.
293 % \end{function}
294 %
295 % \section{Coffin affine transformations}
296 %
297 % \begin{function}[updated = 2019-01-23]
298 % {
299 % \coffin_resize:Nnn, \coffin_resize:cnn,
300 % \coffin_gresize:Nnn, \coffin_gresize:cnn
301 % }
302 % \begin{syntax}
303 % \cs{coffin_resize:Nnn} \meta{coffin} \Arg{width} \Arg{total-height}
304 % \end{syntax}
305 % Resized the \meta{coffin} to \meta{width} and \meta{total-height},
306 % both of which should be given as dimension expressions.
307 % \end{function}
308 %
309 % \begin{function}
310 % {
311 % \coffin_rotate:Nn, \coffin_rotate:cn,
312 % \coffin_grotate:Nn, \coffin_grotate:cn
313 % }
314 % \begin{syntax}
315 % \cs{coffin_rotate:Nn} \meta{coffin} \Arg{angle}
316 % \end{syntax}
317 % Rotates the \meta{coffin} by the given \meta{angle} (given in
318 % degrees counter-clockwise). This process rotates both the
319 % coffin content and poles. Multiple rotations do not result in
320 % the bounding box of the coffin growing unnecessarily.
321 % \end{function}
322 %
323 % \begin{function}[updated = 2019-01-23]
324 % {
325 % \coffin_scale:Nnn, \coffin_scale:cnn,
326 % \coffin_gscale:Nnn, \coffin_gscale:cnn
327 % }
328 % \begin{syntax}
329 % \cs{coffin_scale:Nnn} \meta{coffin} \Arg{x-scale} \Arg{y-scale}
330 % \end{syntax}
331 % Scales the \meta{coffin} by a factors \meta{x-scale} and
332 % \meta{y-scale} in the horizontal and vertical directions,
333 % respectively. The two scale factors should be given as real numbers.
334 % \end{function}
335 %
336 % \section{Joining and using coffins}
337 %
338 % \begin{function}[updated = 2019-01-22]
339 % {
340 % \coffin_attach:NnnNnnnn, \coffin_attach:cnnNnnnn,
341 % \coffin_attach:Nnncnnnn, \coffin_attach:cnncnnnn,
342 % \coffin_gattach:NnnNnnnn, \coffin_gattach:cnnNnnnn,
343 % \coffin_gattach:Nnncnnnn, \coffin_gattach:cnncnnnn
344 % }
345 % \begin{syntax}
346 % \cs{coffin_attach:NnnNnnnn}
347 % ~~\meta{coffin_1} \Arg{coffin_1-pole_1} \Arg{coffin_1-pole_2}
348 % ~~\meta{coffin_2} \Arg{coffin_2-pole_1} \Arg{coffin_2-pole_2}
349 % ~~\Arg{x-offset} \Arg{y-offset}
350 % \end{syntax}
351 % This function attaches \meta{coffin_2} to \meta{coffin_1} such that the bounding box
352 % of \meta{coffin_1} is not altered, i.e., \meta{coffin_2} can
353 % protrude outside of the bounding box of the coffin. The alignment
354 % is carried out by first calculating \meta{handle_1}, the
355 % point of intersection of \meta{coffin_1-pole_1} and
356 % \meta{coffin_1-pole_2}, and \meta{handle_2}, the point of intersection
357 % of \meta{coffin_2-pole_1} and \meta{coffin_2-pole_2}. \meta{coffin_2} is
358 % then attached to \meta{coffin_1} such that the relationship between
359 % \meta{handle_1} and \meta{handle_2} is described by the \meta{x-offset}
360 % and \meta{y-offset}. The two offsets should be given as dimension
361 % expressions.
362 % \end{function}
363 %
364 % \begin{function}[updated = 2019-01-22]
365 % {
366 % \coffin_join:NnnNnnnn, \coffin_join:cnnNnnnn,
367 % \coffin_join:Nnncnnnn, \coffin_join:cnncnnnn,
368 % \coffin_gjoin:NnnNnnnn, \coffin_gjoin:cnnNnnnn,
369 % \coffin_gjoin:Nnncnnnn, \coffin_gjoin:cnncnnnn
370 % }
371 % \begin{syntax}
372 % \cs{coffin_join:NnnNnnnn}
373 % ~~\meta{coffin_1} \Arg{coffin_1-pole_1} \Arg{coffin_1-pole_2}
374 % ~~\meta{coffin_2} \Arg{coffin_2-pole_1} \Arg{coffin_2-pole_2}
375 % ~~\Arg{x-offset} \Arg{y-offset}
376 % \end{syntax}
377 % This function joins \meta{coffin_2} to \meta{coffin_1} such that the bounding box
378 % of \meta{coffin_1} may expand. The new bounding
379 % box covers the area containing the bounding boxes of the two
380 % original coffins. The alignment is carried out by first calculating
381 % \meta{handle_1}, the point of intersection of \meta{coffin_1-pole_1} and
382 % \meta{coffin_1-pole_2}, and \meta{handle_2}, the point of intersection
383 % of \meta{coffin_2-pole_1} and \meta{coffin_2-pole_2}. \meta{coffin_2} is
384 % then attached to \meta{coffin_1} such that the relationship between
385 % \meta{handle_1} and \meta{handle_2} is described by the \meta{x-offset}
386 % and \meta{y-offset}. The two offsets should be given as dimension
387 % expressions.
388 % \end{function}
389 %
390 % \begin{function}[updated = 2012-07-20]
391 % {\coffin_typeset:Nnnnn, \coffin_typeset:cnnnn}
392 % \begin{syntax}
393 % \cs{coffin_typeset:Nnnnn} \meta{coffin} \Arg{pole_1} \Arg{pole_2}
394 % ~~\Arg{x-offset} \Arg{y-offset}
395 % \end{syntax}
396 % Typesetting is carried out by first calculating \meta{handle}, the
397 % point of intersection of \meta{pole_1} and \meta{pole_2}. The coffin
398 % is then typeset in horizontal mode such that the relationship between the
399 % current reference point in the document and the \meta{handle} is described
400 % by the \meta{x-offset} and \meta{y-offset}. The two offsets should
401 % be given as dimension expressions. Typesetting a coffin is
402 % therefore analogous to carrying out an alignment where the
403 % \enquote{parent} coffin is the current insertion point.
404 % \end{function}
405 %
406 % \section{Measuring coffins}
407 %
408 % \begin{function}{\coffin_dp:N, \coffin_dp:c}
409 % \begin{syntax}
410 % \cs{coffin_dp:N} \meta{coffin}
411 % \end{syntax}
412 % Calculates the depth (below the baseline) of the \meta{coffin}
413 % in a form suitable for use in a \meta{dim expr}.
414 % \end{function}
415 %
416 % \begin{function}{\coffin_ht:N, \coffin_ht:c}
417 % \begin{syntax}
418 % \cs{coffin_ht:N} \meta{coffin}
419 % \end{syntax}
420 % Calculates the height (above the baseline) of the \meta{coffin}
421 % in a form suitable for use in a \meta{dim expr}.
422 % \end{function}
423 %
424 % \begin{function}[added = 2024-10-01]{\coffin_ht_plus_dp:N, \coffin_ht_plus_dp:c}
425 % \begin{syntax}
426 % \cs{coffin_ht_plus_dp:N} \meta{coffin}
427 % \end{syntax}
428 % Calculates the total vertical size (height plus depth) of the \meta{coffin}
429 % in a form suitable for use in a \meta{dim expr}.
430 % \end{function}
431 %
432 % \begin{function}{\coffin_wd:N, \coffin_wd:c}
433 % \begin{syntax}
434 % \cs{coffin_wd:N} \meta{coffin}
435 % \end{syntax}
436 % Calculates the width of the \meta{coffin} in a form
437 % suitable for use in a \meta{dim expr}.
438 % \end{function}
439 %
440 % \section{Coffin diagnostics}
441 %
442 % \begin{function}[updated = 2011-09-02]
443 % {\coffin_display_handles:Nn, \coffin_display_handles:cn}
444 % \begin{syntax}
445 % \cs{coffin_display_handles:Nn} \meta{coffin} \Arg{color}
446 % \end{syntax}
447 % This function first calculates the intersections between all of
448 % the \meta{poles} of the \meta{coffin} to give a set of
449 % \meta{handles}. It then prints the \meta{coffin} at the current
450 % location in the source, with the position of the \meta{handles}
451 % marked on the coffin. The \meta{handles} are labeled as part
452 % of this process: the locations of the \meta{handles} and the labels
453 % are both printed in the \meta{color} specified.
454 % \end{function}
455 %
456 % \begin{function}[updated = 2011-09-02]
457 % {\coffin_mark_handle:Nnnn, \coffin_mark_handle:cnnn}
458 % \begin{syntax}
459 % \cs{coffin_mark_handle:Nnnn} \meta{coffin} \Arg{pole_1} \Arg{pole_2} \Arg{color}
460 % \end{syntax}
461 % This function first calculates the \meta{handle} for the
462 % \meta{coffin} as defined by the intersection of \meta{pole_1} and
463 % \meta{pole_2}. It then marks the position of the \meta{handle}
464 % on the \meta{coffin}. The \meta{handle} are labeled as part of
465 % this process: the location of the \meta{handle} and the label are
466 % both printed in the \meta{color} specified.
467 % \end{function}
468 %
469 % \begin{function}[updated = 2015-08-01]
470 % {\coffin_show_structure:N, \coffin_show_structure:c}
471 % \begin{syntax}
472 % \cs{coffin_show_structure:N} \meta{coffin}
473 % \end{syntax}
474 % This function shows the structural information about the
475 % \meta{coffin} in the terminal. The width, height and depth of the
476 % typeset material are given, along with the location of all of the
477 % poles of the coffin.
478 %
479 % Notice that the poles of a coffin are defined by four values:
480 % the $x$ and $y$ coordinates of a point that the pole
481 % passes through and the $x$- and $y$-components of a
482 % vector denoting the direction of the pole. It is the ratio between
483 % the later, rather than the absolute values, which determines the
484 % direction of the pole.
485 % \end{function}
486 %
487 % \begin{function}[added = 2014-08-22, updated = 2015-08-01]
488 % {\coffin_log_structure:N, \coffin_log_structure:c}
489 % \begin{syntax}
490 % \cs{coffin_log_structure:N} \meta{coffin}
491 % \end{syntax}
492 % This function writes the structural information about the
493 % \meta{coffin} in the log file. See also \cs{coffin_show_structure:N}
494 % which displays the result in the terminal.
495 % \end{function}
496 %
497 % \begin{function}[added = 2021-05-11]
498 % {\coffin_show:N, \coffin_show:c, \coffin_log:N, \coffin_log:c}
499 % \begin{syntax}
500 % \cs{coffin_show:N} \meta{coffin}
501 % \cs{coffin_log:N} \meta{coffin}
502 % \end{syntax}
503 % Shows full details of poles and contents of the \meta{coffin} in the
504 % terminal or log file. See \cs{coffin_show_structure:N} and
505 % \cs{box_show:N} to show separately the pole structure and the
506 % contents.
507 % \end{function}
508 %
509 % \begin{function}[added = 2021-05-11]
510 % {\coffin_show:Nnn, \coffin_show:cnn, \coffin_log:Nnn, \coffin_log:cnn}
511 % \begin{syntax}
512 % \cs{coffin_show:Nnn} \meta{coffin} \Arg{int expr_1} \Arg{int expr_2}
513 % \cs{coffin_log:Nnn} \meta{coffin} \Arg{int expr_1} \Arg{int expr_2}
514 % \end{syntax}
515 % Shows poles and contents of the \meta{coffin} in the terminal or log
516 % file, showing the first \meta{int expr_1} items in the coffin, and
517 % descending into \meta{int expr_2} group levels. See
518 % \cs{coffin_show_structure:N} and \cs{box_show:Nnn} to show
519 % separately the pole structure and the contents.
520 % \end{function}
521 %
522 % \section{Constants and variables}
523 %
524 % \begin{variable}{\c_empty_coffin}
525 % A permanently empty coffin.
526 % \end{variable}
527 %
528 % \begin{variable}[added = 2012-06-19]{\l_tmpa_coffin, \l_tmpb_coffin}
529 % Scratch coffins for local assignment. These are never used by
530 % the kernel code, and so are safe for use with any \LaTeX3-defined
531 % function. However, they may be overwritten by other non-kernel
532 % code and so should only be used for short-term storage.
533 % \end{variable}
534 %
535 % \begin{variable}[added = 2019-01-24]{\g_tmpa_coffin, \g_tmpb_coffin}
536 % Scratch coffins for global assignment. These are never used by
537 % the kernel code, and so are safe for use with any \LaTeX3-defined
538 % function. However, they may be overwritten by other non-kernel
539 % code and so should only be used for short-term storage.
540 % \end{variable}
541 %
542 % \end{documentation}
543 %
544 % \begin{implementation}
545 %
546 % \section{\pkg{l3coffins} implementation}
547 %
548 % \begin{macrocode}
549 %<*code>
550 % \end{macrocode}
551 %
552 % \begin{macrocode}
553 %<@@=coffin>
554 % \end{macrocode}
555 %
556 % \subsection{Coffins: data structures and general variables}
557 %
558 % \begin{variable}{\l_@@_tmp_box}
559 % \begin{variable}{\l_@@_tmp_dim}
560 % \begin{variable}{\l_@@_tmp_tl}
561 % Scratch variables.
562 % \begin{macrocode}
563 \box_new:N \l_@@_tmp_box
564 \dim_new:N \l_@@_tmp_dim
565 \tl_new:N \l_@@_tmp_tl
566 % \end{macrocode}
567 % \end{variable}
568 % \end{variable}
569 % \end{variable}
570 %
571 % \begin{variable}{\c_@@_corners_prop}
572 % The \enquote{corners}; of a coffin define the real content, as
573 % opposed to the \TeX{} bounding box. They all start off in the same
574 % place, of course.
575 % \begin{macrocode}
576 \prop_const_from_keyval:Nn \c_@@_corners_prop
577 {
578 tl = { 0pt } { 0pt } ,
579 tr = { 0pt } { 0pt } ,
580 bl = { 0pt } { 0pt } ,
581 br = { 0pt } { 0pt } ,
582 }
583 % \end{macrocode}
584 % \end{variable}
585 %
586 % \begin{variable}{\c_@@_poles_prop}
587 % Pole positions are given for horizontal, vertical and reference-point
588 % based values.
589 % \begin{macrocode}
590 \prop_const_from_keyval:Nn \c_@@_poles_prop
591 {
592 l = { 0pt } { 0pt } { 0pt } { 1000pt } ,
593 hc = { 0pt } { 0pt } { 0pt } { 1000pt } ,
594 r = { 0pt } { 0pt } { 0pt } { 1000pt } ,
595 b = { 0pt } { 0pt } { 1000pt } { 0pt } ,
596 vc = { 0pt } { 0pt } { 1000pt } { 0pt } ,
597 t = { 0pt } { 0pt } { 1000pt } { 0pt } ,
598 B = { 0pt } { 0pt } { 1000pt } { 0pt } ,
599 H = { 0pt } { 0pt } { 1000pt } { 0pt } ,
600 T = { 0pt } { 0pt } { 1000pt } { 0pt } ,
601 }
602 % \end{macrocode}
603 % \end{variable}
604 %
605 % \begin{variable}{\l_@@_slope_A_fp}
606 % \begin{variable}{\l_@@_slope_B_fp}
607 % Used for calculations of intersections.
608 % \begin{macrocode}
609 \fp_new:N \l_@@_slope_A_fp
610 \fp_new:N \l_@@_slope_B_fp
611 % \end{macrocode}
612 % \end{variable}
613 % \end{variable}
614 %
615 % \begin{variable}{\l_@@_error_bool}
616 % For propagating errors so that parts of the code can work around them.
617 % \begin{macrocode}
618 \bool_new:N \l_@@_error_bool
619 % \end{macrocode}
620 % \end{variable}
621 %
622 % \begin{variable}{\l_@@_offset_x_dim}
623 % \begin{variable}{\l_@@_offset_y_dim}
624 % The offset between two sets of coffin handles when typesetting. These
625 % values are corrected from those requested in an alignment for the
626 % positions of the handles.
627 % \begin{macrocode}
628 \dim_new:N \l_@@_offset_x_dim
629 \dim_new:N \l_@@_offset_y_dim
630 % \end{macrocode}
631 % \end{variable}
632 % \end{variable}
633 %
634 % \begin{variable}{\l_@@_x_dim}
635 % \begin{variable}{\l_@@_y_dim}
636 % \begin{variable}{\l_@@_x_prime_dim}
637 % \begin{variable}{\l_@@_y_prime_dim}
638 % For calculating intersections and so forth.
639 % \begin{macrocode}
640 \dim_new:N \l_@@_x_dim
641 \dim_new:N \l_@@_y_dim
642 \dim_new:N \l_@@_x_prime_dim
643 \dim_new:N \l_@@_y_prime_dim
644 % \end{macrocode}
645 % \end{variable}
646 % \end{variable}
647 % \end{variable}
648 % \end{variable}
649 %
650 % \subsection{Basic coffin functions}
651 %
652 % There are a number of basic functions needed for creating coffins and
653 % placing material in them. This all relies on the following data
654 % structures.
655 %
656 % \begin{macro}[EXP]{\@@_to_value:N}
657 % Coffins are a two-part structure and we rely on the internal nature of
658 % box allocation to make everything work. As such, we need an interface
659 % to turn coffin identifiers into numbers. For the purposes here, the
660 % signature allowed is |N| despite the nature of the underlying primitive.
661 % \begin{macrocode}
662 \cs_new_eq:NN \@@_to_value:N \tex_number:D
663 % \end{macrocode}
664 % \end{macro}
665 %
666 % \begin{macro}[EXP, pTF]{\coffin_if_exist:N, \coffin_if_exist:c}
667 % Several of the higher-level coffin functions would give multiple
668 % errors if the coffin does not exist. A cleaner way to handle this
669 % is provided here: both the box and the coffin structure are
670 % checked.
671 % \begin{macrocode}
672 \prg_new_conditional:Npnn \coffin_if_exist:N #1 { p , T , F , TF }
673 {
674 \cs_if_exist:NTF #1
675 {
676 \cs_if_exist:cTF { coffin ~ \@@_to_value:N #1 ~ poles }
677 { \prg_return_true: }
678 { \prg_return_false: }
679 }
680 { \prg_return_false: }
681 }
682 \prg_generate_conditional_variant:Nnn \coffin_if_exist:N
683 { c } { p , T , F , TF }
684 % \end{macrocode}
685 % \end{macro}
686 %
687 % \begin{macro}{\@@_if_exist:NT}
688 % Several of the higher-level coffin functions would give multiple
689 % errors if the coffin does not exist. So a wrapper is provided to deal
690 % with this correctly, issuing an error on erroneous use.
691 % \begin{macrocode}
692 \cs_new_protected:Npn \@@_if_exist:NT #1#2
693 {
694 \coffin_if_exist:NTF #1
695 { #2 }
696 {
697 \msg_error:nne { coffin } { unknown }
698 { \token_to_str:N #1 }
699 }
700 }
701 % \end{macrocode}
702 % \end{macro}
703 %
704 % \begin{macro}
705 % {
706 % \coffin_clear:N, \coffin_clear:c,
707 % \coffin_gclear:N, \coffin_gclear:c
708 % }
709 % Clearing coffins means emptying the box and resetting all of the
710 % structures.
711 % \begin{macrocode}
712 \cs_new_protected:Npn \coffin_clear:N #1
713 {
714 \@@_if_exist:NT #1
715 {
716 \box_clear:N #1
717 \@@_reset_structure:N #1
718 }
719 }
720 \cs_generate_variant:Nn \coffin_clear:N { c }
721 \cs_new_protected:Npn \coffin_gclear:N #1
722 {
723 \@@_if_exist:NT #1
724 {
725 \box_gclear:N #1
726 \@@_greset_structure:N #1
727 }
728 }
729 \cs_generate_variant:Nn \coffin_gclear:N { c }
730 % \end{macrocode}
731 % \end{macro}
732 %
733 % \begin{macro}{\coffin_new:N, \coffin_new:c}
734 % Creating a new coffin means making the underlying box and adding the
735 % data structures. The \cs{debug_suspend:} and \cs{debug_resume:} functions
736 % prevent \cs{prop_gclear_new:c} from writing useless information to
737 % the log file.
738 % \begin{macrocode}
739 \cs_new_protected:Npn \coffin_new:N #1
740 {
741 \box_new:N #1
742 \debug_suspend:
743 \prop_gclear_new:c { coffin ~ \@@_to_value:N #1 ~ corners }
744 \prop_gclear_new:c { coffin ~ \@@_to_value:N #1 ~ poles }
745 \prop_gset_eq:cN { coffin ~ \@@_to_value:N #1 ~ corners }
746 \c_@@_corners_prop
747 \prop_gset_eq:cN { coffin ~ \@@_to_value:N #1 ~ poles }
748 \c_@@_poles_prop
749 \debug_resume:
750 }
751 \cs_generate_variant:Nn \coffin_new:N { c }
752 % \end{macrocode}
753 % \end{macro}
754 %
755 % \begin{macro}
756 % {
757 % \hcoffin_set:Nn, \hcoffin_set:cn,
758 % \hcoffin_gset:Nn, \hcoffin_gset:cn
759 % }
760 % Horizontal coffins are relatively easy: set the appropriate box,
761 % reset the structures then update the handle positions.
762 % \begin{macrocode}
763 \cs_new_protected:Npn \hcoffin_set:Nn #1#2
764 {
765 \@@_if_exist:NT #1
766 {
767 \hbox_set:Nn #1
768 {
769 \color_ensure_current:
770 #2
771 }
772 \coffin_reset_poles:N #1
773 }
774 }
775 \cs_generate_variant:Nn \hcoffin_set:Nn { c }
776 \cs_new_protected:Npn \hcoffin_gset:Nn #1#2
777 {
778 \@@_if_exist:NT #1
779 {
780 \hbox_gset:Nn #1
781 {
782 \color_ensure_current:
783 #2
784 }
785 \coffin_greset_poles:N #1
786 }
787 }
788 \cs_generate_variant:Nn \hcoffin_gset:Nn { c }
789 % \end{macrocode}
790 % \end{macro}
791 %
792 % \begin{macro}
793 % {
794 % \vcoffin_set:Nnn, \vcoffin_set:cnn,
795 % \vcoffin_gset:Nnn, \vcoffin_gset:cnn
796 % }
797 % \begin{macro}{\@@_set_vertical:NnnNNN}
798 % \begin{macro}{\@@_set_vertical_aux:}
799 % Setting vertical coffins is more complex. First, the material is
800 % typeset with a given width. The default handles and poles are set as
801 % for a horizontal coffin, before finding the top baseline using a
802 % temporary box. No \cs{color_ensure_current:} here as that would add a
803 % whatsit to the start of the vertical box and mess up the location of the
804 % \texttt{T}~pole (see \emph{\TeX{} by Topic} for discussion of the
805 % \tn{vtop} primitive, used to do the measuring).
806 % \begin{macrocode}
807 \cs_new_protected:Npn \vcoffin_set:Nnn #1#2#3
808 {
809 \@@_set_vertical:NnnNNN #1 {#2} {#3}
810 \vbox_set:Nn \coffin_reset_poles:N \@@_set_pole:Nnn
811 }
812 \cs_generate_variant:Nn \vcoffin_set:Nnn { c }
813 \cs_new_protected:Npn \vcoffin_gset:Nnn #1#2#3
814 {
815 \@@_set_vertical:NnnNNN #1 {#2} {#3}
816 \vbox_gset:Nn \coffin_greset_poles:N \@@_gset_pole:Nnn
817 }
818 \cs_generate_variant:Nn \vcoffin_gset:Nnn { c }
819 \cs_new_protected:Npn \@@_set_vertical:NnnNNN #1#2#3#4#5#6
820 {
821 \@@_if_exist:NT #1
822 {
823 #4 #1
824 {
825 \dim_set:Nn \tex_hsize:D {#2}
826 \@@_set_vertical_aux:
827 #3
828 }
829 #5 #1
830 \vbox_set_top:Nn \l_@@_tmp_box { \vbox_unpack:N #1 }
831 #6 #1 { T }
832 {
833 { 0pt }
834 {
835 \dim_eval:n
836 { \box_ht:N #1 - \box_ht:N \l_@@_tmp_box }
837 }
838 { 1000pt }
839 { 0pt }
840 }
841 \box_clear:N \l_@@_tmp_box
842 }
843 }
844 \cs_new_protected:Npe \@@_set_vertical_aux:
845 {
846 \bool_lazy_and:nnT
847 { \cs_if_exist_p:N \fmtname }
848 { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
849 {
850 \dim_set_eq:NN \exp_not:N \linewidth \tex_hsize:D
851 \dim_set_eq:NN \exp_not:N \columnwidth \tex_hsize:D
852 }
853 }
854 % \end{macrocode}
855 % \end{macro}
856 % \end{macro}
857 % \end{macro}
858 %
859 % \begin{macro}
860 % {\hcoffin_set:Nw, \hcoffin_set:cw, \hcoffin_gset:Nw, \hcoffin_gset:cw}
861 % \begin{macro}{\hcoffin_set_end:, \hcoffin_gset_end:}
862 % These are the \enquote{begin}/\enquote{end} versions of the above:
863 % watch the grouping!
864 % \begin{macrocode}
865 \cs_new_protected:Npn \hcoffin_set:Nw #1
866 {
867 \@@_if_exist:NT #1
868 {
869 \hbox_set:Nw #1 \color_ensure_current:
870 \cs_set_protected:Npn \hcoffin_set_end:
871 {
872 \hbox_set_end:
873 \coffin_reset_poles:N #1
874 }
875 }
876 }
877 \cs_generate_variant:Nn \hcoffin_set:Nw { c }
878 \cs_new_protected:Npn \hcoffin_gset:Nw #1
879 {
880 \@@_if_exist:NT #1
881 {
882 \hbox_gset:Nw #1 \color_ensure_current:
883 \cs_set_protected:Npn \hcoffin_gset_end:
884 {
885 \hbox_gset_end:
886 \coffin_greset_poles:N #1
887 }
888 }
889 }
890 \cs_generate_variant:Nn \hcoffin_gset:Nw { c }
891 \cs_new_protected:Npn \hcoffin_set_end: { }
892 \cs_new_protected:Npn \hcoffin_gset_end: { }
893 % \end{macrocode}
894 % \end{macro}
895 % \end{macro}
896 %
897 % \begin{macro}
898 % {\vcoffin_set:Nnw, \vcoffin_set:cnw, \vcoffin_gset:Nnw, \vcoffin_gset:cnw}
899 % \begin{macro}{\@@_set_vertical:NnNNNNNw}
900 % \begin{macro}{\vcoffin_set_end:, \vcoffin_gset_end:}
901 % The same for vertical coffins.
902 % \begin{macrocode}
903 \cs_new_protected:Npn \vcoffin_set:Nnw #1#2
904 {
905 \@@_set_vertical:NnNNNNNw #1 {#2} \vbox_set:Nw
906 \vcoffin_set_end:
907 \vbox_set_end: \coffin_reset_poles:N \@@_set_pole:Nnn
908 }
909 \cs_generate_variant:Nn \vcoffin_set:Nnw { c }
910 \cs_new_protected:Npn \vcoffin_gset:Nnw #1#2
911 {
912 \@@_set_vertical:NnNNNNNw #1 {#2} \vbox_gset:Nw
913 \vcoffin_gset_end:
914 \vbox_gset_end: \coffin_greset_poles:N \@@_gset_pole:Nnn
915 }
916 \cs_generate_variant:Nn \vcoffin_gset:Nnw { c }
917 \cs_new_protected:Npn \@@_set_vertical:NnNNNNNw #1#2#3#4#5#6#7
918 {
919 \@@_if_exist:NT #1
920 {
921 #3 #1
922 \dim_set:Nn \tex_hsize:D {#2}
923 \@@_set_vertical_aux:
924 \cs_set_protected:Npn #4
925 {
926 #5
927 #6 #1
928 \vbox_set_top:Nn \l_@@_tmp_box { \vbox_unpack:N #1 }
929 #7 #1 { T }
930 {
931 { 0pt }
932 {
933 \dim_eval:n
934 { \box_ht:N #1 - \box_ht:N \l_@@_tmp_box }
935 }
936 { 1000pt }
937 { 0pt }
938 }
939 \box_clear:N \l_@@_tmp_box
940 }
941 }
942 }
943 \cs_new_protected:Npn \vcoffin_set_end: { }
944 \cs_new_protected:Npn \vcoffin_gset_end: { }
945 % \end{macrocode}
946 % \end{macro}
947 % \end{macro}
948 % \end{macro}
949 %
950 % \begin{macro}
951 % {
952 % \coffin_set_eq:NN, \coffin_set_eq:Nc,
953 % \coffin_set_eq:cN, \coffin_set_eq:cc,
954 % \coffin_gset_eq:NN, \coffin_gset_eq:Nc,
955 % \coffin_gset_eq:cN, \coffin_gset_eq:cc
956 % }
957 % Setting two coffins equal is just a wrapper around other functions.
958 % \begin{macrocode}
959 \cs_new_protected:Npn \coffin_set_eq:NN #1#2
960 {
961 \@@_if_exist:NT #2
962 {
963 \box_set_eq:NN #1 #2
964 \prop_set_eq:cc { coffin ~ \@@_to_value:N #1 ~ corners }
965 { coffin ~ \@@_to_value:N #2 ~ corners }
966 \prop_set_eq:cc { coffin ~ \@@_to_value:N #1 ~ poles }
967 { coffin ~ \@@_to_value:N #2 ~ poles }
968 }
969 }
970 \cs_generate_variant:Nn \coffin_set_eq:NN { c , Nc , cc }
971 \cs_new_protected:Npn \coffin_gset_eq:NN #1#2
972 {
973 \@@_if_exist:NT #2
974 {
975 \box_gset_eq:NN #1 #2
976 \prop_gset_eq:cc { coffin ~ \@@_to_value:N #1 ~ corners }
977 { coffin ~ \@@_to_value:N #2 ~ corners }
978 \prop_gset_eq:cc { coffin ~ \@@_to_value:N #1 ~ poles }
979 { coffin ~ \@@_to_value:N #2 ~ poles }
980 }
981 }
982 \cs_generate_variant:Nn \coffin_gset_eq:NN { c , Nc , cc }
983 % \end{macrocode}
984 % \end{macro}
985 %
986 % \begin{variable}{\c_empty_coffin}
987 % \begin{variable}{\l_@@_aligned_coffin}
988 % \begin{variable}{\l_@@_aligned_internal_coffin}
989 % Special coffins: these cannot be set up earlier as they need
990 % \cs{coffin_new:N}. The empty coffin is set as a box as the full
991 % coffin-setting system needs some material which is not yet available.
992 % The empty coffin is created entirely by hand: not everything is in place
993 % yet.
994 % \begin{macrocode}
995 \coffin_new:N \c_empty_coffin
996 \coffin_new:N \l_@@_aligned_coffin
997 \coffin_new:N \l_@@_aligned_internal_coffin
998 % \end{macrocode}
999 % \end{variable}
1000 % \end{variable}
1001 % \end{variable}
1002 %
1003 % \begin{variable}
1004 % {\l_tmpa_coffin, \l_tmpb_coffin, \g_tmpa_coffin, \g_tmpb_coffin}
1005 % The usual scratch space.
1006 % \begin{macrocode}
1007 \coffin_new:N \l_tmpa_coffin
1008 \coffin_new:N \l_tmpb_coffin
1009 \coffin_new:N \g_tmpa_coffin
1010 \coffin_new:N \g_tmpb_coffin
1011 % \end{macrocode}
1012 % \end{variable}
1013 %
1014 % \subsection{Measuring coffins}
1015 %
1016 % \begin{macro}
1017 % {
1018 % \coffin_dp:N, \coffin_dp:c, \coffin_ht:N, \coffin_ht:c,
1019 % \coffin_ht_plus_dp:N, \coffin_ht_plus_dp:c,
1020 % \coffin_wd:N, \coffin_wd:c,
1021 % }
1022 % Coffins are just boxes when it comes to measurement. However, semantically
1023 % a separate set of functions are required.
1024 % \begin{macrocode}
1025 \cs_new_eq:NN \coffin_dp:N \box_dp:N
1026 \cs_new_eq:NN \coffin_dp:c \box_dp:c
1027 \cs_new_eq:NN \coffin_ht:N \box_ht:N
1028 \cs_new_eq:NN \coffin_ht:c \box_ht:c
1029 \cs_new_eq:NN \coffin_ht_plus_dp:N \box_ht_plus_dp:N
1030 \cs_new_eq:NN \coffin_ht_plus_dp:c \box_ht_plus_dp:c
1031 \cs_new_eq:NN \coffin_wd:N \box_wd:N
1032 \cs_new_eq:NN \coffin_wd:c \box_wd:c
1033 % \end{macrocode}
1034 % \end{macro}
1035 %
1036 % \subsection{Coffins: handle and pole management}
1037 %
1038 % \begin{macro}[EXP]{\coffin_pole:Nn}
1039 % \begin{macro}[EXP]{\@@_pole:nNn}
1040 % A simple wrapper around the recovery of a coffin pole, with some
1041 % error checking and recovery built-in.
1042 % \begin{macrocode}
1043 \cs_new:Npn \coffin_pole:Nn #1#2
1044 {
1045 \exp_args:Ne \@@_pole:nNn
1046 { \prop_item:cn { coffin ~ \@@_to_value:N #1 ~ poles } {#2} }
1047 #1 {#2}
1048 }
1049 \cs_new:Npn \@@_pole:nNn #1#2#3
1050 {
1051 \tl_if_blank:nTF {#1}
1052 {
1053 \msg_expandable_error:nnee { coffin } { unknown-pole }
1054 { \exp_not:n {#3} } { \token_to_str:N #2 }
1055 { 0pt } { 0pt } { 0pt } { 0pt }
1056 }
1057 {#1}
1058 }
1059 % \end{macrocode}
1060 % \end{macro}
1061 % \end{macro}
1062 %
1063 % \begin{macro}{\@@_reset_structure:N, \@@_greset_structure:N}
1064 % Resetting the structure is a simple copy job.
1065 % \begin{macrocode}
1066 \cs_new_protected:Npn \@@_reset_structure:N #1
1067 {
1068 \prop_set_eq:cN { coffin ~ \@@_to_value:N #1 ~ corners }
1069 \c_@@_corners_prop
1070 \prop_set_eq:cN { coffin ~ \@@_to_value:N #1 ~ poles }
1071 \c_@@_poles_prop
1072 }
1073 \cs_new_protected:Npn \@@_greset_structure:N #1
1074 {
1075 \prop_gset_eq:cN { coffin ~ \@@_to_value:N #1 ~ corners }
1076 \c_@@_corners_prop
1077 \prop_gset_eq:cN { coffin ~ \@@_to_value:N #1 ~ poles }
1078 \c_@@_poles_prop
1079 }
1080 % \end{macrocode}
1081 % \end{macro}
1082 %
1083 % \begin{macro}
1084 % {
1085 % \coffin_set_horizontal_pole:Nnn, \coffin_set_horizontal_pole:cnn,
1086 % \coffin_gset_horizontal_pole:Nnn, \coffin_gset_horizontal_pole:cnn
1087 % }
1088 % \begin{macro}{\@@_set_horizontal_pole:NnnN}
1089 % \begin{macro}
1090 % {
1091 % \coffin_set_vertical_pole:Nnn, \coffin_set_vertical_pole:cnn,
1092 % \coffin_gset_vertical_pole:Nnn, \coffin_gset_vertical_pole:cnn
1093 % }
1094 % \begin{macro}{\@@_set_vertical_pole:NnnN}
1095 % \begin{macro}{\@@_set_pole:Nnn, \@@_gset_pole:Nnn}
1096 % Setting the pole of a coffin at the user/designer level requires a
1097 % bit more care. The idea here is to provide a reasonable interface to
1098 % the system, then to do the setting with full expansion. The
1099 % three-argument version is used internally to do a direct setting.
1100 % \begin{macrocode}
1101 \cs_new_protected:Npn \coffin_set_horizontal_pole:Nnn #1#2#3
1102 { \@@_set_horizontal_pole:NnnN #1 {#2} {#3} \prop_put:cne }
1103 \cs_generate_variant:Nn \coffin_set_horizontal_pole:Nnn { c }
1104 \cs_new_protected:Npn \coffin_gset_horizontal_pole:Nnn #1#2#3
1105 { \@@_set_horizontal_pole:NnnN #1 {#2} {#3} \prop_gput:cne }
1106 \cs_generate_variant:Nn \coffin_gset_horizontal_pole:Nnn { c }
1107 \cs_new_protected:Npn \@@_set_horizontal_pole:NnnN #1#2#3#4
1108 {
1109 \@@_if_exist:NT #1
1110 {
1111 #4 { coffin ~ \@@_to_value:N #1 ~ poles }
1112 {#2}
1113 {
1114 { 0pt } { \dim_eval:n {#3} }
1115 { 1000pt } { 0pt }
1116 }
1117 }
1118 }
1119 \cs_new_protected:Npn \coffin_set_vertical_pole:Nnn #1#2#3
1120 { \@@_set_vertical_pole:NnnN #1 {#2} {#3} \prop_put:cne }
1121 \cs_generate_variant:Nn \coffin_set_vertical_pole:Nnn { c }
1122 \cs_new_protected:Npn \coffin_gset_vertical_pole:Nnn #1#2#3
1123 { \@@_set_vertical_pole:NnnN #1 {#2} {#3} \prop_gput:cne }
1124 \cs_generate_variant:Nn \coffin_gset_vertical_pole:Nnn { c }
1125 \cs_new_protected:Npn \@@_set_vertical_pole:NnnN #1#2#3#4
1126 {
1127 \@@_if_exist:NT #1
1128 {
1129 #4 { coffin ~ \@@_to_value:N #1 ~ poles }
1130 {#2}
1131 {
1132 { \dim_eval:n {#3} } { 0pt }
1133 { 0pt } { 1000pt }
1134 }
1135 }
1136 }
1137 \cs_new_protected:Npn \@@_set_pole:Nnn #1#2#3
1138 {
1139 \prop_put:cne { coffin ~ \@@_to_value:N #1 ~ poles }
1140 {#2} {#3}
1141 }
1142 \cs_new_protected:Npn \@@_gset_pole:Nnn #1#2#3
1143 {
1144 \prop_gput:cne { coffin ~ \@@_to_value:N #1 ~ poles }
1145 {#2} {#3}
1146 }
1147 % \end{macrocode}
1148 % \end{macro}
1149 % \end{macro}
1150 % \end{macro}
1151 % \end{macro}
1152 % \end{macro}
1153 %
1154 % \begin{macro}{\coffin_reset_poles:N, \coffin_greset_poles:N}
1155 % Simple shortcuts.
1156 % \begin{macrocode}
1157 \cs_new_protected:Npn \coffin_reset_poles:N #1
1158 {
1159 \@@_reset_structure:N #1
1160 \@@_update_corners:N #1
1161 \@@_update_poles:N #1
1162 }
1163 \cs_new_protected:Npn \coffin_greset_poles:N #1
1164 {
1165 \@@_greset_structure:N #1
1166 \@@_gupdate_corners:N #1
1167 \@@_gupdate_poles:N #1
1168 }
1169 % \end{macrocode}
1170 % \end{macro}
1171 %
1172 % \begin{macro}{\@@_update_corners:N, \@@_gupdate_corners:N}
1173 % \begin{macro}{\@@_update_corners:NN}
1174 % \begin{macro}{\@@_update_corners:NNN}
1175 % Updating the corners of a coffin is straight-forward as at this stage
1176 % there can be no rotation. So the corners of the content are just those
1177 % of the underlying \TeX{} box.
1178 % \begin{macrocode}
1179 \cs_new_protected:Npn \@@_update_corners:N #1
1180 { \@@_update_corners:NN #1 \prop_put:Nne }
1181 \cs_new_protected:Npn \@@_gupdate_corners:N #1
1182 { \@@_update_corners:NN #1 \prop_gput:Nne }
1183 \cs_new_protected:Npn \@@_update_corners:NN #1#2
1184 {
1185 \exp_args:Nc \@@_update_corners:NNN
1186 { coffin ~ \@@_to_value:N #1 ~ corners }
1187 #1 #2
1188 }
1189 \cs_new_protected:Npn \@@_update_corners:NNN #1#2#3
1190 {
1191 #3 #1
1192 { tl }
1193 { { 0pt } { \dim_eval:n { \box_ht:N #2 } } }
1194 #3 #1
1195 { tr }
1196 {
1197 { \dim_eval:n { \box_wd:N #2 } }
1198 { \dim_eval:n { \box_ht:N #2 } }
1199 }
1200 #3 #1
1201 { bl }
1202 { { 0pt } { \dim_eval:n { -\box_dp:N #2 } } }
1203 #3 #1
1204 { br }
1205 {
1206 { \dim_eval:n { \box_wd:N #2 } }
1207 { \dim_eval:n { -\box_dp:N #2 } }
1208 }
1209 }
1210 % \end{macrocode}
1211 % \end{macro}
1212 % \end{macro}
1213 % \end{macro}
1214 %
1215 % \begin{macro}{\@@_update_poles:N, \@@_gupdate_poles:N}
1216 % \begin{macro}{\@@_update_poles:NN}
1217 % \begin{macro}{\@@_update_poles:NNN}
1218 % This function is called when a coffin is set, and updates the poles to
1219 % reflect the nature of size of the box. Thus this function only alters
1220 % poles where the default position is dependent on the size of the box.
1221 % It also does not set poles which are relevant only to vertical
1222 % coffins.
1223 % \begin{macrocode}
1224 \cs_new_protected:Npn \@@_update_poles:N #1
1225 { \@@_update_poles:NN #1 \prop_put:Nne }
1226 \cs_new_protected:Npn \@@_gupdate_poles:N #1
1227 { \@@_update_poles:NN #1 \prop_gput:Nne }
1228 \cs_new_protected:Npn \@@_update_poles:NN #1#2
1229 {
1230 \exp_args:Nc \@@_update_poles:NNN
1231 { coffin ~ \@@_to_value:N #1 ~ poles }
1232 #1 #2
1233 }
1234 \cs_new_protected:Npn \@@_update_poles:NNN #1#2#3
1235 {
1236 #3 #1 { hc }
1237 {
1238 { \dim_eval:n { 0.5 \box_wd:N #2 } }
1239 { 0pt } { 0pt } { 1000pt }
1240 }
1241 #3 #1 { r }
1242 {
1243 { \dim_eval:n { \box_wd:N #2 } }
1244 { 0pt } { 0pt } { 1000pt }
1245 }
1246 #3 #1 { vc }
1247 {
1248 { 0pt }
1249 { \dim_eval:n { ( \box_ht:N #2 - \box_dp:N #2 ) / 2 } }
1250 { 1000pt }
1251 { 0pt }
1252 }
1253 #3 #1 { t }
1254 {
1255 { 0pt }
1256 { \dim_eval:n { \box_ht:N #2 } }
1257 { 1000pt }
1258 { 0pt }
1259 }
1260 #3 #1 { b }
1261 {
1262 { 0pt }
1263 { \dim_eval:n { -\box_dp:N #2 } }
1264 { 1000pt }
1265 { 0pt }
1266 }
1267 }
1268 % \end{macrocode}
1269 % \end{macro}
1270 % \end{macro}
1271 % \end{macro}
1272 %
1273 % \subsection{Coffins: calculation of pole intersections}
1274 %
1275 % \begin{macro}{\@@_calculate_intersection:Nnn}
1276 % \begin{macro}{\@@_calculate_intersection:nnnnnnnn}
1277 % \begin{macro}{\@@_calculate_intersection:nnnnnn}
1278 % The lead off in finding intersections is to recover the two poles
1279 % and then hand off to the auxiliary for the actual calculation. There
1280 % may of course not be an intersection, for which an error trap is
1281 % needed.
1282 % \begin{macrocode}
1283 \cs_new_protected:Npn \@@_calculate_intersection:Nnn #1#2#3
1284 {
1285 \bool_set_false:N \l_@@_error_bool
1286 \use:e
1287 {
1288 \@@_calculate_intersection:nnnnnnnn
1289 \coffin_pole:Nn #1 {#2}
1290 \coffin_pole:Nn #1 {#3}
1291 }
1292 \bool_if:NT \l_@@_error_bool
1293 {
1294 \msg_error:nn { coffin } { no-pole-intersection }
1295 \dim_zero:N \l_@@_x_dim
1296 \dim_zero:N \l_@@_y_dim
1297 }
1298 }
1299 % \end{macrocode}
1300 % The two poles passed here each have four values (as dimensions),
1301 % ($a$, $b$, $c$, $d$) and
1302 % ($a'$, $b'$, $c'$, $d'$). These are arguments
1303 % $1$--$4$ and $5$--$8$, respectively. In both
1304 % cases $a$ and $b$ are the coordinates of a point on the
1305 % pole and $c$ and $d$ define the direction of the pole. Finding
1306 % the intersection depends on the directions of the poles, which are
1307 % given by $d / c$ and $d' / c'$. However, if one of the poles
1308 % is either horizontal or vertical then one or more of $c$, $d$,
1309 % $c'$ and $d'$ are zero and a special case is needed.
1310 % \begin{macrocode}
1311 \cs_new_protected:Npn \@@_calculate_intersection:nnnnnnnn
1312 #1#2#3#4#5#6#7#8
1313 {
1314 \dim_compare:nNnTF {#3} = \c_zero_dim
1315 % \end{macrocode}
1316 % The case where the first pole is vertical. So the $x$-component
1317 % of the interaction is at $a$. There is then a test on the
1318 % second pole: if it is also vertical then there is an error.
1319 % \begin{macrocode}
1320 {
1321 \dim_set:Nn \l_@@_x_dim {#1}
1322 \dim_compare:nNnTF {#7} = \c_zero_dim
1323 { \bool_set_true:N \l_@@_error_bool }
1324 % \end{macrocode}
1325 % The second pole may still be horizontal, in which case the
1326 % $y$-component of the intersection is $b'$. If not,
1327 % \[
1328 % y = \frac{d'}{c'} \left ( a - a' \right ) + b'
1329 % \]
1330 % with the $x$-component already known to be |#1|.
1331 % \begin{macrocode}
1332 {
1333 \dim_set:Nn \l_@@_y_dim
1334 {
1335 \dim_compare:nNnTF {#8} = \c_zero_dim
1336 {#6}
1337 {
1338 \fp_to_dim:n
1339 {
1340 ( \dim_to_fp:n {#8} / \dim_to_fp:n {#7} )
1341 * ( \dim_to_fp:n {#1} - \dim_to_fp:n {#5} )
1342 + \dim_to_fp:n {#6}
1343 }
1344 }
1345 }
1346 }
1347 }
1348 % \end{macrocode}
1349 % If the first pole is not vertical then it may be horizontal. If so,
1350 % then the procedure is essentially the same as that already done but
1351 % with the $x$- and $y$-components interchanged.
1352 % \begin{macrocode}
1353 {
1354 \dim_compare:nNnTF {#4} = \c_zero_dim
1355 {
1356 \dim_set:Nn \l_@@_y_dim {#2}
1357 \dim_compare:nNnTF {#8} = { \c_zero_dim }
1358 { \bool_set_true:N \l_@@_error_bool }
1359 {
1360 % \end{macrocode}
1361 % Now we deal with the case where the second pole may be vertical, or
1362 % if not we have
1363 % \[
1364 % x = \frac{c'}{d'} \left ( b - b' \right ) + a'
1365 % \]
1366 % which is again handled by the same auxiliary.
1367 % \begin{macrocode}
1368 \dim_set:Nn \l_@@_x_dim
1369 {
1370 \dim_compare:nNnTF {#7} = \c_zero_dim
1371 {#5}
1372 {
1373 \fp_to_dim:n
1374 {
1375 ( \dim_to_fp:n {#7} / \dim_to_fp:n {#8} )
1376 * ( \dim_to_fp:n {#4} - \dim_to_fp:n {#6} )
1377 + \dim_to_fp:n {#5}
1378 }
1379 }
1380 }
1381 }
1382 }
1383 % \end{macrocode}
1384 % The first pole is neither horizontal nor vertical. To avoid even
1385 % more complexity, we now work out both slopes and pass to an auxiliary.
1386 % \begin{macrocode}
1387 {
1388 \use:e
1389 {
1390 \@@_calculate_intersection:nnnnnn
1391 { \dim_to_fp:n {#4} / \dim_to_fp:n {#3} }
1392 { \dim_to_fp:n {#8} / \dim_to_fp:n {#7} }
1393 }
1394 {#1} {#2} {#5} {#6}
1395 }
1396 }
1397 }
1398 % \end{macrocode}
1399 % Assuming the two poles are not parallel, then the intersection point is
1400 % found in two steps. First we find the $x$-value with
1401 % \[
1402 % x = \frac { sa - s'a' - b + b' }{ s - s' }
1403 % \]
1404 % and then finding the $y$-value with
1405 % \[
1406 % y = s ( x - a ) + b
1407 % \]
1408 % \begin{macrocode}
1409 \cs_new_protected:Npn \@@_calculate_intersection:nnnnnn #1#2#3#4#5#6
1410 {
1411 \fp_compare:nNnTF {#1} = {#2}
1412 { \bool_set_true:N \l_@@_error_bool }
1413 {
1414 \dim_set:Nn \l_@@_x_dim
1415 {
1416 \fp_to_dim:n
1417 {
1418 (
1419 #1 * \dim_to_fp:n {#3}
1420 - #2 * \dim_to_fp:n {#5}
1421 - \dim_to_fp:n {#4}
1422 + \dim_to_fp:n {#6}
1423 )
1424 /
1425 ( #1 - #2 )
1426 }
1427 }
1428 \dim_set:Nn \l_@@_y_dim
1429 {
1430 \fp_to_dim:n
1431 {
1432 #1 * ( \l_@@_x_dim - \dim_to_fp:n {#3} )
1433 + \dim_to_fp:n {#4}
1434 }
1435 }
1436 }
1437 }
1438 % \end{macrocode}
1439 % \end{macro}
1440 % \end{macro}
1441 % \end{macro}
1442 %
1443 % \subsection{Affine transformations}
1444 %
1445 % \begin{variable}{\l_@@_sin_fp}
1446 % \begin{variable}{\l_@@_cos_fp}
1447 % Used for rotations to get the sine and cosine values.
1448 % \begin{macrocode}
1449 \fp_new:N \l_@@_sin_fp
1450 \fp_new:N \l_@@_cos_fp
1451 % \end{macrocode}
1452 % \end{variable}
1453 % \end{variable}
1454 %
1455 % \begin{variable}{\l_@@_bounding_prop}
1456 % A property list for the bounding box of a coffin. This is only needed
1457 % during the rotation, so there is just the one.
1458 % \begin{macrocode}
1459 \prop_new:N \l_@@_bounding_prop
1460 % \end{macrocode}
1461 % \end{variable}
1462 %
1463 % \begin{variable}{\l_@@_corners_prop, \l_@@_poles_prop}
1464 % Used to avoid needing to track scope for intermediate steps.
1465 % \begin{macrocode}
1466 \prop_new:N \l_@@_corners_prop
1467 \prop_new:N \l_@@_poles_prop
1468 % \end{macrocode}
1469 % \end{variable}
1470 %
1471 % \begin{variable}{\l_@@_bounding_shift_dim}
1472 % The shift of the bounding box of a coffin from the real content.
1473 % \begin{macrocode}
1474 \dim_new:N \l_@@_bounding_shift_dim
1475 % \end{macrocode}
1476 % \end{variable}
1477 %
1478 % \begin{variable}{\l_@@_left_corner_dim}
1479 % \begin{variable}{\l_@@_right_corner_dim}
1480 % \begin{variable}{\l_@@_bottom_corner_dim}
1481 % \begin{variable}{\l_@@_top_corner_dim}
1482 % These are used to hold maxima for the various corner values: these
1483 % thus define the minimum size of the bounding box after rotation.
1484 % \begin{macrocode}
1485 \dim_new:N \l_@@_left_corner_dim
1486 \dim_new:N \l_@@_right_corner_dim
1487 \dim_new:N \l_@@_bottom_corner_dim
1488 \dim_new:N \l_@@_top_corner_dim
1489 % \end{macrocode}
1490 % \end{variable}
1491 % \end{variable}
1492 % \end{variable}
1493 % \end{variable}
1494 %
1495 % \begin{macro}
1496 % {
1497 % \coffin_rotate:Nn, \coffin_rotate:cn,
1498 % \coffin_grotate:Nn, \coffin_grotate:cn
1499 % }
1500 % \begin{macro}{\@@_rotate:NnNNN}
1501 % Rotating a coffin requires several steps which can be conveniently
1502 % run together. The sine and cosine of the angle in degrees are
1503 % computed. This is then used to set \cs{l_@@_sin_fp} and
1504 % \cs{l_@@_cos_fp}, which are carried through unchanged for the rest
1505 % of the procedure.
1506 % \begin{macrocode}
1507 \cs_new_protected:Npn \coffin_rotate:Nn #1#2
1508 { \@@_rotate:NnNNN #1 {#2} \box_rotate:Nn \prop_set_eq:cN \hbox_set:Nn }
1509 \cs_generate_variant:Nn \coffin_rotate:Nn { c }
1510 \cs_new_protected:Npn \coffin_grotate:Nn #1#2
1511 { \@@_rotate:NnNNN #1 {#2} \box_grotate:Nn \prop_gset_eq:cN \hbox_gset:Nn }
1512 \cs_generate_variant:Nn \coffin_grotate:Nn { c }
1513 \cs_new_protected:Npn \@@_rotate:NnNNN #1#2#3#4#5
1514 {
1515 \fp_set:Nn \l_@@_sin_fp { sind ( #2 ) }
1516 \fp_set:Nn \l_@@_cos_fp { cosd ( #2 ) }
1517 % \end{macrocode}
1518 % Use a local copy of the property lists to avoid needing to pass the
1519 % name and scope around.
1520 % \begin{macrocode}
1521 \prop_set_eq:Nc \l_@@_corners_prop
1522 { coffin ~ \@@_to_value:N #1 ~ corners }
1523 \prop_set_eq:Nc \l_@@_poles_prop
1524 { coffin ~ \@@_to_value:N #1 ~ poles }
1525 % \end{macrocode}
1526 % The corners and poles of the coffin can now be rotated around the
1527 % origin. This is best achieved using mapping functions.
1528 % \begin{macrocode}
1529 \prop_map_inline:Nn \l_@@_corners_prop
1530 { \@@_rotate_corner:Nnnn #1 {##1} ##2 }
1531 \prop_map_inline:Nn \l_@@_poles_prop
1532 { \@@_rotate_pole:Nnnnnn #1 {##1} ##2 }
1533 % \end{macrocode}
1534 % The bounding box of the coffin needs to be rotated, and to do this
1535 % the corners have to be found first. They are then rotated in the same
1536 % way as the corners of the coffin material itself.
1537 % \begin{macrocode}
1538 \@@_set_bounding:N #1
1539 \prop_map_inline:Nn \l_@@_bounding_prop
1540 { \@@_rotate_bounding:nnn {##1} ##2 }
1541 % \end{macrocode}
1542 % At this stage, there needs to be a calculation to find where the
1543 % corners of the content and the box itself will end up.
1544 % \begin{macrocode}
1545 \@@_find_corner_maxima:N #1
1546 \@@_find_bounding_shift:
1547 #3 #1 {#2}
1548 % \end{macrocode}
1549 % The correction of the box position itself takes place here. The idea
1550 % is that the bounding box for a coffin is tight up to the content, and
1551 % has the reference point at the bottom-left. The $x$-direction is
1552 % handled by moving the content by the difference in the positions of
1553 % the bounding box and the content left edge. The $y$-direction is
1554 % dealt with by moving the box down by any depth it has acquired. The
1555 % internal box is used here to allow for the next step.
1556 % \begin{macrocode}
1557 \hbox_set:Nn \l_@@_tmp_box
1558 {
1559 \dim_horizontal:n
1560 { \l_@@_bounding_shift_dim - \l_@@_left_corner_dim }
1561 \box_move_down:nn { \l_@@_bottom_corner_dim }
1562 { \box_use:N #1 }
1563 }
1564 % \end{macrocode}
1565 % If there have been any previous rotations then the size of the
1566 % bounding box will be bigger than the contents. This can be corrected
1567 % easily by setting the size of the box to the height and width of the
1568 % content. As this operation requires setting box dimensions and these
1569 % transcend grouping, the safe way to do this is to use the internal box
1570 % and to reset the result into the target box.
1571 % \begin{macrocode}
1572 \box_set_ht:Nn \l_@@_tmp_box
1573 { \l_@@_top_corner_dim - \l_@@_bottom_corner_dim }
1574 \box_set_dp:Nn \l_@@_tmp_box { 0pt }
1575 \box_set_wd:Nn \l_@@_tmp_box
1576 { \l_@@_right_corner_dim - \l_@@_left_corner_dim }
1577 #5 #1 { \box_use_drop:N \l_@@_tmp_box }
1578 % \end{macrocode}
1579 % The final task is to move the poles and corners such that they are
1580 % back in alignment with the box reference point.
1581 % \begin{macrocode}
1582 \prop_map_inline:Nn \l_@@_corners_prop
1583 { \@@_shift_corner:Nnnn #1 {##1} ##2 }
1584 \prop_map_inline:Nn \l_@@_poles_prop
1585 { \@@_shift_pole:Nnnnnn #1 {##1} ##2 }
1586 % \end{macrocode}
1587 % Update the coffin data.
1588 % \begin{macrocode}
1589 #4 { coffin ~ \@@_to_value:N #1 ~ corners }
1590 \l_@@_corners_prop
1591 #4 { coffin ~ \@@_to_value:N #1 ~ poles }
1592 \l_@@_poles_prop
1593 }
1594 % \end{macrocode}
1595 % \end{macro}
1596 % \end{macro}
1597 %
1598 % \begin{macro}{\@@_set_bounding:N}
1599 % The bounding box corners for a coffin are easy enough to find: this
1600 % is the same code as for the corners of the material itself, but
1601 % using a dedicated property list.
1602 % \begin{macrocode}
1603 \cs_new_protected:Npn \@@_set_bounding:N #1
1604 {
1605 \prop_put:Nne \l_@@_bounding_prop { tl }
1606 { { 0pt } { \dim_eval:n { \box_ht:N #1 } } }
1607 \prop_put:Nne \l_@@_bounding_prop { tr }
1608 {
1609 { \dim_eval:n { \box_wd:N #1 } }
1610 { \dim_eval:n { \box_ht:N #1 } }
1611 }
1612 \dim_set:Nn \l_@@_tmp_dim { -\box_dp:N #1 }
1613 \prop_put:Nne \l_@@_bounding_prop { bl }
1614 { { 0pt } { \dim_use:N \l_@@_tmp_dim } }
1615 \prop_put:Nne \l_@@_bounding_prop { br }
1616 {
1617 { \dim_eval:n { \box_wd:N #1 } }
1618 { \dim_use:N \l_@@_tmp_dim }
1619 }
1620 }
1621 % \end{macrocode}
1622 % \end{macro}
1623 %
1624 % \begin{macro}{\@@_rotate_bounding:nnn}
1625 % \begin{macro}{\@@_rotate_corner:Nnnn}
1626 % Rotating the position of the corner of the coffin is just a case
1627 % of treating this as a vector from the reference point. The same
1628 % treatment is used for the corners of the material itself and the
1629 % bounding box.
1630 % \begin{macrocode}
1631 \cs_new_protected:Npn \@@_rotate_bounding:nnn #1#2#3
1632 {
1633 \@@_rotate_vector:nnNN {#2} {#3} \l_@@_x_dim \l_@@_y_dim
1634 \prop_put:Nne \l_@@_bounding_prop {#1}
1635 { { \dim_use:N \l_@@_x_dim } { \dim_use:N \l_@@_y_dim } }
1636 }
1637 \cs_new_protected:Npn \@@_rotate_corner:Nnnn #1#2#3#4
1638 {
1639 \@@_rotate_vector:nnNN {#3} {#4} \l_@@_x_dim \l_@@_y_dim
1640 \prop_put:Nne \l_@@_corners_prop {#2}
1641 { { \dim_use:N \l_@@_x_dim } { \dim_use:N \l_@@_y_dim } }
1642 }
1643 % \end{macrocode}
1644 % \end{macro}
1645 % \end{macro}
1646 %
1647 % \begin{macro}{\@@_rotate_pole:Nnnnnn}
1648 % Rotating a single pole simply means shifting the coordinate of
1649 % the pole and its direction. The rotation here is about the bottom-left
1650 % corner of the coffin.
1651 % \begin{macrocode}
1652 \cs_new_protected:Npn \@@_rotate_pole:Nnnnnn #1#2#3#4#5#6
1653 {
1654 \@@_rotate_vector:nnNN {#3} {#4} \l_@@_x_dim \l_@@_y_dim
1655 \@@_rotate_vector:nnNN {#5} {#6}
1656 \l_@@_x_prime_dim \l_@@_y_prime_dim
1657 \prop_put:Nne \l_@@_poles_prop {#2}
1658 {
1659 { \dim_use:N \l_@@_x_dim } { \dim_use:N \l_@@_y_dim }
1660 { \dim_use:N \l_@@_x_prime_dim }
1661 { \dim_use:N \l_@@_y_prime_dim }
1662 }
1663 }
1664 % \end{macrocode}
1665 % \end{macro}
1666 %
1667 % \begin{macro}{\@@_rotate_vector:nnNN}
1668 % A rotation function, which needs only an input vector (as dimensions)
1669 % and an output space. The values \cs{l_@@_cos_fp} and
1670 % \cs{l_@@_sin_fp} should previously have been set up correctly.
1671 % Working this way means that the floating point work is kept to a
1672 % minimum: for any given rotation the sin and cosine values do no
1673 % change, after all.
1674 % \begin{macrocode}
1675 \cs_new_protected:Npn \@@_rotate_vector:nnNN #1#2#3#4
1676 {
1677 \dim_set:Nn #3
1678 {
1679 \fp_to_dim:n
1680 {
1681 \dim_to_fp:n {#1} * \l_@@_cos_fp
1682 - \dim_to_fp:n {#2} * \l_@@_sin_fp
1683 }
1684 }
1685 \dim_set:Nn #4
1686 {
1687 \fp_to_dim:n
1688 {
1689 \dim_to_fp:n {#1} * \l_@@_sin_fp
1690 + \dim_to_fp:n {#2} * \l_@@_cos_fp
1691 }
1692 }
1693 }
1694 % \end{macrocode}
1695 % \end{macro}
1696 %
1697 % \begin{macro}{\@@_find_corner_maxima:N}
1698 % \begin{macro}{\@@_find_corner_maxima_aux:nn}
1699 % The idea here is to find the extremities of the content of the
1700 % coffin. This is done by looking for the smallest values for the bottom
1701 % and left corners, and the largest values for the top and right
1702 % corners. The values start at the maximum dimensions so that the
1703 % case where all are positive or all are negative works out correctly.
1704 % \begin{macrocode}
1705 \cs_new_protected:Npn \@@_find_corner_maxima:N #1
1706 {
1707 \dim_set:Nn \l_@@_top_corner_dim { -\c_max_dim }
1708 \dim_set:Nn \l_@@_right_corner_dim { -\c_max_dim }
1709 \dim_set:Nn \l_@@_bottom_corner_dim { \c_max_dim }
1710 \dim_set:Nn \l_@@_left_corner_dim { \c_max_dim }
1711 \prop_map_inline:Nn \l_@@_corners_prop
1712 { \@@_find_corner_maxima_aux:nn ##2 }
1713 }
1714 \cs_new_protected:Npn \@@_find_corner_maxima_aux:nn #1#2
1715 {
1716 \dim_set:Nn \l_@@_left_corner_dim
1717 { \dim_min:nn { \l_@@_left_corner_dim } {#1} }
1718 \dim_set:Nn \l_@@_right_corner_dim
1719 { \dim_max:nn { \l_@@_right_corner_dim } {#1} }
1720 \dim_set:Nn \l_@@_bottom_corner_dim
1721 { \dim_min:nn { \l_@@_bottom_corner_dim } {#2} }
1722 \dim_set:Nn \l_@@_top_corner_dim
1723 { \dim_max:nn { \l_@@_top_corner_dim } {#2} }
1724 }
1725 % \end{macrocode}
1726 % \end{macro}
1727 % \end{macro}
1728 %
1729 % \begin{macro}{\@@_find_bounding_shift:}
1730 % \begin{macro}{\@@_find_bounding_shift_aux:nn}
1731 % The approach to finding the shift for the bounding box is similar to
1732 % that for the corners. However, there is only one value needed here and
1733 % a fixed input property list, so things are a bit clearer.
1734 % \begin{macrocode}
1735 \cs_new_protected:Npn \@@_find_bounding_shift:
1736 {
1737 \dim_set:Nn \l_@@_bounding_shift_dim { \c_max_dim }
1738 \prop_map_inline:Nn \l_@@_bounding_prop
1739 { \@@_find_bounding_shift_aux:nn ##2 }
1740 }
1741 \cs_new_protected:Npn \@@_find_bounding_shift_aux:nn #1#2
1742 {
1743 \dim_set:Nn \l_@@_bounding_shift_dim
1744 { \dim_min:nn { \l_@@_bounding_shift_dim } {#1} }
1745 }
1746 % \end{macrocode}
1747 % \end{macro}
1748 % \end{macro}
1749 %
1750 % \begin{macro}{\@@_shift_corner:Nnnn}
1751 % \begin{macro}{\@@_shift_pole:Nnnnnn}
1752 % Shifting the corners and poles of a coffin means subtracting the
1753 % appropriate values from the $x$- and $y$-components. For
1754 % the poles, this means that the direction vector is unchanged.
1755 % \begin{macrocode}
1756 \cs_new_protected:Npn \@@_shift_corner:Nnnn #1#2#3#4
1757 {
1758 \prop_put:Nne \l_@@_corners_prop {#2}
1759 {
1760 { \dim_eval:n { #3 - \l_@@_left_corner_dim } }
1761 { \dim_eval:n { #4 - \l_@@_bottom_corner_dim } }
1762 }
1763 }
1764 \cs_new_protected:Npn \@@_shift_pole:Nnnnnn #1#2#3#4#5#6
1765 {
1766 \prop_put:Nne \l_@@_poles_prop {#2}
1767 {
1768 { \dim_eval:n { #3 - \l_@@_left_corner_dim } }
1769 { \dim_eval:n { #4 - \l_@@_bottom_corner_dim } }
1770 {#5} {#6}
1771 }
1772 }
1773 % \end{macrocode}
1774 % \end{macro}
1775 % \end{macro}
1776 %
1777 % \begin{variable}{\l_@@_scale_x_fp}
1778 % \begin{variable}{\l_@@_scale_y_fp}
1779 % Storage for the scaling factors in $x$ and $y$, respectively.
1780 % \begin{macrocode}
1781 \fp_new:N \l_@@_scale_x_fp
1782 \fp_new:N \l_@@_scale_y_fp
1783 % \end{macrocode}
1784 % \end{variable}
1785 % \end{variable}
1786 %
1787 % \begin{variable}{\l_@@_scaled_total_height_dim}
1788 % \begin{variable}{\l_@@_scaled_width_dim}
1789 % When scaling, the values given have to be turned into absolute values.
1790 % \begin{macrocode}
1791 \dim_new:N \l_@@_scaled_total_height_dim
1792 \dim_new:N \l_@@_scaled_width_dim
1793 % \end{macrocode}
1794 % \end{variable}
1795 % \end{variable}
1796 %
1797 % \begin{macro}
1798 % {
1799 % \coffin_resize:Nnn, \coffin_resize:cnn,
1800 % \coffin_gresize:Nnn, \coffin_gresize:cnn
1801 % }
1802 % \begin{macro}{\@@_resize:NnnNN}
1803 % Resizing a coffin begins by setting up the user-friendly names for
1804 % the dimensions of the coffin box. The new sizes are then turned into
1805 % scale factor. This is the same operation as takes place for the
1806 % underlying box, but that operation is grouped and so the same
1807 % calculation is done here.
1808 % \begin{macrocode}
1809 \cs_new_protected:Npn \coffin_resize:Nnn #1#2#3
1810 {
1811 \@@_resize:NnnNN #1 {#2} {#3}
1812 \box_resize_to_wd_and_ht_plus_dp:Nnn
1813 \prop_set_eq:cN
1814 }
1815 \cs_generate_variant:Nn \coffin_resize:Nnn { c }
1816 \cs_new_protected:Npn \coffin_gresize:Nnn #1#2#3
1817 {
1818 \@@_resize:NnnNN #1 {#2} {#3}
1819 \box_gresize_to_wd_and_ht_plus_dp:Nnn
1820 \prop_gset_eq:cN
1821 }
1822 \cs_generate_variant:Nn \coffin_gresize:Nnn { c }
1823 \cs_new_protected:Npn \@@_resize:NnnNN #1#2#3#4#5
1824 {
1825 \fp_set:Nn \l_@@_scale_x_fp
1826 { \dim_to_fp:n {#2} / \dim_to_fp:n { \coffin_wd:N #1 } }
1827 \fp_set:Nn \l_@@_scale_y_fp
1828 {
1829 \dim_to_fp:n {#3}
1830 / \dim_to_fp:n { \coffin_ht:N #1 + \coffin_dp:N #1 }
1831 }
1832 #4 #1 {#2} {#3}
1833 \@@_resize_common:NnnN #1 {#2} {#3} #5
1834 }
1835 % \end{macrocode}
1836 % \end{macro}
1837 % \end{macro}
1838 %
1839 % \begin{macro}{\@@_resize_common:NnnN}
1840 % The poles and corners of the coffin are scaled to the appropriate
1841 % places before actually resizing the underlying box.
1842 % \begin{macrocode}
1843 \cs_new_protected:Npn \@@_resize_common:NnnN #1#2#3#4
1844 {
1845 \prop_set_eq:Nc \l_@@_corners_prop
1846 { coffin ~ \@@_to_value:N #1 ~ corners }
1847 \prop_set_eq:Nc \l_@@_poles_prop
1848 { coffin ~ \@@_to_value:N #1 ~ poles }
1849 \prop_map_inline:Nn \l_@@_corners_prop
1850 { \@@_scale_corner:Nnnn #1 {##1} ##2 }
1851 \prop_map_inline:Nn \l_@@_poles_prop
1852 { \@@_scale_pole:Nnnnnn #1 {##1} ##2 }
1853 % \end{macrocode}
1854 % Negative $x$-scaling values place the poles in the wrong
1855 % location: this is corrected here.
1856 % \begin{macrocode}
1857 \fp_compare:nNnT \l_@@_scale_x_fp < \c_zero_fp
1858 {
1859 \prop_map_inline:Nn \l_@@_corners_prop
1860 { \@@_x_shift_corner:Nnnn #1 {##1} ##2 }
1861 \prop_map_inline:Nn \l_@@_poles_prop
1862 { \@@_x_shift_pole:Nnnnnn #1 {##1} ##2 }
1863 }
1864 #4 { coffin ~ \@@_to_value:N #1 ~ corners }
1865 \l_@@_corners_prop
1866 #4 { coffin ~ \@@_to_value:N #1 ~ poles }
1867 \l_@@_poles_prop
1868 }
1869 % \end{macrocode}
1870 % \end{macro}
1871 %
1872 % \begin{macro}
1873 % {
1874 % \coffin_scale:Nnn, \coffin_scale:cnn,
1875 % \coffin_gscale:Nnn, \coffin_gscale:cnn
1876 % }
1877 % \begin{macro}{\@@_scale:NnnNN}
1878 % For scaling, the opposite calculation is done to find the new
1879 % dimensions for the coffin. Only the total height is needed, as this
1880 % is the shift required for corners and poles. The scaling is done
1881 % the \TeX{} way as this works properly with floating point values
1882 % without needing to use the \texttt{fp} module.
1883 % \begin{macrocode}
1884 \cs_new_protected:Npn \coffin_scale:Nnn #1#2#3
1885 { \@@_scale:NnnNN #1 {#2} {#3} \box_scale:Nnn \prop_set_eq:cN }
1886 \cs_generate_variant:Nn \coffin_scale:Nnn { c }
1887 \cs_new_protected:Npn \coffin_gscale:Nnn #1#2#3
1888 { \@@_scale:NnnNN #1 {#2} {#3} \box_gscale:Nnn \prop_gset_eq:cN }
1889 \cs_generate_variant:Nn \coffin_gscale:Nnn { c }
1890 \cs_new_protected:Npn \@@_scale:NnnNN #1#2#3#4#5
1891 {
1892 \fp_set:Nn \l_@@_scale_x_fp {#2}
1893 \fp_set:Nn \l_@@_scale_y_fp {#3}
1894 #4 #1 { \l_@@_scale_x_fp } { \l_@@_scale_y_fp }
1895 \dim_set:Nn \l_@@_tmp_dim
1896 { \coffin_ht:N #1 + \coffin_dp:N #1 }
1897 \dim_set:Nn \l_@@_scaled_total_height_dim
1898 { \fp_abs:n { \l_@@_scale_y_fp } \l_@@_tmp_dim }
1899 \dim_set:Nn \l_@@_scaled_width_dim
1900 { -\fp_abs:n { \l_@@_scale_x_fp } \coffin_wd:N #1 }
1901 \@@_resize_common:NnnN #1
1902 { \l_@@_scaled_width_dim } { \l_@@_scaled_total_height_dim }
1903 #5
1904 }
1905 % \end{macrocode}
1906 % \end{macro}
1907 % \end{macro}
1908 %
1909 % \begin{macro}{\@@_scale_vector:nnNN}
1910 % This functions scales a vector from the origin using the pre-set scale
1911 % factors in $x$ and $y$. This is a much less complex operation
1912 % than rotation, and as a result the code is a lot clearer.
1913 % \begin{macrocode}
1914 \cs_new_protected:Npn \@@_scale_vector:nnNN #1#2#3#4
1915 {
1916 \dim_set:Nn #3
1917 { \fp_to_dim:n { \dim_to_fp:n {#1} * \l_@@_scale_x_fp } }
1918 \dim_set:Nn #4
1919 { \fp_to_dim:n { \dim_to_fp:n {#2} * \l_@@_scale_y_fp } }
1920 }
1921 % \end{macrocode}
1922 % \end{macro}
1923 %
1924 % \begin{macro}{\@@_scale_corner:Nnnn}
1925 % \begin{macro}{\@@_scale_pole:Nnnnnn}
1926 % Scaling both corners and poles is a simple calculation using the
1927 % preceding vector scaling.
1928 % \begin{macrocode}
1929 \cs_new_protected:Npn \@@_scale_corner:Nnnn #1#2#3#4
1930 {
1931 \@@_scale_vector:nnNN {#3} {#4} \l_@@_x_dim \l_@@_y_dim
1932 \prop_put:Nne \l_@@_corners_prop {#2}
1933 { { \dim_use:N \l_@@_x_dim } { \dim_use:N \l_@@_y_dim } }
1934 }
1935 \cs_new_protected:Npn \@@_scale_pole:Nnnnnn #1#2#3#4#5#6
1936 {
1937 \@@_scale_vector:nnNN {#3} {#4} \l_@@_x_dim \l_@@_y_dim
1938 \prop_put:Nne \l_@@_poles_prop {#2}
1939 {
1940 { \dim_use:N \l_@@_x_dim } { \dim_use:N \l_@@_y_dim }
1941 {#5} {#6}
1942 }
1943 }
1944 % \end{macrocode}
1945 % \end{macro}
1946 % \end{macro}
1947 %
1948 % \begin{macro}{\@@_x_shift_corner:Nnnn}
1949 % \begin{macro}{\@@_x_shift_pole:Nnnnnn}
1950 % These functions correct for the $x$ displacement that takes
1951 % place with a negative horizontal scaling.
1952 % \begin{macrocode}
1953 \cs_new_protected:Npn \@@_x_shift_corner:Nnnn #1#2#3#4
1954 {
1955 \prop_put:Nne \l_@@_corners_prop {#2}
1956 {
1957 { \dim_eval:n { #3 + \box_wd:N #1 } } {#4}
1958 }
1959 }
1960 \cs_new_protected:Npn \@@_x_shift_pole:Nnnnnn #1#2#3#4#5#6
1961 {
1962 \prop_put:Nne \l_@@_poles_prop {#2}
1963 {
1964 { \dim_eval:n { #3 + \box_wd:N #1 } } {#4}
1965 {#5} {#6}
1966 }
1967 }
1968 % \end{macrocode}
1969 % \end{macro}
1970 % \end{macro}
1971 %
1972 % \subsection{Aligning and typesetting of coffins}
1973 %
1974 % \begin{macro}
1975 % {
1976 % \coffin_join:NnnNnnnn, \coffin_join:cnnNnnnn,
1977 % \coffin_join:Nnncnnnn, \coffin_join:cnncnnnn,
1978 % \coffin_gjoin:NnnNnnnn, \coffin_gjoin:cnnNnnnn,
1979 % \coffin_gjoin:Nnncnnnn, \coffin_gjoin:cnncnnnn
1980 % }
1981 % \begin{macro}{\@@_join:NnnNnnnnN}
1982 % This command joins two coffins, using a horizontal and vertical pole
1983 % from each coffin and making an offset between the two. The result
1984 % is stored as the as a third coffin, which has all of its handles
1985 % reset to standard values. First, the more basic alignment function is
1986 % used to get things started.
1987 % \begin{macrocode}
1988 \cs_new_protected:Npn \coffin_join:NnnNnnnn #1#2#3#4#5#6#7#8
1989 {
1990 \@@_join:NnnNnnnnN #1 {#2} {#3} #4 {#5} {#6} {#7} {#8}
1991 \coffin_set_eq:NN
1992 }
1993 \cs_generate_variant:Nn \coffin_join:NnnNnnnn { c , Nnnc , cnnc }
1994 \cs_new_protected:Npn \coffin_gjoin:NnnNnnnn #1#2#3#4#5#6#7#8
1995 {
1996 \@@_join:NnnNnnnnN #1 {#2} {#3} #4 {#5} {#6} {#7} {#8}
1997 \coffin_gset_eq:NN
1998 }
1999 \cs_generate_variant:Nn \coffin_gjoin:NnnNnnnn { c , Nnnc , cnnc }
2000 \cs_new_protected:Npn \@@_join:NnnNnnnnN #1#2#3#4#5#6#7#8#9
2001 {
2002 \@@_align:NnnNnnnnN
2003 #1 {#2} {#3} #4 {#5} {#6} {#7} {#8} \l_@@_aligned_coffin
2004 % \end{macrocode}
2005 % Correct the placement of the reference point. If the $x$-offset
2006 % is negative then the reference point of the second box is to the left
2007 % of that of the first, which is corrected using a kern. On the right
2008 % side the first box might stick out, which would show up if it is wider
2009 % than the sum of the $x$-offset and the width of the second box.
2010 % So a second kern may be needed.
2011 % \begin{macrocode}
2012 \hbox_set:Nn \l_@@_aligned_coffin
2013 {
2014 \dim_compare:nNnT { \l_@@_offset_x_dim } < \c_zero_dim
2015 { \dim_horizontal:n { -\l_@@_offset_x_dim } }
2016 \hbox_unpack:N \l_@@_aligned_coffin
2017 \dim_set:Nn \l_@@_tmp_dim
2018 { \l_@@_offset_x_dim - \box_wd:N #1 + \box_wd:N #4 }
2019 \dim_compare:nNnT \l_@@_tmp_dim < \c_zero_dim
2020 { \dim_horizontal:n { -\l_@@_tmp_dim } }
2021 }
2022 % \end{macrocode}
2023 % The coffin structure is reset, and the corners are cleared: only
2024 % those from the two parent coffins are needed.
2025 % \begin{macrocode}
2026 \@@_reset_structure:N \l_@@_aligned_coffin
2027 \prop_clear:c
2028 {
2029 coffin ~ \@@_to_value:N \l_@@_aligned_coffin
2030 \c_space_tl corners
2031 }
2032 \@@_update_poles:N \l_@@_aligned_coffin
2033 % \end{macrocode}
2034 % The structures of the parent coffins are now transferred to the new
2035 % coffin, which requires that the appropriate offsets are applied. That
2036 % then depends on whether any shift was needed.
2037 % \begin{macrocode}
2038 \dim_compare:nNnTF \l_@@_offset_x_dim < \c_zero_dim
2039 {
2040 \@@_offset_poles:Nnn #1 { -\l_@@_offset_x_dim } { 0pt }
2041 \@@_offset_poles:Nnn #4 { 0pt } { \l_@@_offset_y_dim }
2042 \@@_offset_corners:Nnn #1 { -\l_@@_offset_x_dim } { 0pt }
2043 \@@_offset_corners:Nnn #4 { 0pt } { \l_@@_offset_y_dim }
2044 }
2045 {
2046 \@@_offset_poles:Nnn #1 { 0pt } { 0pt }
2047 \@@_offset_poles:Nnn #4
2048 { \l_@@_offset_x_dim } { \l_@@_offset_y_dim }
2049 \@@_offset_corners:Nnn #1 { 0pt } { 0pt }
2050 \@@_offset_corners:Nnn #4
2051 { \l_@@_offset_x_dim } { \l_@@_offset_y_dim }
2052 }
2053 \@@_update_TB_poles:NNnN #1 #4 { \l_@@_offset_y_dim } \l_@@_aligned_coffin
2054 #9 #1 \l_@@_aligned_coffin
2055 }
2056 % \end{macrocode}
2057 % \end{macro}
2058 % \end{macro}
2059 %
2060 % \begin{macro}
2061 % {
2062 % \coffin_attach:NnnNnnnn, \coffin_attach:cnnNnnnn,
2063 % \coffin_attach:Nnncnnnn, \coffin_attach:cnncnnnn,
2064 % \coffin_gattach:NnnNnnnn, \coffin_gattach:cnnNnnnn,
2065 % \coffin_gattach:Nnncnnnn, \coffin_gattach:cnncnnnn
2066 % }
2067 % \begin{macro}{\@@_attach:NnnNnnnnN}
2068 % \begin{macro}{\@@_attach_mark:NnnNnnnn}
2069 % A more simple version of the above, as it simply uses the size of the
2070 % first coffin for the new one. This means that the work here is rather
2071 % simplified compared to the above code. The function used when marking
2072 % a position is hear also as it is similar but without the structure
2073 % updates.
2074 % \begin{macrocode}
2075 \cs_new_protected:Npn \coffin_attach:NnnNnnnn #1#2#3#4#5#6#7#8
2076 {
2077 \@@_attach:NnnNnnnnN #1 {#2} {#3} #4 {#5} {#6} {#7} {#8}
2078 \coffin_set_eq:NN
2079 }
2080 \cs_generate_variant:Nn \coffin_attach:NnnNnnnn { c , Nnnc , cnnc }
2081 \cs_new_protected:Npn \coffin_gattach:NnnNnnnn #1#2#3#4#5#6#7#8
2082 {
2083 \@@_attach:NnnNnnnnN #1 {#2} {#3} #4 {#5} {#6} {#7} {#8}
2084 \coffin_gset_eq:NN
2085 }
2086 \cs_generate_variant:Nn \coffin_gattach:NnnNnnnn { c , Nnnc , cnnc }
2087 \cs_new_protected:Npn \@@_attach:NnnNnnnnN #1#2#3#4#5#6#7#8#9
2088 {
2089 \@@_align:NnnNnnnnN
2090 #1 {#2} {#3} #4 {#5} {#6} {#7} {#8} \l_@@_aligned_coffin
2091 \box_set_ht:Nn \l_@@_aligned_coffin { \box_ht:N #1 }
2092 \box_set_dp:Nn \l_@@_aligned_coffin { \box_dp:N #1 }
2093 \box_set_wd:Nn \l_@@_aligned_coffin { \box_wd:N #1 }
2094 \@@_reset_structure:N \l_@@_aligned_coffin
2095 \prop_set_eq:cc
2096 {
2097 coffin ~ \@@_to_value:N \l_@@_aligned_coffin
2098 \c_space_tl corners
2099 }
2100 { coffin ~ \@@_to_value:N #1 ~ corners }
2101 \@@_update_poles:N \l_@@_aligned_coffin
2102 \@@_offset_poles:Nnn #1 { 0pt } { 0pt }
2103 \@@_offset_poles:Nnn #4
2104 { \l_@@_offset_x_dim } { \l_@@_offset_y_dim }
2105 \@@_update_TB_poles:NNnN #1 #4 { \l_@@_offset_y_dim } \l_@@_aligned_coffin
2106 #9 #1 \l_@@_aligned_coffin
2107 }
2108 \cs_new_protected:Npn \@@_attach_mark:NnnNnnnn #1#2#3#4#5#6#7#8
2109 {
2110 \@@_align:NnnNnnnnN
2111 #1 {#2} {#3} #4 {#5} {#6} {#7} {#8} \l_@@_aligned_coffin
2112 \box_set_ht:Nn \l_@@_aligned_coffin { \box_ht:N #1 }
2113 \box_set_dp:Nn \l_@@_aligned_coffin { \box_dp:N #1 }
2114 \box_set_wd:Nn \l_@@_aligned_coffin { \box_wd:N #1 }
2115 \box_set_eq:NN #1 \l_@@_aligned_coffin
2116 }
2117 % \end{macrocode}
2118 % \end{macro}
2119 % \end{macro}
2120 % \end{macro}
2121 %
2122 % \begin{macro}{\@@_align:NnnNnnnnN}
2123 % The internal function aligns the two coffins into a third one, but
2124 % performs no corrections on the resulting coffin poles. The process
2125 % begins by finding the points of intersection for the poles for each
2126 % of the input coffins. Those for the first coffin are worked out after
2127 % those for the second coffin, as this allows the `primed'
2128 % storage area to be used for the second coffin. The `real' box
2129 % offsets are then calculated, before using these to re-box the
2130 % input coffins. The default poles are then set up, but the final result
2131 % depends on how the bounding box is being handled.
2132 % \begin{macrocode}
2133 \cs_new_protected:Npn \@@_align:NnnNnnnnN #1#2#3#4#5#6#7#8#9
2134 {
2135 \@@_calculate_intersection:Nnn #4 {#5} {#6}
2136 \dim_set:Nn \l_@@_x_prime_dim { \l_@@_x_dim }
2137 \dim_set:Nn \l_@@_y_prime_dim { \l_@@_y_dim }
2138 \@@_calculate_intersection:Nnn #1 {#2} {#3}
2139 \dim_set:Nn \l_@@_offset_x_dim
2140 { \l_@@_x_dim - \l_@@_x_prime_dim + #7 }
2141 \dim_set:Nn \l_@@_offset_y_dim
2142 { \l_@@_y_dim - \l_@@_y_prime_dim + #8 }
2143 \hbox_set:Nn \l_@@_aligned_internal_coffin
2144 {
2145 \box_use:N #1
2146 \dim_horizontal:n { -\box_wd:N #1 }
2147 \dim_horizontal:n { \l_@@_offset_x_dim }
2148 \box_move_up:nn { \l_@@_offset_y_dim } { \box_use:N #4 }
2149 }
2150 \coffin_set_eq:NN #9 \l_@@_aligned_internal_coffin
2151 }
2152 % \end{macrocode}
2153 % \end{macro}
2154 %
2155 % \begin{macro}{\@@_offset_poles:Nnn}
2156 % \begin{macro}{\@@_offset_pole:Nnnnnnn}
2157 % Transferring structures from one coffin to another requires that the
2158 % positions are updated by the offset between the two coffins. This is
2159 % done by mapping over the property list of the source coffins, moving
2160 % as appropriate and saving to the new coffin data structures. The
2161 % test for a |-| means that the structures from the parent coffins
2162 % are uniquely labeled and do not depend on the order of alignment.
2163 % The pay off for this is that |-| should not be used in coffin pole
2164 % or handle names, and that multiple alignments do not result in a
2165 % whole set of values.
2166 % \begin{macrocode}
2167 \cs_new_protected:Npn \@@_offset_poles:Nnn #1#2#3
2168 {
2169 \prop_map_inline:cn { coffin ~ \@@_to_value:N #1 ~ poles }
2170 { \@@_offset_pole:Nnnnnnn #1 {##1} ##2 {#2} {#3} }
2171 }
2172 \cs_new_protected:Npn \@@_offset_pole:Nnnnnnn #1#2#3#4#5#6#7#8
2173 {
2174 \dim_set:Nn \l_@@_x_dim { #3 + #7 }
2175 \dim_set:Nn \l_@@_y_dim { #4 + #8 }
2176 \tl_if_in:nnTF {#2} { - }
2177 { \tl_set:Nn \l_@@_tmp_tl { {#2} } }
2178 { \tl_set:Nn \l_@@_tmp_tl { { #1 - #2 } } }
2179 \exp_last_unbraced:NNo \@@_set_pole:Nnn \l_@@_aligned_coffin
2180 { \l_@@_tmp_tl }
2181 {
2182 { \dim_use:N \l_@@_x_dim } { \dim_use:N \l_@@_y_dim }
2183 {#5} {#6}
2184 }
2185 }
2186 % \end{macrocode}
2187 % \end{macro}
2188 % \end{macro}
2189 %
2190 % \begin{macro}{\@@_offset_corners:Nnn}
2191 % \begin{macro}{\@@_offset_corner:Nnnnn}
2192 % Saving the offset corners of a coffin is very similar, except that
2193 % there is no need to worry about naming: every corner can be saved
2194 % here as order is unimportant.
2195 % \begin{macrocode}
2196 \cs_new_protected:Npn \@@_offset_corners:Nnn #1#2#3
2197 {
2198 \prop_map_inline:cn { coffin ~ \@@_to_value:N #1 ~ corners }
2199 { \@@_offset_corner:Nnnnn #1 {##1} ##2 {#2} {#3} }
2200 }
2201 \cs_new_protected:Npn \@@_offset_corner:Nnnnn #1#2#3#4#5#6
2202 {
2203 \prop_put:cne
2204 {
2205 coffin ~ \@@_to_value:N \l_@@_aligned_coffin
2206 \c_space_tl corners
2207 }
2208 { #1 - #2 }
2209 {
2210 { \dim_eval:n { #3 + #5 } }
2211 { \dim_eval:n { #4 + #6 } }
2212 }
2213 }
2214 % \end{macrocode}
2215 % \end{macro}
2216 % \end{macro}
2217 %
2218 % \begin{macro}{\@@_update_TB_poles:NNnN}
2219 % \begin{macro}{\@@_update_TB_aux:NNnNnN}
2220 % \begin{macro}{\@@_extract_pole_y:NnN}
2221 % \begin{macro}{\@@_extract_pole_y_aux:nnnnN}
2222 % The \texttt{T} and \texttt{B} poles need to be recalculated
2223 % after alignment. To avoid incorrect pole selection due to name clashes
2224 % in deeply nested coffins or self-joins, these functions extract the
2225 % $y$-coordinates of the \texttt{T} and \texttt{B} poles directly from
2226 % the unmutated parent coffins, apply the necessary vertical offset,
2227 % and then find the maximum (for \texttt{T}) or minimum (for \texttt{B}).
2228 % Because these poles are strictly horizontal, only their $y$-components
2229 % need to be evaluated.
2230 % \begin{macrocode}
2231 \cs_new_protected:Npn \@@_update_TB_poles:NNnN #1#2#3#4
2232 {
2233 \@@_update_TB_aux:NNnNnN #1 #2 {#3} #4 { T } \dim_max:nn
2234 \@@_update_TB_aux:NNnNnN #1 #2 {#3} #4 { B } \dim_min:nn
2235 }
2236 \cs_new_protected:Npn \@@_update_TB_aux:NNnNnN #1#2#3#4#5#6
2237 {
2238 \@@_extract_pole_y:NnN #1 {#5} \l_@@_y_dim
2239 \@@_extract_pole_y:NnN #2 {#5} \l_@@_y_prime_dim
2240 \dim_set:Nn \l_@@_y_dim
2241 { #6 { \l_@@_y_dim } { \l_@@_y_prime_dim + #3 } }
2242 \@@_set_pole:Nnn #4 {#5}
2243 {
2244 { 0pt }
2245 { \dim_use:N \l_@@_y_dim }
2246 { 1000pt }
2247 { 0pt }
2248 }
2249 }
2250 \cs_new_protected:Npn \@@_extract_pole_y:NnN #1#2#3
2251 {
2252 \use:e
2253 {
2254 \@@_extract_pole_y_aux:nnnnN
2255 \coffin_pole:Nn #1 {#2}
2256 \exp_not:N #3
2257 }
2258 }
2259 \cs_new_protected:Npn \@@_extract_pole_y_aux:nnnnN #1#2#3#4#5 { \dim_set:Nn #5 {#2} }
2260 % \end{macrocode}
2261 % \end{macro}
2262 % \end{macro}
2263 % \end{macro}
2264 % \end{macro}
2265 %
2266 % \begin{variable}{\c_@@_empty_coffin}
2267 % An empty-but-horizontal coffin.
2268 % \begin{macrocode}
2269 \coffin_new:N \c_@@_empty_coffin
2270 \tex_setbox:D \c_@@_empty_coffin = \tex_hbox:D { }
2271 % \end{macrocode}
2272 % \end{variable}
2273 %
2274 % \begin{macro}{\coffin_typeset:Nnnnn, \coffin_typeset:cnnnn}
2275 % Typesetting a coffin means aligning it with the current position,
2276 % which is done using a coffin with no content at all. As well as aligning to
2277 % the empty coffin, there is also a need to leave vertical mode, if necessary.
2278 % \begin{macrocode}
2279 \cs_new_protected:Npn \coffin_typeset:Nnnnn #1#2#3#4#5
2280 {
2281 \mode_leave_vertical:
2282 \@@_align:NnnNnnnnN \c_@@_empty_coffin { H } { l }
2283 #1 {#2} {#3} {#4} {#5} \l_@@_aligned_coffin
2284 \box_use_drop:N \l_@@_aligned_coffin
2285 }
2286 \cs_generate_variant:Nn \coffin_typeset:Nnnnn { c }
2287 % \end{macrocode}
2288 % \end{macro}
2289 %
2290 % \subsection{Coffin diagnostics}
2291 %
2292 % \begin{variable}{\l_@@_display_coffin}
2293 % \begin{variable}{\l_@@_display_coord_coffin}
2294 % \begin{variable}{\l_@@_display_pole_coffin}
2295 % Used for printing coffins with data structures attached.
2296 % \begin{macrocode}
2297 \coffin_new:N \l_@@_display_coffin
2298 \coffin_new:N \l_@@_display_coord_coffin
2299 \coffin_new:N \l_@@_display_pole_coffin
2300 % \end{macrocode}
2301 % \end{variable}
2302 % \end{variable}
2303 % \end{variable}
2304 %
2305 % \begin{variable}{\l_@@_display_handles_prop}
2306 % This property list is used to print coffin handles at suitable
2307 % positions. The offsets are expressed as multiples of the basic offset
2308 % value, which therefore acts as a scale-factor.
2309 % \begin{macrocode}
2310 \prop_new:N \l_@@_display_handles_prop
2311 \prop_put:Nnn \l_@@_display_handles_prop { tl }
2312 { { b } { r } { -1 } { 1 } }
2313 \prop_put:Nnn \l_@@_display_handles_prop { thc }
2314 { { b } { hc } { 0 } { 1 } }
2315 \prop_put:Nnn \l_@@_display_handles_prop { tr }
2316 { { b } { l } { 1 } { 1 } }
2317 \prop_put:Nnn \l_@@_display_handles_prop { vcl }
2318 { { vc } { r } { -1 } { 0 } }
2319 \prop_put:Nnn \l_@@_display_handles_prop { vchc }
2320 { { vc } { hc } { 0 } { 0 } }
2321 \prop_put:Nnn \l_@@_display_handles_prop { vcr }
2322 { { vc } { l } { 1 } { 0 } }
2323 \prop_put:Nnn \l_@@_display_handles_prop { bl }
2324 { { t } { r } { -1 } { -1 } }
2325 \prop_put:Nnn \l_@@_display_handles_prop { bhc }
2326 { { t } { hc } { 0 } { -1 } }
2327 \prop_put:Nnn \l_@@_display_handles_prop { br }
2328 { { t } { l } { 1 } { -1 } }
2329 \prop_put:Nnn \l_@@_display_handles_prop { Tl }
2330 { { t } { r } { -1 } { -1 } }
2331 \prop_put:Nnn \l_@@_display_handles_prop { Thc }
2332 { { t } { hc } { 0 } { -1 } }
2333 \prop_put:Nnn \l_@@_display_handles_prop { Tr }
2334 { { t } { l } { 1 } { -1 } }
2335 \prop_put:Nnn \l_@@_display_handles_prop { Hl }
2336 { { vc } { r } { -1 } { 1 } }
2337 \prop_put:Nnn \l_@@_display_handles_prop { Hhc }
2338 { { vc } { hc } { 0 } { 1 } }
2339 \prop_put:Nnn \l_@@_display_handles_prop { Hr }
2340 { { vc } { l } { 1 } { 1 } }
2341 \prop_put:Nnn \l_@@_display_handles_prop { Bl }
2342 { { b } { r } { -1 } { -1 } }
2343 \prop_put:Nnn \l_@@_display_handles_prop { Bhc }
2344 { { b } { hc } { 0 } { -1 } }
2345 \prop_put:Nnn \l_@@_display_handles_prop { Br }
2346 { { b } { l } { 1 } { -1 } }
2347 % \end{macrocode}
2348 % \end{variable}
2349 %
2350 % \begin{variable}{\l_@@_display_offset_dim}
2351 % The standard offset for the label from the handle position when
2352 % displaying handles.
2353 % \begin{macrocode}
2354 \dim_new:N \l_@@_display_offset_dim
2355 \dim_set:Nn \l_@@_display_offset_dim { 2pt }
2356 % \end{macrocode}
2357 % \end{variable}
2358 %
2359 % \begin{variable}{\l_@@_display_x_dim}
2360 % \begin{variable}{\l_@@_display_y_dim}
2361 % As the intersections of poles have to be calculated to find which
2362 % ones to print, there is a need to avoid repetition. This is done
2363 % by saving the intersection into two dedicated values.
2364 % \begin{macrocode}
2365 \dim_new:N \l_@@_display_x_dim
2366 \dim_new:N \l_@@_display_y_dim
2367 % \end{macrocode}
2368 % \end{variable}
2369 % \end{variable}
2370 %
2371 % \begin{variable}{\l_@@_display_poles_prop}
2372 % A property list for printing poles: various things need to be deleted
2373 % from this to get a \enquote{nice} output.
2374 % \begin{macrocode}
2375 \prop_new:N \l_@@_display_poles_prop
2376 % \end{macrocode}
2377 % \end{variable}
2378 %
2379 % \begin{variable}{\l_@@_display_font_tl}
2380 % Stores the settings used to print coffin data: this keeps things
2381 % flexible.
2382 % \begin{macrocode}
2383 \tl_new:N \l_@@_display_font_tl
2384 \bool_lazy_and:nnT
2385 { \cs_if_exist_p:N \fmtname }
2386 { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
2387 {
2388 \tl_set:Nn \l_@@_display_font_tl
2389 { \sffamily \tiny }
2390 }
2391 % \end{macrocode}
2392 % \end{variable}
2393 %
2394 % \begin{macro}{\@@_rule:nn}
2395 % Abstract out creation of rules here until there is a higher-level interface.
2396 % \begin{macrocode}
2397 \cs_new_protected:Npn \@@_rule:nn #1#2
2398 {
2399 \mode_leave_vertical:
2400 \hbox:n { \tex_vrule:D width #1 height #2 \scan_stop: }
2401 }
2402 % \end{macrocode}
2403 % \end{macro}
2404 %
2405 % \begin{macro}{\coffin_mark_handle:Nnnn, \coffin_mark_handle:cnnn}
2406 % \begin{macro}{\@@_mark_handle_aux:nnnnNnn}
2407 % Marking a single handle is relatively easy. The standard attachment
2408 % function is used, meaning that there are two calculations for the
2409 % location. However, this is likely to be okay given the load expected.
2410 % Contrast with the more optimized version for showing all handles which
2411 % comes next.
2412 % \begin{macrocode}
2413 \cs_new_protected:Npn \coffin_mark_handle:Nnnn #1#2#3#4
2414 {
2415 \hcoffin_set:Nn \l_@@_display_pole_coffin
2416 {
2417 \color_select:n {#4}
2418 \@@_rule:nn { 1pt } { 1pt }
2419 }
2420 \@@_attach_mark:NnnNnnnn #1 {#2} {#3}
2421 \l_@@_display_pole_coffin { hc } { vc } { 0pt } { 0pt }
2422 \hcoffin_set:Nn \l_@@_display_coord_coffin
2423 {
2424 \color_select:n {#4}
2425 \l_@@_display_font_tl
2426 ( \tl_to_str:n { #2 , #3 } )
2427 }
2428 \prop_get:NnN \l_@@_display_handles_prop
2429 { #2 #3 } \l_@@_tmp_tl
2430 \quark_if_no_value:NTF \l_@@_tmp_tl
2431 {
2432 \prop_get:NnN \l_@@_display_handles_prop
2433 { #3 #2 } \l_@@_tmp_tl
2434 \quark_if_no_value:NTF \l_@@_tmp_tl
2435 {
2436 \@@_attach_mark:NnnNnnnn #1 {#2} {#3}
2437 \l_@@_display_coord_coffin { l } { vc }
2438 { 1pt } { 0pt }
2439 }
2440 {
2441 \exp_last_unbraced:No \@@_mark_handle_aux:nnnnNnn
2442 \l_@@_tmp_tl #1 {#2} {#3}
2443 }
2444 }
2445 {
2446 \exp_last_unbraced:No \@@_mark_handle_aux:nnnnNnn
2447 \l_@@_tmp_tl #1 {#2} {#3}
2448 }
2449 }
2450 \cs_new_protected:Npn \@@_mark_handle_aux:nnnnNnn #1#2#3#4#5#6#7
2451 {
2452 \@@_attach_mark:NnnNnnnn #5 {#6} {#7}
2453 \l_@@_display_coord_coffin {#1} {#2}
2454 { #3 \l_@@_display_offset_dim }
2455 { #4 \l_@@_display_offset_dim }
2456 }
2457 \cs_generate_variant:Nn \coffin_mark_handle:Nnnn { c }
2458 % \end{macrocode}
2459 % \end{macro}
2460 % \end{macro}
2461 %
2462 % \begin{macro}{\coffin_display_handles:Nn, \coffin_display_handles:cn}
2463 % \begin{macro}{\@@_display_handles_aux:nnnnnn}
2464 % \begin{macro}{\@@_display_handles_aux:nnnn}
2465 % \begin{macro}{\@@_display_attach:Nnnnn}
2466 % Printing the poles starts by removing any duplicates, for which the
2467 % \texttt{H} poles is used as the definitive version for the baseline
2468 % and bottom. Two loops are then used to find the combinations of
2469 % handles for all of these poles. This is done such that poles are
2470 % removed during the loops to avoid duplication.
2471 % \begin{macrocode}
2472 \cs_new_protected:Npn \coffin_display_handles:Nn #1#2
2473 {
2474 \hcoffin_set:Nn \l_@@_display_pole_coffin
2475 {
2476 \color_select:n {#2}
2477 \@@_rule:nn { 1pt } { 1pt }
2478 }
2479 \prop_set_eq:Nc \l_@@_display_poles_prop
2480 { coffin ~ \@@_to_value:N #1 ~ poles }
2481 \str_if_eq:eeT
2482 { \coffin_pole:Nn #1 { H } }
2483 { \coffin_pole:Nn #1 { T } }
2484 { \prop_remove:Nn \l_@@_display_poles_prop { T } }
2485 \str_if_eq:eeT
2486 { \coffin_pole:Nn #1 { H } }
2487 { \coffin_pole:Nn #1 { B } }
2488 { \prop_remove:Nn \l_@@_display_poles_prop { B } }
2489 \coffin_set_eq:NN \l_@@_display_coffin #1
2490 \prop_map_inline:Nn \l_@@_display_poles_prop
2491 {
2492 \prop_remove:Nn \l_@@_display_poles_prop {##1}
2493 \@@_display_handles_aux:nnnnnn {##1} ##2 {#2}
2494 }
2495 \box_use_drop:N \l_@@_display_coffin
2496 }
2497 % \end{macrocode}
2498 % For each pole there is a check for an intersection, which here does
2499 % not give an error if none is found. The successful values are stored
2500 % and used to align the pole coffin with the main coffin for output.
2501 % The positions are recovered from the preset list if available.
2502 % \begin{macrocode}
2503 \cs_new_protected:Npn \@@_display_handles_aux:nnnnnn #1#2#3#4#5#6
2504 {
2505 \prop_map_inline:Nn \l_@@_display_poles_prop
2506 {
2507 \bool_set_false:N \l_@@_error_bool
2508 \@@_calculate_intersection:nnnnnnnn {#2} {#3} {#4} {#5} ##2
2509 \bool_if:NF \l_@@_error_bool
2510 {
2511 \dim_set:Nn \l_@@_display_x_dim { \l_@@_x_dim }
2512 \dim_set:Nn \l_@@_display_y_dim { \l_@@_y_dim }
2513 \@@_display_attach:Nnnnn
2514 \l_@@_display_pole_coffin { hc } { vc }
2515 { 0pt } { 0pt }
2516 \hcoffin_set:Nn \l_@@_display_coord_coffin
2517 {
2518 \color_select:n {#6}
2519 \l_@@_display_font_tl
2520 ( \tl_to_str:n { #1 , ##1 } )
2521 }
2522 \prop_get:NnN \l_@@_display_handles_prop
2523 { #1 ##1 } \l_@@_tmp_tl
2524 \quark_if_no_value:NTF \l_@@_tmp_tl
2525 {
2526 \prop_get:NnN \l_@@_display_handles_prop
2527 { ##1 #1 } \l_@@_tmp_tl
2528 \quark_if_no_value:NTF \l_@@_tmp_tl
2529 {
2530 \@@_display_attach:Nnnnn
2531 \l_@@_display_coord_coffin { l } { vc }
2532 { 1pt } { 0pt }
2533 }
2534 {
2535 \exp_last_unbraced:No
2536 \@@_display_handles_aux:nnnn
2537 \l_@@_tmp_tl
2538 }
2539 }
2540 {
2541 \exp_last_unbraced:No \@@_display_handles_aux:nnnn
2542 \l_@@_tmp_tl
2543 }
2544 }
2545 }
2546 }
2547 \cs_new_protected:Npn \@@_display_handles_aux:nnnn #1#2#3#4
2548 {
2549 \@@_display_attach:Nnnnn
2550 \l_@@_display_coord_coffin {#1} {#2}
2551 { #3 \l_@@_display_offset_dim }
2552 { #4 \l_@@_display_offset_dim }
2553 }
2554 \cs_generate_variant:Nn \coffin_display_handles:Nn { c }
2555 % \end{macrocode}
2556 % This is a dedicated version of \cs{coffin_attach:NnnNnnnn} with
2557 % a hard-wired first coffin. As the intersection is already known
2558 % and stored for the display coffin the code simply uses it directly,
2559 % with no calculation.
2560 % \begin{macrocode}
2561 \cs_new_protected:Npn \@@_display_attach:Nnnnn #1#2#3#4#5
2562 {
2563 \@@_calculate_intersection:Nnn #1 {#2} {#3}
2564 \dim_set:Nn \l_@@_x_prime_dim { \l_@@_x_dim }
2565 \dim_set:Nn \l_@@_y_prime_dim { \l_@@_y_dim }
2566 \dim_set:Nn \l_@@_offset_x_dim
2567 { \l_@@_display_x_dim - \l_@@_x_prime_dim + #4 }
2568 \dim_set:Nn \l_@@_offset_y_dim
2569 { \l_@@_display_y_dim - \l_@@_y_prime_dim + #5 }
2570 \hbox_set:Nn \l_@@_aligned_coffin
2571 {
2572 \box_use:N \l_@@_display_coffin
2573 \dim_horizontal:n { -\box_wd:N \l_@@_display_coffin }
2574 \dim_horizontal:n { \l_@@_offset_x_dim }
2575 \box_move_up:nn { \l_@@_offset_y_dim } { \box_use:N #1 }
2576 }
2577 \box_set_ht:Nn \l_@@_aligned_coffin
2578 { \box_ht:N \l_@@_display_coffin }
2579 \box_set_dp:Nn \l_@@_aligned_coffin
2580 { \box_dp:N \l_@@_display_coffin }
2581 \box_set_wd:Nn \l_@@_aligned_coffin
2582 { \box_wd:N \l_@@_display_coffin }
2583 \box_set_eq:NN \l_@@_display_coffin \l_@@_aligned_coffin
2584 }
2585 % \end{macrocode}
2586 % \end{macro}
2587 % \end{macro}
2588 % \end{macro}
2589 % \end{macro}
2590 %
2591 % \begin{macro}
2592 % {
2593 % \coffin_show_structure:N, \coffin_show_structure:c,
2594 % \coffin_log_structure:N, \coffin_log_structure:c,
2595 % \@@_show_structure:NN
2596 % }
2597 % For showing the various internal structures attached to a coffin in
2598 % a way that keeps things relatively readable. If there is no apparent
2599 % structure then the code complains.
2600 % \begin{macrocode}
2601 \cs_new_protected:Npn \coffin_show_structure:N
2602 { \@@_show_structure:NN \msg_show:nneeee }
2603 \cs_generate_variant:Nn \coffin_show_structure:N { c }
2604 \cs_new_protected:Npn \coffin_log_structure:N
2605 { \@@_show_structure:NN \msg_log:nneeee }
2606 \cs_generate_variant:Nn \coffin_log_structure:N { c }
2607 \cs_new_protected:Npn \@@_show_structure:NN #1#2
2608 {
2609 \@@_if_exist:NT #2
2610 {
2611 #1 { coffin } { show }
2612 { \token_to_str:N #2 }
2613 {
2614 \iow_newline: >~ ht ~=~ \dim_eval:n { \coffin_ht:N #2 }
2615 \iow_newline: >~ dp ~=~ \dim_eval:n { \coffin_dp:N #2 }
2616 \iow_newline: >~ wd ~=~ \dim_eval:n { \coffin_wd:N #2 }
2617 }
2618 {
2619 \prop_map_function:cN
2620 { coffin ~ \@@_to_value:N #2 ~ poles }
2621 \msg_show_item_unbraced:nn
2622 }
2623 { }
2624 }
2625 }
2626 % \end{macrocode}
2627 % \end{macro}
2628 %
2629 % \begin{macro}
2630 % {
2631 % \coffin_show:N, \coffin_show:c, \coffin_log:N, \coffin_log:c,
2632 % \coffin_show:Nnn, \coffin_show:cnn, \coffin_log:Nnn, \coffin_log:cnn,
2633 % \@@_show:NNNnn
2634 % }
2635 % Essentially a combination of \cs{coffin_show_structure:N} and
2636 % \cs{box_show:Nnn}, but we need to avoid having two prompts, so we
2637 % use \cs{msg_term:nneeee} instead of
2638 % \cs{msg_show:nneeee} in the |show| case.
2639 % \begin{macrocode}
2640 \cs_new_protected:Npn \coffin_show:N #1
2641 { \coffin_show:Nnn #1 \c_max_int \c_max_int }
2642 \cs_generate_variant:Nn \coffin_show:N { c }
2643 \cs_new_protected:Npn \coffin_log:N #1
2644 { \coffin_log:Nnn #1 \c_max_int \c_max_int }
2645 \cs_generate_variant:Nn \coffin_log:N { c }
2646 \cs_new_protected:Npn \coffin_show:Nnn
2647 { \@@_show:NNNnn \msg_term:nneeee \box_show:Nnn }
2648 \cs_generate_variant:Nn \coffin_show:Nnn { c }
2649 \cs_new_protected:Npn \coffin_log:Nnn
2650 { \@@_show:NNNnn \msg_log:nneeee \box_show:Nnn }
2651 \cs_generate_variant:Nn \coffin_log:Nnn { c }
2652 \cs_new_protected:Npn \@@_show:NNNnn #1#2#3#4#5
2653 {
2654 \@@_if_exist:NT #3
2655 {
2656 \@@_show_structure:NN #1 #3
2657 #2 #3 {#4} {#5}
2658 }
2659 }
2660 % \end{macrocode}
2661 % \end{macro}
2662 %
2663 % \subsection{Messages}
2664 %
2665 % \begin{macrocode}
2666 \msg_new:nnnn { coffin } { no-pole-intersection }
2667 { No~intersection~between~coffin~poles. }
2668 {
2669 LaTeX~was~asked~to~find~the~intersection~between~two~poles,~
2670 but~they~do~not~have~a~unique~meeting~point:~
2671 the~value~(0pt,~0pt)~will~be~used.
2672 }
2673 \msg_new:nnnn { coffin } { unknown }
2674 { Unknown~coffin~'#1'. }
2675 { The~coffin~'#1'~was~never~defined. }
2676 \msg_new:nnn { coffin } { unknown-pole }
2677 { Pole~'#1'~unknown~for~coffin~'#2'. }
2678 \msg_new:nnn { coffin } { show }
2679 {
2680 Size~of~coffin~#1 : #2 \\
2681 Poles~of~coffin~#1 : #3 .
2682 }
2683 % \end{macrocode}
2684 %
2685 % \begin{macrocode}
2686 %</code>
2687 % \end{macrocode}
2688 %
2689 % \end{implementation}
2690 %
2691 % \PrintIndex