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