details-captiontrickery.tex /size: 6337 b    last modification: 2023-12-21 09:43
1% language=us
2
3\environment details-environment
4
5\startcomponent details-captiontrickery
6
7\startchapter[title={Caption handling}]
8
9\start
10
11It's hard to predict what kind of caption placements users want. The amount of
12variation if large and thereby any system of specifying them will look complex.
13So, examples are the best way to show them.
14
15\startbuffer
16\setupcaption
17  [figure]
18  [location=bottom]
19\placefigure
20  [left]
21  {}{\externalfigure[dummy][lines=2,width=4cm]}
22\fakewords{60}{80} \par
23\stopbuffer
24
25\typebuffer \getbuffer
26
27\startbuffer
28% \setupfloats[grid=yes]
29% \setupfloats[grid=tolerant]
30\setupcaption
31  [figure]
32  [location=top]
33\placefigure
34  [left]
35  {}{\externalfigure[dummy][lines=2,width=4cm]}
36\fakewords{60}{80} \par
37\stopbuffer
38
39\typebuffer \getbuffer
40
41In this document we typeset on a grid. For more complex cases and when a document
42is processed without any user intervention, this is often a bad idea because the
43snapper can decide to make sure that there is enough space above and below an
44element. You can however influence the snapper explicitly:
45
46\startbuffer
47\setupcaption
48  [figure]
49  [location=top]
50\placefigure
51  [left,line]
52  {}{\externalfigure[dummy][lines=2,width=4cm]}
53\fakewords{60}{80} \par
54\stopbuffer
55
56\typebuffer \getbuffer
57
58Normally a side float plus caption has a normalized (strut) depth while also
59top skip gets applied. When one of the grid related options \type {height}, \type
60{line}, \type {depth}, \type {grid} or \type {halfline} is given the top skip
61correction is removed. The \type {grid} option removes the depth too. The \type
62{grid} option removes the depth while the \type {height} and \type {depth}
63options adds an extra amount of strut depth. The \type {depth} option also adds a
64line and \type {halfline} removes a line but adds strut height. Indeed this sounds
65complicated so best play with it a bit.
66
67Keep in mind that the snapper plays safe and therefore tends to add more space when
68needed. You can set a grid parameter that controls it:
69
70\starttyping
71\setupfloats[grid=tolerant]
72\stoptyping
73
74Currently this only applies to side floats but in the future we might support it
75for regular floats too.
76
77\startbuffer
78\setupcaption
79  [figure]
80  [width=4cm,align=flushright,location={left,high}]
81\placefigure
82  [left]
83  {}{\externalfigure[dummy][lines=2,width=4cm]}
84\fakewords{60}{80} \par
85\stopbuffer
86
87\typebuffer \getbuffer
88
89\startbuffer
90\setupcaption
91  [figure]
92  [width=4cm,align=flushright,location={high,lefthanging}]
93\placefigure
94  [left]
95  {}{\externalfigure[dummy][lines=2,width=4cm]}
96\fakewords{60}{80} \par
97\stopbuffer
98
99\typebuffer \getbuffer
100
101\startbuffer
102\setupcaption
103  [figure]
104  [width=4cm,align=flushleft,location={high,righthanging}]
105\placefigure
106  [right]
107  {}{\externalfigure[dummy][lines=2,width=4cm]}
108\fakewords{60}{80} \par
109\stopbuffer
110
111\typebuffer \getbuffer
112
113\startbuffer
114\setupcaption
115  [figure]
116  [width=4cm,align=flushleft,location={high,rightmargin}]
117\placefigure
118  [right]
119  {}{\externalfigure[dummy][lines=2,width=4cm]}
120\fakewords{60}{80} \par
121\stopbuffer
122
123\typebuffer \getbuffer
124
125The location of a caption is determined by the keywords \type {top}, \type
126{bottom} and for the side captions \type {high}, \type {middle}, \type {low},
127either or not in combination with \type {left}, \type {right}, \type
128{leftmargin}, \type {rightmargin}, {lefthanging} or \type {righthanging}.
129
130The next series of examples shows the regular (non||side) floats.
131
132\startbuffer
133\setupcaption
134  [figure]
135  [location={high,left}]
136\placefigure
137  {}{\externalfigure[dummy][lines=2,width=4cm]}
138\stopbuffer
139
140\typebuffer \getbuffer
141
142\startbuffer
143\setupcaption
144  [figure]
145  [width=4cm,align=flushright,location={high,left}]
146\placefigure
147  {}{\externalfigure[dummy][lines=2,width=4cm]}
148\stopbuffer
149
150\typebuffer \getbuffer
151
152\startbuffer
153\setupcaption
154  [figure]
155  [width=4cm,align=flushright,location={middle,left}]
156\placefigure
157  {}{\externalfigure[dummy][lines=2,width=4cm]}
158\stopbuffer
159
160\typebuffer \getbuffer
161
162\startbuffer
163\setupcaption
164  [figure]
165  [width=4cm,align=flushright,location={low,left}]
166\placefigure
167  {}{\externalfigure[dummy][lines=2,width=4cm]}
168\stopbuffer
169
170\startbuffer
171\setupfloat
172  [figure]
173  [location=right]
174\setupcaption
175  [figure]
176  [width=4cm,align=flushright,location=high]
177\placefigure
178  {}{\externalfigure[dummy][lines=2,width=4cm]}
179\stopbuffer
180
181\typebuffer \getbuffer
182
183\startbuffer
184\setupfloat
185  [figure]
186  [location=right]
187\setupcaption
188  [figure]
189  [width=4cm,align=flushright,location={high,left}]
190\placefigure
191  {}{\externalfigure[dummy][lines=2,width=4cm]}
192
193\setupfloat
194  [figure]
195  [location=left]
196\setupcaption
197  [figure]
198  [width=4cm,align=flushleft, location={high,left}]
199\placefigure
200  {}{\externalfigure[dummy][lines=2,width=4cm]}
201\stopbuffer
202
203\typebuffer \getbuffer
204
205\startbuffer
206\setupfloat
207  [figure]
208  [location=middle]
209\setupcaption
210  [figure]
211  [width=4cm,align=flushright, location={high,lefthanging}]
212\placefigure
213  {}{\externalfigure[dummy][lines=2,width=4cm]}
214\stopbuffer
215
216\typebuffer \getbuffer
217
218\startbuffer
219\setupfloat
220  [figure]
221  [location=middle]
222\setupcaption
223  [figure]
224  [width=4cm,align=flushleft,  location={high,righthanging}]
225\placefigure
226  {}{\externalfigure[dummy][lines=2,width=4cm]}
227\stopbuffer
228
229\typebuffer \getbuffer
230
231\startbuffer
232\setupfloat
233  [figure]
234  [location=right]
235\setupcaption
236  [figure]
237  [width=4cm,align=flushleft, location={high,rightmargin}]
238\placefigure
239  {}{\externalfigure[dummy][lines=2,width=4cm]}
240\stopbuffer
241
242\typebuffer \getbuffer
243
244\startbuffer
245\setupfloat
246  [figure]
247  [location=left]
248\setupcaption
249  [figure]
250  [width=4cm,align=flushright,location={high,leftmargin}]
251\placefigure
252  {}{\externalfigure[dummy][lines=2,width=4cm]}
253\stopbuffer
254
255\typebuffer \getbuffer
256
257\startbuffer
258\setupfloat
259  [figure]
260  [location=middle]
261\setupcaption
262  [figure]
263  [width=4cm,align=flushright,location={high,outermargin}]
264\placefigure
265  {}{\externalfigure[dummy][lines=2,width=4cm]}
266\stopbuffer
267
268\typebuffer \getbuffer
269
270\startbuffer
271\setupfloat
272  [figure]
273  [location=middle]
274\setupcaption
275  [figure]
276  [width=4cm,align=flushleft, location={high,innermargin}]
277\placefigure
278  {}{\externalfigure[dummy][lines=2,width=4cm]}
279\stopbuffer
280
281\typebuffer \getbuffer
282
283The \type {innermargin} and \type {outermargin} are special cases. They adapt to
284the kind of page.
285
286\page \stop
287
288\stopchapter
289
290\stopcomponent
291