summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/publications/publications-otheruse.tex
blob: 43b21d9a5f39764106a49b0dbbcb9e2e4f7dbef0 (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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
\environment publications-style

\startcomponent publications-otheruse

\startchapter
   [reference=ch:duane,
    title=Other use of datasets]

Because a bibliography is just a kind of database, you can use the publications
mechanism for other purposes as well.

\startsection
    [title=Images]

During the re|-|implementation \name {Miklavec}{M.}Mojca came up with the
following definitions:

\startbuffer
\startbuffer[duane]
@IMAGE {tug2013,
    title       = "TUG 2013",
    url         = "http://tug.org/tug2013/",
    url_image   = "http://tug.org/tug2013/tug2013-color-300.jpg",
    url_thumb   = "http://tug.org/tug2013/t2013-thumb.jpg",
    description = "Official drawing of the TUG 2013 conference",
    author      = "Duane Bibby",
    year        = 2013,
    copyright   = "TUG",
}

@IMAGE {tug2014,
    title       = "TUG 2014",
    url         = "http://tug.org/tug2014/",
    url_image   = "http://tug.org/art/tug2014-color.jpg",
    url_thumb   = "http://tug.org/tug2014/t2014-thumb.jpg",
    description = "Official drawing of the TUG 2014 conference",
    author      = "Duane Bibby",
    year        = 2014,
    copyright   = "TUG",
}
\stopbuffer
\stopbuffer

\typeBTXbuffer \name{Bibby}{D.}\getbuffer

For documentation purposes we can have a definition in a buffer so that we can
show it verbatim but also load it. The following code defines a dataset, loads
the buffer and sets up a rendering.

\startbuffer
\definebtxdataset
  [duane]

\usebtxdataset
  [duane]
  [duane.buffer]

\definebtx
  [duane]
  [default=,
   specification=duane,
   authorconversion=normal]

\definebtx
  [duane:list]
  [duane]

\definebtx
  [duane:list:author]
  [duane:list]

\definebtx
  [duane:list:image]
  [duane:list]

\definebtxrendering
  [duane]
  [specification=duane,
   group=duane, % so not: group=default,
   dataset=duane,
   method=dataset,
   numbering=no,
   criterium=all]

\stopbuffer

\cindex{definebtxdataset}
\cindex{usebtxdataset}
\cindex{definebtx}
\cindex{definebtxrendering}

\typeTEXbuffer \getbuffer

Instead of for instance \TEXcode {apa} we create a specification named \TEXcode
{duane}. Because categories are rendered with a setup, we can define the
following:

\startbuffer
\startsetups btx:duane:list:image
  \tbox \bgroup
    \bTABLE[offset=1ex]
      \bTR
        \bTD[ny=4]
          \dontleavehmode
          \externalfigure[\btxflush{url_thumb}][width=3cm]
        \eTD
        \bTD \btxflush{title} \eTD
      \eTR
      \bTR
        \bTD \btxflush{author} \eTD
      \eTR
      \bTR
        \bTD \btxflush{description} \eTD
      \eTR
      \bTR
        \bTD
          \goto{high res variant}[url(\btxflush{url_image})]
        \eTD
      \eTR
    \eTABLE
  \egroup
\stopsetups

\placebtxrendering[duane][criterium=all]
\stopbuffer

\cindex{startsetups}
\cindex{stopsetups}
\cindex{placebtxrendering}
\cindex{btxflush}

\typeTEXbuffer \getbuffer

An alternative rendering is:

\startbuffer
\startsetups btx:duane:list:image
  \bgroup
    \bTABLE[offset=1ex]
      \bTR
        \bTD
          \dontleavehmode
          \goto{\externalfigure[\btxflush{url_thumb}][width=3cm]}
            [url(\btxflush{url_image})]
        \eTD
        \bTD
          \bold{\btxflush{title}}
          \blank
          \btxflush{description}
          \blank [3*line]
          \btxflush{author}
        \eTD
      \eTR
    \eTABLE
  \egroup
\stopsetups

\placebtxrendering[duane]
\stopbuffer

\cindex{startsetups}
\cindex{stopsetups}
\cindex{placebtxrendering}
\cindex{btxflush}

\typeTEXbuffer \getbuffer

We only get the second rendering because we specified \TEXcode {criterium} as
\TEXcode {all}. Future version of \CONTEXT\ will probably provide \Index{sorting}
options and ways to plug in additional functionality.

\stopsection

\startsection
    [title=Chemistry]

To give further ideas on how the \quote {publications} database system can be
effectively used in a document, consider any object such as an image (as seen
above), an equation, a chemical compound, or other entity having various
properties and that might be used repeatedly. Here we will give an almost
realistic example of a dataset containing various chemical compounds.

Like above, we shall define a named dataset and load it with definitions having
nothing to do with publications, rather a number of chemical compounds of
formula \chemical {C_6H_6O} (there are some 57 such molecules).

\startbuffer
\definebtxdataset
  [chemistry]

\usebtxdataset
  [chemistry]
  [C6H6O.bib]
\stopbuffer

\cindex{definebtxdataset}
\cindex{usebtxdataset}
\typebuffer [option=TEX]
\getbuffer

We can visualize the contents of the dataset using, for example:

\startbuffer
\showbtxdatasetcompleteness
  [dataset=chemistry,
   specification=chemistry]
\stopbuffer

\cindex{showbtxdatasetcompleteness}
\typebuffer [option=TEX]

Note that the specification \quote {chemistry} is undefined (as yet) so the log file shows:

\starttyping
publications    > no data definition file 'publ-imp-chemistry.lua' for 'chemistry'
\stoptyping

This is harmless as a missing (lua) definition file makes \emphasis {all} data categories and fields
\quote {optional}, allowing their access and use.

The dataset (containing just 4 of the 57 entries) is:

\startparagraph [style=small]
\getbuffer
\stopparagraph

The next step is to activate the specification and dataset and to define a list rendering, as
follows:

\startbuffer
\setupbtx
  [specification=chemistry,
   dataset=chemistry]

\definebtxrendering
  [chemistry]
  [specification=chemistry,
   group=chemistry,
   dataset=chemistry]
\stopbuffer

\cindex{setupbtx}
\cindex{definebtxrendering}
\typebuffer [option=TEX]
\getbuffer

This list rendering can then be placed, but first one needs to create a setup
describing how to handle the entry (or category) \type {@chemical{}} contained
in the file \type {C6H6O.bib}. As in the earlier example, we shall use a table
structure for the list text:

\startbuffer
\startsetups btx:chemistry:list:chemical
  \startframed [frame=off,location=middle]
  \bTABLE [frame=off]
    \bTR
      \bTD [width=.2\textwidth,ny=2]
        \goto
        {\startchemical [scale=small]
           \chemical [\btxflush{chemical}]
         \stopchemical} [program(\btxflush{rendered})]
      \eTD
      \bTD [width=.2\textwidth] \chemical{\btxflush{formula}} \eTD
      \bTD [width=.4\textwidth] \btxflush{iupac} \eTD
    \eTR
    \bTR
      \bTD \btxflush{mw}~g/mole \eTD
      \bTD \btxflush{cas} \eTD
    \eTR
  \eTABLE
  \stopframed
\stopsetups

\placebtxrendering [method=dataset]
\stopbuffer

\cindex{startsetups}
\cindex{stopsetups}
\typebuffer [option=TEX]

Note that not all fields of the dataset are used.

\getbuffer

The real usefulness of the dataset is the possibility of referring to entries
and the ability to extract data fields. Setups can be defined for those fields
requiring any formatting beyond a simple flushing, for example those requiring
the \Cindex {chemical} command.

\startbuffer
\startsetups btx:chemistry:cite:formula
  \chemical {\currentbtxfirst}
\stopsetups

\startsetups btx:chemistry:cite:chemical
  \startchemical [scale=600]
    \chemical [\currentbtxfirst]
  \stopchemical
\stopsetups

\cite [name]        [108-95-2] |<|or|>|
\cite [formula]     [108-95-2] |<|or|>|
\cite [chemical]    [108-95-2] |<|or|>|
\cite [molarvolume] [108-95-2]
\stopbuffer

\cindex{startsetups}
\cindex{stopsetups}
\cindex{cite}
\typebuffer [option=TEX]
\getbuffer

\startbuffer
\cite [name]        [566-33-5] |<|or|>|
\cite [formula]     [566-33-5] |<|or|>|
\cite [chemical]    [566-33-5] |<|or|>|
\cite [molarvolume] [566-33-5]
\stopbuffer

\cindex{cite}
\typebuffer [option=TEX]
\getbuffer

\stopsection

\stopchapter

\stopcomponent