details-gridtrickery.tex /size: 7085 b    last modification: 2023-12-21 09:43
1% language=us
2
3\environment details-environment
4
5\startcomponent details-gridtrickery
6
7\startchapter[title={Grid trickery}]
8
9In this manual we pay quite some words on ways to snap your content on a grid.
10When dealing with grids, we often run into conflicting situations where we have
11to make the best of it. Let's again deal with an aspect of graphics.
12
13One of the strong points of \TEX\ is that it can deal with graphics
14automatically, which means that you seldom have to tweak dimensions or placements
15unless \unknown\ you're dealing with grids. In that case you need to make sure
16that the height of graphics consistently match the height of lines (or multiples
17of lines). It is for this purpose that the graphic inclusion macro has a \type
18{grid} entry.
19
20We will illustrate its usage using a dedicated figure class where we have set the
21space between figure and caption to zero.
22
23\startbuffer
24\definefloat[tightfigure][tightfigures][figure]
25\setupcaption[tightfigure][inbetween=]
26\stopbuffer
27
28\typebuffer \getbuffer
29
30The \type {grid} parameter controls rounding of the height of a graphic in the
31following way:
32
33\starttabulate
34
35\NC \type {yes}    \NC safe rounding to an equal number of lines        \NC \NR
36\NC \type {fit}    \NC tight rounding to an equal number of lines       \NC \NR
37\NC \type {height} \NC same as \type {yes} but incremented by linedepth \NC \NR
38\stoptabulate
39
40On the next pages we demonstrate the effects of these settings. At the bottom of
41a page we show the placement commands. On the last pages we've hidden the
42captions with:
43
44\starttyping
45\setupfloat[tightfigure][default={here,none}]
46\stoptyping
47
48As you will notice, the \type {height} option is handy when the caption is
49positioned directly under the graphic.
50
51\start \page
52
53\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=yes]}
54\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=yes]}
55\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=yes]}
56\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=yes]}
57\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=yes]}
58\fakewords{20}{30}
59
60\starttyping
61\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=yes]}
62\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=yes]}
63\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=yes]}
64\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=yes]}
65\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=yes]}
66\stoptyping
67
68\page
69
70\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=fit]}
71\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=fit]}
72\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=fit]}
73\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=fit]}
74\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=fit]}
75\fakewords{20}{30}
76
77\starttyping
78\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=fit]}
79\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=fit]}
80\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=fit]}
81\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=fit]}
82\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=fit]}
83\stoptyping
84
85\page
86
87\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=height]}
88\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=height]}
89\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=height]}
90\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=height]}
91\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=height]}
92\fakewords{20}{30}
93
94\starttyping
95\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=height]}
96\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=height]}
97\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=height]}
98\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=height]}
99\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=height]}
100\stoptyping
101
102\page
103
104\setupfloat[tightfigure][default={here,none}]
105
106\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=yes]}
107\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=yes]}
108\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=yes]}
109\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=yes]}
110\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=yes]}
111\fakewords{20}{30}
112
113\starttyping
114\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=yes]}
115\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=yes]}
116\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=yes]}
117\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=yes]}
118\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=yes]}
119\stoptyping
120
121\page
122
123\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=fit]}
124\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=fit]}
125\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=fit]}
126\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=fit]}
127\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=fit]}
128\fakewords{20}{30}
129
130\starttyping
131\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=fit]}
132\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=fit]}
133\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=fit]}
134\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=fit]}
135\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=fit]}
136\stoptyping
137
138\page
139
140\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=height]}
141\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=height]}
142\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=height]}
143\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=height]}
144\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=height]}
145\fakewords{20}{30}
146
147\starttyping
148\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=height]}
149\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=height]}
150\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=height]}
151\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=height]}
152\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=height]}
153\stoptyping
154
155\page \stop
156
157\stopchapter
158
159\page
160
161\stopcomponent
162