1\pushoverloadmode
2
3\environment publicationsstyle
4
5\startcomponent publicationsotheruse
6
7\startchapter
8 [reference=ch:duane,
9 title=Other use of datasets]
10
11Because a bibliography is just a kind of database, you can use the publications
12mechanism for other purposes as well.
13
14\startsection
15 [title=Images]
16
17During the reimplementation \name {Miklavec}{M.}Mojca came up with the
18following definitions:
19
20\startbuffer
21\startbuffer[duane]
22@IMAGE {tug2013,
23 title = "TUG 2013",
24 url = "https:tug.orgtug2013",
25 urlimage = "https:tug.orgtug2013tug2013color300.jpg",
26 urlthumb = "https:tug.orgtug2013t2013thumb.jpg",
27 description = "Official drawing of the TUG 2013 conference",
28 author = "Duane Bibby",
29 year = 2013,
30 copyright = "TUG",
31}
32
33@IMAGE {tug2014,
34 title = "TUG 2014",
35 url = "https:tug.orgtug2014",
36 urlimage = "https:tug.orgarttug2014color.jpg",
37 urlthumb = "https:tug.orgtug2014t2014thumb.jpg",
38 description = "Official drawing of the TUG 2014 conference",
39 author = "Duane Bibby",
40 year = 2014,
41 copyright = "TUG",
42}
43\stopbuffer
44\stopbuffer
45
46\typeBTXbuffer \name{Bibby}{D.}\getbuffer
47
48For documentation purposes we can have a definition in a buffer so that we can
49show it verbatim but also load it. The following code defines a dataset, loads
50the buffer and sets up a rendering.
51
52\startbuffer
53\definebtxdataset
54 [duane]
55
56\usebtxdataset
57 [duane]
58 [duane.buffer]
59
60\definebtx
61 [duane]
62 [default=,
63 specification=duane,
64 authorconversion=normal]
65
66\definebtx
67 [duane:list]
68 [duane]
69
70\definebtx
71 [duane:list:author]
72 [duane:list]
73
74\definebtx
75 [duane:list:image]
76 [duane:list]
77
78\definebtxrendering
79 [duane]
80 [specification=duane,
81 group=duane,
82 dataset=duane,
83 method=dataset,
84 numbering=no,
85 criterium=all]
86\stopbuffer
87
88\cindex{definebtxdataset}
89\cindex{usebtxdataset}
90\cindex{definebtx}
91\cindex{definebtxrendering}
92
93\typeTEXbuffer \getbuffer
94
95Instead of for instance \TEXcode {apa} we create a specification named \TEXcode
96{duane}. Because categories are rendered with a setup, we can define the
97following:
98
99\startbuffer
100\startsetups btx:duane:list:image
101 \tbox \bgroup
102 \bTABLE[offset=1ex]
103 \bTR
104 \bTD[ny=4]
105 \dontleavehmode
106 \externalfigure[\btxflush{urlthumb}][width=3cm]
107 \eTD
108 \bTD \btxflush{title} \eTD
109 \eTR
110 \bTR
111 \bTD \btxflush{author} \eTD
112 \eTR
113 \bTR
114 \bTD \btxflush{description} \eTD
115 \eTR
116 \bTR
117 \bTD
118 \goto{high res variant}[url(\btxflush{urlimage})]
119 \eTD
120 \eTR
121 \eTABLE
122 \egroup
123\stopsetups
124
125\placebtxrendering[duane][criterium=all]
126\stopbuffer
127
128\cindex{startsetups}
129\cindex{stopsetups}
130\cindex{placebtxrendering}
131\cindex{btxflush}
132
133\typeTEXbuffer \getbuffer
134
135An alternative rendering is:
136
137\startbuffer
138\startsetups btx:duane:list:image
139 \bgroup
140 \bTABLE[offset=1ex]
141 \bTR
142 \bTD
143 \dontleavehmode
144 \goto{\externalfigure[\btxflush{urlthumb}][width=3cm]}
145 [url(\btxflush{urlimage})]
146 \eTD
147 \bTD
148 \bold{\btxflush{title}}
149 \blank
150 \btxflush{description}
151 \blank [3*line]
152 \btxflush{author}
153 \eTD
154 \eTR
155 \eTABLE
156 \egroup
157\stopsetups
158
159\placebtxrendering[duane]
160\stopbuffer
161
162\cindex{startsetups}
163\cindex{stopsetups}
164\cindex{placebtxrendering}
165\cindex{btxflush}
166
167\typeTEXbuffer \getbuffer
168
169We only get the second rendering because we specified \TEXcode {criterium} as
170\TEXcode {all}. Future version of \CONTEXT\ will probably provide \Index{sorting}
171options and ways to plug in additional functionality.
172
173\stopsection
174
175\startsection
176 [title=Chemistry]
177
178To give further ideas on how the \quote {publications} database system can be
179effectively used in a document, consider any object such as an image (as seen
180above), an equation, a chemical compound, or other entity having various
181properties and that might be used repeatedly. Here we will give an almost
182realistic example of a dataset containing various chemical compounds.
183
184Like above, we shall define a named dataset and load it with definitions having
185nothing to do with publications, rather a number of chemical compounds of
186formula \chemical {C6H6O} (there are some 57 such molecules).
187
188\startbuffer
189\definebtxdataset
190 [chemistry]
191
192\usebtxdataset
193 [chemistry]
194 [C6H6O.bib]
195\stopbuffer
196
197\cindex{definebtxdataset}
198\cindex{usebtxdataset}
199\typebuffer [option=TEX]
200\getbuffer
201
202We can visualize the contents of the dataset using, for example:
203
204\startbuffer
205\showbtxdatasetcompleteness
206 [dataset=chemistry,
207 specification=chemistry]
208\stopbuffer
209
210\cindex{showbtxdatasetcompleteness}
211\typebuffer [option=TEX]
212
213Note that the specification \quote {chemistry} is undefined (as yet) so the log file shows:
214
215\starttyping
216publications > no data definition file publimpchemistry.lua for chemistry
217\stoptyping
218
219This is harmless as a missing (lua) definition file makes \emphasis {all} data categories and fields
220\quote {optional}, allowing their access and use.
221
222The dataset (containing just 4 of the 57 entries) is:
223
224\startparagraph [style=small]
225\getbuffer
226\stopparagraph
227
228The next step is to activate the specification and dataset and to define a list rendering, as
229follows:
230
231\startbuffer
232\setupbtx
233 [specification=chemistry,
234 dataset=chemistry]
235
236\definebtxrendering
237 [chemistry]
238 [specification=chemistry,
239 group=chemistry,
240 dataset=chemistry]
241\stopbuffer
242
243\cindex{setupbtx}
244\cindex{definebtxrendering}
245\typebuffer [option=TEX]
246\getbuffer
247
248This list rendering can then be placed, but first one needs to create a setup
249describing how to handle the entry (or category) \type {@chemical{}} contained
250in the file \type {C6H6O.bib}. As in the earlier example, we shall use a table
251structure for the list text:
252
253\startbuffer
254\startsetups btx:chemistry:list:chemical
255 \startframed [frame=off,location=middle]
256 \bTABLE [frame=off]
257 \bTR
258 \bTD [width=.2\textwidth,ny=2]
259 \goto
260 {\startchemical [scale=small]
261 \chemical [\btxflush{chemical}]
262 \stopchemical} [program(\btxflush{rendered})]
263 \eTD
264 \bTD [width=.2\textwidth] \chemical{\btxflush{formula}} \eTD
265 \bTD [width=.4\textwidth] \btxflush{iupac} \eTD
266 \eTR
267 \bTR
268 \bTD \btxflush{mw}gmole \eTD
269 \bTD \btxflush{cas} \eTD
270 \eTR
271 \eTABLE
272 \stopframed
273\stopsetups
274
275\placebtxrendering [method=dataset]
276\stopbuffer
277
278\cindex{startsetups}
279\cindex{stopsetups}
280\typebuffer [option=TEX]
281
282Note that not all fields of the dataset are used.
283
284\getbuffer
285
286The real usefulness of the dataset is the possibility of referring to entries
287and the ability to extract data fields. Setups can be defined for those fields
288requiring any formatting beyond a simple flushing, for example those requiring
289the \Cindex {chemical} command.
290
291\startbuffer
292\startsetups btx:chemistry:cite:formula
293 \chemical {\currentbtxfirst}
294\stopsetups
295
296\startsetups btx:chemistry:cite:chemical
297 \startchemical [scale=600]
298 \chemical [\currentbtxfirst]
299 \stopchemical
300\stopsetups
301
302\cite [name] [108952] <or>
303\cite [formula] [108952] <or>
304\cite [chemical] [108952] <or>
305\cite [molarvolume] [108952]
306\stopbuffer
307
308\cindex{startsetups}
309\cindex{stopsetups}
310\cindex{cite}
311\typebuffer [option=TEX]
312\getbuffer
313
314\startbuffer
315\cite [name] [566335] <or>
316\cite [formula] [566335] <or>
317\cite [chemical] [566335] <or>
318\cite [molarvolume] [566335]
319\stopbuffer
320
321\cindex{cite}
322\typebuffer [option=TEX]
323\getbuffer
324
325\stopsection
326
327\startsection[title=\METAPOST]
328
329Because its a variant on previous examples, we just show the whole set
330of definitions and the result.
331
332\startbuffer
333\startbuffer[sample]
334\startMPpage
335 fill fullcircle scaled 4cm withcolor "darkgreen";
336\stopMPpage
337\stopbuffer
338
339\savebuffer[list={sample},file={metafunsample2.tex},prefix=]
340
341\startbuffer[samples]
342@IMAGE {sample1,
343 title = "sample1",
344 author = "My Self",
345 mpcode = {fill fullcircle scaled 4cm withcolor "darkblue";}
346}
347
348@IMAGE {sample2,
349 title = "sample2",
350 author = "My Self",
351 mpfile = "metafunsample2.tex"
352}
353\stopbuffer
354
355\definebtxdataset
356 [samples]
357
358\usebtxdataset
359 [samples]
360 [samples.buffer]
361
362\definebtx
363 [samples]
364 [default=,
365 specification=samples]
366
367\definebtx
368 [samples:list:image]
369 [samples:list]
370
371\definebtxrendering
372 [samples]
373 [specification=samples,
374 group=samples,
375 dataset=samples,
376 method=dataset,
377 numbering=no,
378 criterium=all]
379
380\startsetups btx:samples:list:image
381 \tbox \bgroup
382 \bTABLE[offset=1ex]
383 \bTR
384 \bTD[ny=4]
385 \dontleavehmode
386 \doifelsesomething{\btxflush{mpfile}} {
387 \externalfigure[\btxflush{mpfile}]
388 } {
389 \MPcode{
390 \btxflush{mpcode}
391 }
392 }
393 \eTD
394 \bTD
395 \btxflush{title}
396 \eTD
397 \eTR
398 \eTABLE
399 \egroup
400\stopsetups
401
402\placebtxrendering[samples][criterium=all]
403\stopbuffer
404
405\typebuffer[option=TEX]
406
407\getbuffer
408
409\stopsection
410
411\stopchapter
412
413\stopcomponent
414 |