summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xpackages/xcoffins/xcoffins-test.tex
blob: 1ede1770c0840d55545980eba6bdccbed94aa68b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{times,multicol}
\usepackage{xcoffins}

\usepackage{color}
\newcommand\cbox[2][.8]{{\setlength\fboxsep{0pt}\colorbox[gray]{#1}{#2}}}

\newcommand\hrulebox [2]{\setbox#1\hbox to#2{{\scriptsize\itshape
                         \color{blue}\hrulefill #2\hrulefill}}}
\newcommand\vrulebox [2]{\setbox#1\vbox to#2{{\hsize 1pt\centering\scriptsize
                         \itshape\color{blue}\leaders\vrule\vfill
                         \hbox to0pt{\hss #2\hss}\leaders\vrule\vfill\par}}}


\addtolength\textwidth{10pt}

\showboxdepth 9999
\showboxbreadth 9999
\tracingonline 1


\scrollmode

\newbox\zzz


\begin{document}


\title{Test file for coffins}
\author{FMi}
\maketitle

First we add a few test coffins:
\begin{verbatim}
  \newcoffin \aaa
  \newcoffin \bbb
  \newcoffin \ccc
  \newcoffin \ddd
\end{verbatim}
  \newcoffin \aaa
  \newcoffin \bbb
  \newcoffin \ccc
  \newcoffin \ddd
and some boxes not set up as ordinary boxes (without extra poles):
\begin{verbatim}
  \newbox \xxx
  \newbox \yyy
\end{verbatim}
  \newbox \xxx
  \newbox \yyy


If a coffin receives data a set of ``natural'' default poles are automatically added.
\begin{verbatim}
\sbox\aaa{\fbox{\begin{tabular}[b]{l}123\\4\\5\end{tabular}}}
\showcoffindata \aaa
\end{verbatim}
\sbox\aaa{\fbox{\begin{tabular}[b]{l}123\\4\\5\end{tabular}}}
\showcoffindata \aaa


In contrast, boxes not declared as coffins have no poles defined. However, if
used as coffins at least the natural default poles can be used without
further problems, i.e.,they are changed to coffins automatically on use.
\begin{verbatim}
\sbox\xxx{\fbox{Some very looooonggg Caption Text}}
\showpoles \xxx
\end{verbatim}
\sbox\xxx{\fbox{Some very looooonggg Caption Text}}
\showcoffindata \xxx


Using \verb|\setvcoffin| instead of \verb|\sbox| gives us the codes with
\texttt{T} and \texttt{B}. Similar to \verb|\parbox| this command requires to
specify a target width of the box:
\begin{verbatim}
\setvcoffin \aaa {1.5cm} {\centering
   \fbox{\begin{tabular}[b]{l}123\\4\\5\end{tabular}}}
\showcoffindata \aaa
\end{verbatim}
\setvcoffin \aaa {1.5cm} {\centering
   \fbox{\begin{tabular}[b]{l}123\\4\\5\end{tabular}}}
\showcoffindata \aaa

There are a dozen natural poles per box (some with multiple names); you can
move each of the poles to someplace else (either to an absolute position in
``box space'' or relative to its previous position).  The coordinates can
refer to box dimensions (using \verb|\height|, \verb|\depth|,
 and \verb|width|). First we move some pole and add one
additional one:
\begin{verbatim}
\setcoffinpole \aaa [h]{t}(\height -3pt)
\setcoffinpole \aaa [v]{l}(0pt)
\setcoffinpole \aaa [h]{mybottom}(\depth +2pt)
\showcoffindata \aaa
\end{verbatim}
\setcoffinpole \aaa [h]{t}(\height -3pt)
\setcoffinpole \aaa [v]{l}(0pt)
\setcoffinpole \aaa [h]{mybottom}(\depth +2pt)
\showcoffindata \aaa


More interesting in many cases is the relative move of poles. For this the
poles better exist or one gets an error and \texttt{0pt,0pt} is used:
\begin{verbatim}
\adjustcoffinpole \aaa [h]{H}(1pt)
\adjustcoffinpole \aaa [v]{l}(1pt)
\adjustcoffinpole \aaa [h]{undefined}(1pt)
\showcoffindata \aaa
\end{verbatim}
\adjustcoffinpole \aaa [h]{H}(1pt)
\adjustcoffinpole \aaa [v]{l}(1pt)
\adjustcoffinpole \aaa [h]{undefined}(1pt)
\showcoffindata \aaa



\sbox \aaa {\fontsize{14.4}{5.5pc minus .5pc}\sffamily C\,H\,A\,P\,T\,E\,R 
            \fontsize{36}{40pt}\selectfont 2}

\setvcoffin \bbb {11cm}
   {\raggedleft\normalfont\fontsize{36}{38pt}\bfseries 
    The Structure of a \LaTeX{} Document}

\setvcoffin \ccc {13cm}
   {Some sample blind text to produce paragraph data after a heading.
    Some sample blind text to produce paragraph data after a heading.
    Some sample blind text to produce paragraph data after a heading.
    Some sample blind text to produce paragraph data after a heading.
    \endgraf
    Some more sample blind text to produce paragraph data after a heading.
    Some more sample blind text to produce paragraph data after a heading.
}


Suppose you have the following blocks of text:

\bigskip

\noindent\cbox{\usebox\aaa}

\begin{multicols}{2}
\ttfamily\tiny
\ExplSyntaxOn
   \noindent \coffin_print_pole_values:Nn \aaa \\ 
\ExplSyntaxOff
\end{multicols}

\medskip

\noindent\cbox{\usebox\bbb}

\medskip

\noindent\cbox{\usebox\ccc}

\bigskip

produced by:
\begin{verbatim}
\sbox \aaa {\fontsize{14.4}{5.5pc minus .5pc}\sffamily 
             C\,H\,A\,P\,T\,E\,R 
            \fontsize{36}{40pt}\selectfont 2}
\setvcoffin \bbb {11cm}
   {\raggedleft\normalfont\fontsize{36}{38pt}\bfseries 
    The Structure of a \LaTeX{} Document}
\setvcoffin \ccc {13cm}
   {Some sample blind text to produce paragraph 
    data after a heading.                        ... }
\end{verbatim}

How do you turn this into a heading of TLC2?


\newbox\RBi
\newbox\RBii
\newbox\RBiii

\hrulebox\RBi{62pt}
\vrulebox\RBii{90pt}
\vrulebox\RBiii{60pt}

\aligncoffins  \bbb [T,r] \aaa [H,r](-62pt,60pt)
\aligncoffins  \ccc[T,r] \bbb[B,r](62pt,90pt)

  \aligncoffins * \ccc[\bbb-T,\bbb-hc] \RBiii[b,hc](28pt,0pt)
  \aligncoffins * \ccc[\bbb-b,\bbb-r] \RBi[H,r](0pt,-5pt)
  \aligncoffins * \ccc[\bbb-B,\bbb-hc] \RBii[t,r](14pt,0pt)

\newpage

How do you best define/describe the following design?

\medskip

\noindent\cbox{\usebox\ccc}






\newpage \pagestyle{empty}

\newcoffin \eee
\newcoffin \fff
\newcoffin \ggg

\sbox \aaa {\small\scshape les vases communicants}
\sbox \bbb {\scshape comunicating}
\sbox \ccc {\fontsize{70pt}{60pt} \bfseries Ve\S els}
\sbox \ddd {\scshape andr\'e breton}
\setvcoffin \eee {4.7cm}{\noindent Translated by Mary Ann Caws \&\break
                    Geoffrey T.\,Harris, with notes \&\break
                    introduction by Mary Ann Caws\parfillskip=0pt\relax
                    }
\sbox \fff {University of Nebraska Press: Lincoln \& London}

\setvcoffin \ggg {100mm}{\noindent\fbox{\parbox{97mm}{\leavevmode\vspace*{228mm}}}}


\aligncoffins   \ccc [H,r] \ddd [H,r](0pt,-12pt)
\aligncoffins   \ccc [t,l] \bbb      (0pt,6pt)
\aligncoffins   \ccc [H,r] \aaa [H,r](0pt,138pt)
\aligncoffins   \eee [T,l] \ccc      (0pt,22pc)
\aligncoffins   \fff       \eee [B,l](0pt,4pc)
\aligncoffins   \ggg [b,l] \fff [B,l](54pt,11pc)


\vspace*{-2cm}
\noindent\cbox{\usebox\ggg}


\newpage

\section{Rotation}

\sbox \aaa {\tabcolsep0pt\begin{tabular}[c]{|c|}\hline a\\b\\cccccccccccccc\\d
                \\e\\e\\e\\e\\\hline\end{tabular}}
\sbox \bbb {\fbox{A sample Text}}

% just for the sake of it:
\adjustcoffinpole \aaa {T}(24pt)
\displaycoffinpoles \aaa {black}
x\cbox{\usebox \aaa }x
%
\rotatecoffin \aaa {45}
\displaycoffinhandle \aaa {b}{hc} {blue}
\displaycoffinhandle \aaa {b}{l} {blue}
\displaycoffinhandle \aaa {t}{r} {blue}
\displaycoffinhandle \aaa {vc}{r} {blue}
\displaycoffinhandle \aaa {vc}{l} {blue}
\quad
x\cbox{\usebox \aaa }x
\rotatecoffin \aaa {45}
\displaycoffinhandle \aaa {b}{r} {red}
\displaycoffinhandle \aaa {vc}{l} {red}
\quad
x\cbox{\usebox \aaa }x

\vspace{1cm}

\rotatecoffin \aaa {45}
\displaycoffinhandle \aaa {b}{l} {yellow}
%
x\cbox{\usebox \aaa }x
%

\vspace{1cm}

x\cbox{\usebox \bbb }x
%
\rotatecoffin \bbb {45}
\displaycoffinhandle \bbb {B}{hc} {yellow}
\quad
x\cbox{\usebox \bbb }x


\section{Rotation + alignment}

\aligncoffins \aaa [b,l] \bbb[B,hc](30pt,0pt)
x\cbox{\usebox \aaa }x


After we have aligned a roated box with some other box we need to decide about
the bounding box of the new box. Right now this become the enclosing box and
we do not maintain information about the inner boxes. So when we rotate that
new box there seems to be unnecessary space in the enclosing bounding box,
even though that is correct if you think of the aligned box being unrotated.

There is at least the possibility to refer to the handles of the inner boxes
as one can see by two of the green handles

\medskip

\rotatecoffin \aaa {45}
\displaycoffinhandle \aaa {vc}{hc} {green}
\displaycoffinhandle \aaa {H}{l} {green}
\displaycoffinhandle \aaa {\aaa-T}{\aaa-r} {green}
\displaycoffinhandle \aaa {\bbb-H}{\bbb-r} {green}
%\quad
x\cbox{\usebox \aaa }x

We could do better, if we want to, by actually checking for max and
min of all inner bounding box corners and construct the result BB box from
that---but is it worth it?

Perhaps it is! After all, the current implementation shows different results
depending on when you align boxes and when you rotate, e.g., aligning first
gives totally different bounding box results. 

\newpage

Aligning first and then 135 + 45 rotation gives this:

\sbox \aaa {\tabcolsep0pt\begin{tabular}[c]{|c|}\hline a\\b\\cccccccccccccc\\d
                \\e\\e\\e\\e\\\hline\end{tabular}}
\sbox \bbb {\fbox{A sample Text}}
\rotatecoffin \bbb {90}

\aligncoffins \aaa [b,l] \bbb[B,hc](-30pt,0pt)
x\cbox{\usebox \aaa }x
\qquad
\rotatecoffin \aaa {135}
x\cbox{\usebox \aaa }x
\qquad
\rotatecoffin \aaa {45}
x\cbox{\usebox \aaa }x




\newpage

\section{Rotation by small amounts}

\sbox \aaa {\tabcolsep0pt\begin{tabular}[c]{|c|}\hline a\\b\\ccccccccc\\d
                \\e\\e\\e\\\hline\end{tabular}}

\subsection{30 + 30 +30 }
\rotatecoffin \aaa {30}
x\cbox{\usebox \aaa }x
\rotatecoffin \aaa {30}
x\cbox{\usebox \aaa }x
\rotatecoffin \aaa {30}
x\cbox{\usebox \aaa }x

\subsection{6 * 10 + 45 + 45 + 30}

\rotatecoffin \aaa {10}
x\cbox{\usebox \aaa }x
\rotatecoffin \aaa {10}
x\cbox{\usebox \aaa }x
\rotatecoffin \aaa {10}
x\cbox{\usebox \aaa }x

\vspace{1cm}
\rotatecoffin \aaa {10}
x\cbox{\usebox \aaa }x
\rotatecoffin \aaa {10}
x\cbox{\usebox \aaa }x
\rotatecoffin \aaa {10}
x\cbox{\usebox \aaa }x

\vspace{1cm}
\rotatecoffin \aaa {45}
x\cbox{\usebox \aaa }x
\rotatecoffin \aaa {45}
x\cbox{\usebox \aaa }x
\rotatecoffin \aaa {30}
x\cbox{\usebox \aaa }x


\end{document}