summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/datatool/samples/sample-dict.tex
blob: fbf327318025efda521e6566dd0aff60e4b51e03 (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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
\documentclass[oneside]{scrbook}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathpazo}

% The low optimize setting won't work for this example
\usepackage[optimize=high]{datagidx}

\usepackage[colorlinks]{hyperref}

% This is an example document that uses datagidx to create a
% sorted dictionary, using datatool to do the sorting.

% Make a database labelled 'index' with the given title

\newgidx{index}{Sample Dictionary Created Using datagidx}

% Define some terms for the dictionary

% First set the default database, so we don't have to keep using the
% "database" key:
\DTLgidxSetDefaultDB{index}

% Add some custom fields

\newtermaddfield{Derivatives}{derivatives}{}

\newtermaddfield{Origin}{origin}{}

\newtermaddfield{Phrases}{phrases}{}

\newtermaddfield{Subject}{subject}{}

\newtermaddfield{Variation}{variation}{}

\newtermaddfield{Phonetic}{phonetic}{}

\newtermaddfield{AltPlural}{altplural}{}

\newtermaddfield{Parenthetical}{parenthetical}{}

% Provide a convenient interface to define words:

% Syntax: \newentry[main option list][cat opt list]{word}{category}{definition}

\newcommand*{\newentry}[1][]{%
  \def\newentryopts{#1}%
  \nnewentry
}

\newcommand*{\nnewentry}[4][]{%
  \expandafter\newterm\expandafter[\newentryopts]{#2}%
  \newterm
  [%
    label={\datagidxlastlabel-#3},%
    parent={\datagidxlastlabel},%
    description={#4},%
    text={#3},%
    #1%
  ]%
  {#3}%
  \setcounter{newentrysubcat}{0}%
}

% Syntax: \newentrycat{parent label}{category}{definition}

\newcommand*{\newentrycat}[3]{%
  \newterm
  [%
    label={#1-#2},%
    parent={#1},%
    description={#3}%
  ]%
  {#2}%
  \setcounter{newentrysubcat}{0}%
}

% Syntax: \newentrysubcat[option list]{parent label}{description}

\newcounter{newentrysubcat}

\newcommand*{\newentrysubcat}[3][]{%
  \stepcounter{newentrysubcat}%
  \newterm
  [%
    label={#2-\arabic{newentrysubcat}},%
    sort={#2-\arabic{newentrysubcat}},%
    parent={#2},%
    description={#3},%
   #1%
  ]
  {}%
}

\newcommand*{\categoryand}{ \& }

% hook into the mechanism that constructs the label and sort fields from
% the name:

\appto\newtermlabelhook{\def\categoryand{+}}

\newcommand*{\namefont}[1]{\textbf{\sffamily #1}}
\newcommand*{\subjectfont}[1]{\textsf{#1}}
\newcommand*{\categoryfont}[1]{\namefont{#1}}
\newcommand*{\originfont}[1]{\emph{#1}}
\newcommand*{\derivativeformat}[2]{\textbf{#1}\space\textsf{#2}}
\newcommand*{\phoneticformat}[1]{/#1/}

\newcommand*{\stress}[1]{\textbf{#1}}

\newcommand*{\crossref}[1]{\textbf{\useentry{#1}{Name}}}
\newcommand*{\Crossref}[1]{\textbf{\textsc{\useentry{#1}{Name}}}}

% Words and their definitions taken from the Compact Oxford English
% Dictionary

% label and sort must both be specified here as \newterm can't cope
% with {\ae} when automatically generating the label and sort from
% the name
\newentry
 [%
   phonetic={ee-\stress{oh}-li-uhn},
   origin={from \originfont{\AE olus}, the Greek god of the winds},
   label=aeolian,
   sort=aeolian
 ]
 {{\ae}olian harp}{noun}{a stringed instrument that produces musical
sounds when a current of air passes through it}

% Similarly label and sort are needed here
\newentry
 [%
   phonetic={i-\stress{sof}-fuh-guhss},
   plural={{œ}sophagi},
   origin={Greek \originfont{oisophagos}},
   label={oesophagus},
   sort={oesophagus}
 ]
 {{œ}sophagus}{noun}{the muscular tube which connects throat to
stomach}

\newentry
 [% additional info
   origin={Old English}
 ]%
 [%
   subject={literary}
 ]
 {asunder}{adverb}{apart}

\newentry
 [% additional info
   origin={Old English},
   parenthetical={\subjectfont{US} \namefont{adz}}
 ]
 {adze}{noun}{a tool similar to an axe, with an arched blade at right angles to
 the handle}

\newentry
 [% additional info
   origin={Latin \originfont{astutus}},
   derivatives={\derivativeformat{astutely}{adverb}
    \derivativeformat{astuteness}{noun}}
 ]
 {astute}{adjective}{good at making accurate judgements; shrewd}

\newentry{astern}{adverb}{behind or towards the rear of a ship}

\newentry{thunderbolt}{noun}{flash of lightning with a crash of
thunder at the same time}

\newentry{thunderclap}{noun}{a crash of thunder}

\newentry
 [%
  origin={Italian \originfont{ticchio}}
 ]
 {tic}{noun}{a recurring spasm of the muscles, most often in
the face}

\newentry
 [%
   phonetic={thwort},
   origin={from Old Norse, `transverse'}
 ]
 {thwart}{verb}{}

\newentrysubcat{thwart-verb}{prevent someone from accomplishing
something}

\newentrysubcat{thwart-verb}{prevent something from succeeding}

\newentrycat{thwart}{noun}{a crosspiece forming a seat for a rower
in a boat}

\newentry
 [% additional info
   origin={from an old sense of \Crossref{thwart}, meaning
`across'},
   phonetic={uh-\stress{thwart}}
 ]
 {athwart}{preposition\categoryand adverb}{from side to side of something;
  across}

\newentry
 [%
   phonetic={aw-\stress{bree}-shuh},
   parenthetical={also \namefont{aubrietia}},
   origin={named after the French botanist Claude \originfont{Aubriet}}
 ]
 {aubretia}{noun}{a trailing plant with purple, pink, or white
flowers}

\newentry
 [%
   phonetic={aw-\stress{day}-shuhss},
   derivatives={\derivativeformat{audaciously}{adverb}
    \derivativeformat{audaciousness}{noun}
    \derivativeformat{audacity}{noun}},
   origin={Latin \originfont{audax} `bold'}
 ]
 {audacious}{adjective}{}

\newentrysubcat{audacious-adjective}{willing to take daring risks}
\newentrysubcat{audacious-adjective}{showing lack of respect; rude
or impudent}

\newentry
 [%
   parenthetical={pl.\ \namefont{attorneys}},
   phonetic={uh-\stress{ter}-ni},
   origin={Old French \originfont{atorner} `assign'}
 ]
 {attorney}{noun}{}

\newentrysubcat{attorney-noun}{a person appointed to act for another
in legal matters}

\newentrysubcat
 [%
   subject={chiefly US}%
 ]
 {attorney-noun}{a lawyer}

\newentry
 [
   phonetic={\stress{ay}-tri-uhm},
   altplural={atria},
   parenthetical={pl.\ \namefont{atria}
    \phoneticformat{\stress{ay}-tri-uh}
    or \namefont{atriums}},
   derivatives={\derivativeformat{atrial}{adjective}},
   origin={Latin}
 ]
 {atrium}{noun}{}

\newentrysubcat{atrium-noun}{a central hall rising through several
storeys and having a glazed roof}

\newentrysubcat{atrium-noun}{an open area in the centre of an
ancient Roman house}

\newentrysubcat{atrium-noun}{each of the two cavities of the heart}

\newentry
 [%
   plural={austerities},
   phonetic={oss-\stress{te}-ri-ti}
 ]
 {austerity}{noun}{}

\newentrysubcat{austerity-noun}{strictness or severity of appearance
or manner}
\newentrysubcat{austerity-noun}{difficult economic conditions
resulting from a cut in public spending}

\newentry
[
  plural={cacti},
  altplural={cactuses},
  origin={Greek \originfont{kaktos} `cardoon'}
]
{cactus}{noun}{a succulent plant with thick fleshy stems bearing
spikes but no leaves}

\newentry
 [%
   phonetic={chahf},
   phrases={\namefont{separate} (or \namefont{sort}) \namefont{the
   wheat from the chaff} distinguish valuable people or things from
   worthless ones},
   origin={Old English}
 ]
 {chaff\textsuperscript{1}}{noun}{}

\newentrysubcat{chaff1-noun}{the husks of grain from the seed by
winnowing or threshing}

\newentrysubcat{chaff1-noun}{chopped hay and straw used in cattle
fodder}

\newentry
 [
   phonetic={chaff},
 ]
 {chaff\textsuperscript{2}}{noun}{light-hearted joking}

\newentrycat{chaff2}{verb}{tease someone}

\newterm
[
  plural={elves},%
  derivatives={\derivativeformat{elfish}{adjective}
   \derivativeformat{elven}{adjective (literary)}
   \derivativeformat{elvish}{adjective}},%
  origin={Old English},%
  description={a supernatural creature of folk tales, represented as
   a small human figure with pointed ears}
]
{elf}

% Be careful of words starting with an accent.

\newterm
 [
   label={elite},%
   phonetic={i-\stress{leet}},%
   origin={French, `selection, choice'}%
 ]
 {{é}lite}

\newentrycat{elite}{noun}{a group of people regarded as the best in a
particular society or organisation}

\newterm
 [
   description={plural of \Crossref{elf}}%
 ]
 {elves}

% Add all entries

\glsaddall{index}

% Customise index format

\renewcommand{\DTLgidxNameFont}[1]{\namefont{\large#1}}

\newcommand{\postnamespace}{\space}

\renewcommand{\DTLgidxPostName}{%
  \ifdefempty\Subject
  {%
  }%
  {%
    \space\subjectfont{\Subject}%
  }%
  \ifdefempty\Phonetic
  {%
  }%
  {%
    \space\phoneticformat{\Phonetic}%
  }%
  \ifdefempty\Parenthetical
  {%
    \ifdefempty\AltPlural
    {%
      \ifthenelse{\equal{\Plural}{\Text s}}%
      {%
      }%
      {%
        \space (pl.\ \namefont{\Plural})%
      }%
    }%
    {%
      \space (pl. \namefont{\Plural} or \namefont{\AltPlural})%
    }%
  }%
  {%
    \space (\Parenthetical)%
  }%
  \postnamespace
}

\renewcommand{\DTLgidxCategoryNameFont}[1]{\categoryfont{#1}}
\renewcommand{\DTLgidxCategorySep}{\space\textbullet\space}
\renewcommand*{\DTLgidxChildCountLabel}{%
 \def\postnamespace{~\def\postnamespace{\space}}%
 \textbf{\sffamily\theDTLgidxChildCount}%
}

\renewcommand{\DTLgidxDictPostItem}{%
  \ifdefempty\Derivatives
  {}
  {%
    \par
    \datagidxdictparshape
    -- \textsc{derivatives} \Derivatives.
  }%
  \ifdefempty\Phrases
  {}
  {%
    \par
    \datagidxdictparshape
    -- \textsc{phrases} \Phrases.
  }%
  \ifdefempty\Origin
  {}
  {%
    \par
    \datagidxdictparshape
    -- \textsc{origin} \Origin.
  }%
  \par
}

\begin{document}

\printterms
[
   database=index,
   postheading={This is an example document illustrating
   the use of the datagidx package. The examples here are taken from
   the Compact Oxford English Dictionary.\medskip
   },
   balance=false,
   columns=2,
   postdesc=dot,%
   childsort=false,% don't sort the child lists
   style={dict} % use the 'dict' style
]

\end{document}