ma-cb-en-figures.tex /size: 7276 b    last modification: 2020-07-01 14:35
1\startcomponent ma-cb-en-figures
2
3\enablemode[**en-us]
4
5\project ma-cb
6
7\startchapter[reference=figures,title=Figures]
8
9\index{figure}
10\seeindex{picture}{figure}
11\index{floating blocks}
12
13\Command{\tex{placefigure}}
14\Command{\tex{startfiguretext}}
15\Command{\tex{setupfigures}}
16\Command{\tex{startcombination}}
17\Command{\tex{setupfloats}}
18\Command{\tex{setupcaptions}}
19\Command{\tex{externalfigure}}
20
21Images can be placed in your document with the command \type{\externalfigure}.
22
23\startbuffer
24\externalfigure
25  [cow.pdf]
26  [width=.1\textwidth,
27   frame=on,
28   framecolor=gray,
29   frameoffset=3pt,
30   rulethickness=3pt,
31   framecorner=round]
32\stopbuffer
33
34\typebuffer
35
36Such an image will be placed on the location where you defined it \space \getbuffer
37\space and can have some strange effects on the surrounding white space. By the way,
38the cow image is always available for \CONTEXT\ users which is very convenient when
39you are testing the figure related commands.
40
41You can use the command \type{\placefigure} to influence the positioning of
42images in your document.
43
44\startbuffer
45\placefigure
46   [][fig:church]
47   {Stephanus Church.}
48   {\externalfigure[ma-cb-24][width=.4\textwidth]}
49\stopbuffer
50
51\typebuffer
52
53After processing this will come out as \in{figure}[fig:church] at the first
54available location.
55
56\getbuffer
57
58The command \type{\placefigure} handles numbering and vertical spacing before and
59after your figure. Furthermore this command initializes a float mechanism, which
60means that \CONTEXT\ looks whether there is enough space for your figure on the
61page. If not, the figure will be placed at another location and the text carries
62on, while the figure floats in your document until the optimal location is found.
63You can influence this mechanism within the first bracket
64pair.
65
66The command \type{\placefigure} is a predefined example of:
67
68\shortsetup{placefloat}
69
70A number of basic options is described in \in{table}[tab:placefigure].
71
72\placetable
73  [here]
74  [tab:placefigure]
75  {Options in \type{\placefigure}.}
76\starttable[|l|l|]
77\HL
78\NC \bf Option \NC \bf Meaning                             \NC\SR
79\HL
80\NC here       \NC put figure at this location if possible \NC\FR
81\NC force      \NC force figure placement here             \NC\MR
82\NC page       \NC put figure on its own page              \NC\MR
83\NC top        \NC put the figure at the top of the page   \NC\MR
84\NC bottom     \NC put the figure at the botom of the page \NC\MR
85\NC left       \NC place figure at the left margin         \NC\MR
86\NC right      \NC place figure at the right margin        \NC\MR
87\NC margin     \NC place figure in the margin              \NC\MR
88\NC none       \NC set no caption                          \NC\LR
89\HL
90\stoptable
91
92The second bracket pair is used for cross-referencing. You can refer to this
93particular figure by typing:
94
95\starttyping
96\in{figure}[fig:church]
97\stoptyping
98
99The first brace pair is used for the caption. You can type any text you want. The
100figure labels are set up with \type{\setupcaptions} and the numbering is (re)set
101by \type{\setupnumbering} (see \in{paragraph}[floatingblocks]).
102
103The second brace pair is used for defining the figure and addressing the file
104names of external figures.
105
106In the next example you see how \inframed{Hasselt} is defined within
107the last brace pair to show you the function of \type{\placefigure{}{}}.
108
109\startbuffer
110\placefigure
111  {The boundaries of Hasselt.}
112  {\framed{\tfd Hasselt}}
113\stopbuffer
114
115\typebuffer
116
117This will produce:
118
119\getbuffer
120
121However, your images are often created using programs like Illustrator and photos
122are --- after scanning --- improved in packages like PhotoShop. Then the images
123are available as files. \CONTEXT\ supports image file types like \type {JPG},
124\type {PNG} and (pages from) \type {PDF} files as well as \METAPOST\ output
125(\type {MPS} files). Users normally can trust \CONTEXT\ to find the best possible
126file type.
127
128In \in{figure}[fig:canals] you see a photo and a graphic combined into one
129figure.
130
131\startbuffer
132\placefigure
133  [here,force]
134  [fig:canals]
135  {The Hasselt Canals.}
136  {\startcombination[2*1]
137    {\externalfigure[ma-cb-03][width=.4\textwidth]}{a bitmap picture}
138    {\externalfigure[ma-cb-00][width=.4\textwidth]}{a vector graphic}
139   \stopcombination}
140\stopbuffer
141
142\getbuffer
143
144You can produce this figure by typing something like:
145
146\typebuffer
147
148In this figure two pictures are combined with:
149
150\shortsetup{startcombination}
151
152The \type{\start ...\stopcombination} pair is used for
153combining two pictures in one figure. You can type the number of pictures within
154the bracket pair. If you want to display one picture below the other you would
155have typed \type{[1*2]}. You can imagine what happens when you combine 6~pictures
156as \type{[3*2]} (\type{[rows*columns]}).
157
158The examples shown above are enough for creating illustrated documents. Sometimes
159however you want a more integrated layout of the picture and the text. For that
160purpose you can use \type{\start ...\stopfiguretext} command pair.
161
162\startbuffer
163\startfiguretext
164  [left,none]
165  [fig:citizens]
166  {}
167  {\externalfigure[ma-cb-18][width=.5\makeupwidth]}
168   Hasselt has always had a varying number of citizens due to
169   economic events. For example the Dedemsvaart was dug around
170   1810. This canal runs through Hasselt and therefore trade
171   flourished. This led to a population growth of almost 40\%
172   within 10~years. Nowadays the Dedemsvaart has no commercial
173   value anymore and the canals have become a tourist
174   attraction. But reminders of these prosperous times can be
175   found everywhere.
176\stopfiguretext
177\stopbuffer
178
179The effect of:
180
181\typebuffer
182
183is shown in the figure below.
184
185\start
186\setuptolerance[verytolerant]
187\getbuffer
188\stop
189
190
191\startbuffer[marginpicture]
192\inmargin
193  {\externalfigure
194     [ma-cb-23]
195     [width=.7\marginwidth]}
196\stopbuffer
197
198As you have seen you in the examples above you can summon a figure with the
199command:
200
201\shortsetup{externalfigure}
202
203The command \type{\externalfigure} has two bracket pairs. The first is used for
204the exact file name without extension, the second for file formats and
205dimensions. It is not difficult to guess what happens if you
206type:\getbuffer[marginpicture]
207
208\typebuffer[marginpicture]
209
210You can set up the layout of figures with:
211
212\shortsetup{setupfloats}
213
214You can set up the numbering and the labels with:
215
216\shortsetup{setupcaptions}
217
218\startbuffer[figuresetups]
219\setupfloat
220  [figure]
221  [default=right,
222   spacebefore=none]
223
224\setupcaptions
225  [location=bottom,
226   style=boldslanted]
227\stopbuffer
228
229\startbuffer[figuredefinition]
230\placefigure
231  {A characteristic view on Hasselt.}
232  {\externalfigure[ma-cb-12][width=6cm]}
233\stopbuffer
234
235\start
236\getbuffer[figuresetups]
237\getbuffer[figuredefinition]
238\stop
239
240These commands are typed in the set up area of your input file and have a global
241effect on all floating blocks.
242
243\typebuffer[figuresetups,figuredefinition]
244
245For figure management there are commands like \crlf
246\type{\setupexternalfigure}.
247
248Please refer to the \goto {\CONTEXTWIKI} [
249url(http://wiki.contextgarden.net/Command/defineexternalfigure) ] for practical
250applications of these commands.
251
252If you want to work with a \XML\ based figure database please see the \goto
253{Figures} [ url (manual:figures) ]
254manual.
255
256\stopchapter
257
258\stopcomponent
259