summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/details/details-gridtrickery.tex
blob: f37c7bd4bbb908462b99fa922c44282d5e041af3 (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
% language=uk

\environment details-environment

\startcomponent details-gridtrickery

\startchapter[title={Grid trickery}]

In this manual we pay quite some words on ways to snap your content on a grid.
When dealing with grids, we often run into conflicting situations where we have
to make the best of it. Let's again deal with an aspect of graphics.

One of the strong points of \TEX\ is that it can deal with graphics
automatically, which means that you seldom have to tweak dimensions or placements
unless \unknown\ you're dealing with grids. In that case you need to make sure
that the height of graphics consistently match the height of lines (or multiples
of lines). It is for this purpose that the graphic inclusion macro has a \type
{grid} entry.

We will illustrate its usage using a dedicated figure class where we have set the
space between figure and caption to zero.

\startbuffer
\definefloat[tightfigure][tightfigures][figure]
\setupcaption[tightfigure][inbetween=]
\stopbuffer

\typebuffer \getbuffer

The \type {grid} parameter controls rounding of the height of a graphic in the
following way:

\starttabulate

\NC \type {yes}    \NC safe rounding to an equal number of lines        \NC \NR
\NC \type {fit}    \NC tight rounding to an equal number of lines       \NC \NR
\NC \type {height} \NC same as \type {yes} but incremented by linedepth \NC \NR
\stoptabulate

On the next pages we demonstrate the effects of these settings. At the bottom of
a page we show the placement commands. On the last pages we've hidden the
captions with:

\starttyping
\setupfloat[tightfigure][default={here,none}]
\stoptyping

As you will notice, the \type {height} option is handy when the caption is
positioned directly under the graphic.

\start \page

\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=yes]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=yes]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=yes]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=yes]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=yes]}
\fakewords{20}{30}

\starttyping
\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=yes]}
\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=yes]}
\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=yes]}
\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=yes]}
\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=yes]}
\stoptyping

\page

\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=fit]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=fit]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=fit]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=fit]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=fit]}
\fakewords{20}{30}

\starttyping
\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=fit]}
\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=fit]}
\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=fit]}
\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=fit]}
\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=fit]}
\stoptyping

\page

\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=height]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=height]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=height]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=height]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=height]}
\fakewords{20}{30}

\starttyping
\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=height]}
\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=height]}
\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=height]}
\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=height]}
\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=height]}
\stoptyping

\page

\setupfloat[tightfigure][default={here,none}]

\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=yes]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=yes]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=yes]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=yes]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=yes]}
\fakewords{20}{30}

\starttyping
\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=yes]}
\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=yes]}
\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=yes]}
\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=yes]}
\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=yes]}
\stoptyping

\page

\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=fit]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=fit]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=fit]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=fit]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=fit]}
\fakewords{20}{30}

\starttyping
\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=fit]}
\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=fit]}
\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=fit]}
\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=fit]}
\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=fit]}
\stoptyping

\page

\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.3,grid=height]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.4,grid=height]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.5,grid=height]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.6,grid=height]}
\fakewords{20}{30} \placetightfigure{}{\externalfigure[dummy][width=.5\hsize,lines=1.7,grid=height]}
\fakewords{20}{30}

\starttyping
\placetightfigure{}{\externalfigure[dummy][lines=1.3,grid=height]}
\placetightfigure{}{\externalfigure[dummy][lines=1.4,grid=height]}
\placetightfigure{}{\externalfigure[dummy][lines=1.5,grid=height]}
\placetightfigure{}{\externalfigure[dummy][lines=1.6,grid=height]}
\placetightfigure{}{\externalfigure[dummy][lines=1.7,grid=height]}
\stoptyping

\page \stop

\stopchapter

\page

\stopcomponent