Debian Codegraph @

texmf-dist/doc/latex/datatool/samples/sample-dict.tex

raw
1 \documentclass[oneside]{scrbook}
2
3 \usepackage[T1]{fontenc}
4 \usepackage[utf8]{inputenc}
5 \usepackage{mathpazo}
6
7 % The low optimize setting won't work for this example
8 % Either use high or off
9 \usepackage
10 [
11 locales=en, % requires datatool-english to also be installed
12 % optimize=high,
13 % verbose
14 ]
15 {datagidx}
16
17 \usepackage[colorlinks]{hyperref}
18
19 % This is an example document that uses datagidx to create a
20 % sorted dictionary, using datatool to do the sorting.
21
22 % Make a database labelled 'index' with the given title
23
24 \newgidx{index}{Sample Dictionary Created Using datagidx}
25
26 % Define some terms for the dictionary
27
28 % First set the default database, so we don't have to keep using the
29 % "database" key:
30 \DTLgidxSetDefaultDB{index}
31
32 % Add some custom fields
33
34 \newtermaddfield{Derivatives}{derivatives}{}
35
36 \newtermaddfield{Origin}{origin}{}
37
38 \newtermaddfield{Phrases}{phrases}{}
39
40 \newtermaddfield{Subject}{subject}{}
41
42 \newtermaddfield{Variation}{variation}{}
43
44 \newtermaddfield{Phonetic}{phonetic}{}
45
46 \newtermaddfield{AltPlural}{altplural}{}
47
48 \newtermaddfield{Parenthetical}{parenthetical}{}
49
50 % Provide a convenient interface to define words:
51
52 % Syntax: \newentry[main option list][cat opt list]{word}{category}{definition}
53
54 \newcommand*{\newentry}[1][]{%
55 \def\newentryopts{#1}%
56 \nnewentry
57 }
58
59 \newcommand*{\nnewentry}[4][]{%
60 \expandafter\newterm\expandafter[\newentryopts]{#2}%
61 \newterm
62 [%
63 label={\datagidxlastlabel-#3},%
64 parent={\datagidxlastlabel},%
65 description={#4},%
66 text={#3},%
67 #1%
68 ]%
69 {#3}%
70 \setcounter{newentrysubcat}{0}%
71 }
72
73 % Syntax: \newentrycat{parent label}{category}{definition}
74
75 \newcommand*{\newentrycat}[3]{%
76 \newterm
77 [%
78 label={#1-#2},%
79 parent={#1},%
80 description={#3}%
81 ]%
82 {#2}%
83 \setcounter{newentrysubcat}{0}%
84 }
85
86 % Syntax: \newentrysubcat[option list]{parent label}{description}
87
88 \newcounter{newentrysubcat}
89
90 \newcommand*{\newentrysubcat}[3][]{%
91 \stepcounter{newentrysubcat}%
92 \newterm
93 [%
94 label={#2-\arabic{newentrysubcat}},%
95 sort={#2-\arabic{newentrysubcat}},%
96 parent={#2},%
97 description={#3},%
98 #1%
99 ]
100 {}%
101 }
102
103 \newcommand*{\categoryand}{ \& }
104
105 % hook into the mechanism that constructs the label and sort fields from
106 % the name:
107
108 \appto\newtermlabelhook{\def\categoryand{+}}
109 \appto\newtermsorthook{\def\categoryand{and}}
110
111 \newcommand*{\namefont}[1]{\textbf{\sffamily #1}}
112 \newcommand*{\subjectfont}[1]{\textsf{#1}}
113 \newcommand*{\categoryfont}[1]{\namefont{#1}}
114 \newcommand*{\originfont}[1]{\emph{#1}}
115 \newcommand*{\derivativeformat}[2]{\textbf{#1}\space\textsf{#2}}
116 \newcommand*{\phoneticformat}[1]{/#1/}
117
118 \newcommand*{\stress}[1]{\textbf{#1}}
119
120 \newcommand*{\crossref}[1]{\textbf{\useentry{#1}{Name}}}
121 \newcommand*{\Crossref}[1]{\textbf{\textsc{\useentry{#1}{Name}}}}
122
123 % Words and their definitions taken from the Compact Oxford English
124 % Dictionary
125
126 % label and sort must both be specified here as \newterm can't cope
127 % with {\ae} when automatically generating the label and sort from
128 % the name
129 \newentry
130 [%
131 phonetic={ee-\stress{oh}-li-uhn},
132 origin={from \originfont{\AE olus}, the Greek god of the winds},
133 label=aeolian,
134 sort=aeolian
135 ]
136 {\ae olian harp}{noun}{a stringed instrument that produces musical
137 sounds when a current of air passes through it}
138
139 % Similarly label and sort are needed here
140 \newentry
141 [%
142 phonetic={i-\stress{sof}-fuh-guhss},
143 plural={œsophagi},
144 origin={Greek \originfont{oisophagos}},
145 label={oesophagus},
146 sort={oesophagus}
147 ]
148 {œsophagus}{noun}{the muscular tube which connects throat to
149 stomach}
150
151 \newentry
152 [% additional info
153 origin={Old English}
154 ]%
155 [%
156 subject={literary}
157 ]
158 {asunder}{adverb}{apart}
159
160 \newentry
161 [% additional info
162 origin={Old English},
163 parenthetical={\subjectfont{US} \namefont{adz}}
164 ]
165 {adze}{noun}{a tool similar to an axe, with an arched blade at right angles to
166 the handle}
167
168 \newentry
169 [% additional info
170 origin={Latin \originfont{astutus}},
171 derivatives={\derivativeformat{astutely}{adverb}
172 \derivativeformat{astuteness}{noun}}
173 ]
174 {astute}{adjective}{good at making accurate judgements; shrewd}
175
176 \newentry{astern}{adverb}{behind or towards the rear of a ship}
177
178 \newentry{thunderbolt}{noun}{flash of lightning with a crash of
179 thunder at the same time}
180
181 \newentry{thunderclap}{noun}{a crash of thunder}
182
183 \newentry
184 [%
185 origin={Italian \originfont{ticchio}}
186 ]
187 {tic}{noun}{a recurring spasm of the muscles, most often in
188 the face}
189
190 \newentry
191 [%
192 phonetic={thwort},
193 origin={from Old Norse, `transverse'}
194 ]
195 {thwart}{verb}{}
196
197 \newentrysubcat{thwart-verb}{prevent someone from accomplishing
198 something}
199
200 \newentrysubcat{thwart-verb}{prevent something from succeeding}
201
202 \newentrycat{thwart}{noun}{a crosspiece forming a seat for a rower
203 in a boat}
204
205 \newentry
206 [% additional info
207 origin={from an old sense of \Crossref{thwart}, meaning
208 `across'},
209 phonetic={uh-\stress{thwart}}
210 ]
211 {athwart}{preposition\categoryand adverb}{from side to side of something;
212 across}
213
214 \newentry
215 [%
216 phonetic={aw-\stress{bree}-shuh},
217 parenthetical={also \namefont{aubrietia}},
218 origin={named after the French botanist Claude \originfont{Aubriet}}
219 ]
220 {aubretia}{noun}{a trailing plant with purple, pink, or white
221 flowers}
222
223 \newentry
224 [%
225 phonetic={aw-\stress{day}-shuhss},
226 derivatives={\derivativeformat{audaciously}{adverb}
227 \derivativeformat{audaciousness}{noun}
228 \derivativeformat{audacity}{noun}},
229 origin={Latin \originfont{audax} `bold'}
230 ]
231 {audacious}{adjective}{}
232
233 \newentrysubcat{audacious-adjective}{willing to take daring risks}
234 \newentrysubcat{audacious-adjective}{showing lack of respect; rude
235 or impudent}
236
237 \newentry
238 [%
239 parenthetical={pl.\ \namefont{attorneys}},
240 phonetic={uh-\stress{ter}-ni},
241 origin={Old French \originfont{atorner} `assign'}
242 ]
243 {attorney}{noun}{}
244
245 \newentrysubcat{attorney-noun}{a person appointed to act for another
246 in legal matters}
247
248 \newentrysubcat
249 [%
250 subject={chiefly US}%
251 ]
252 {attorney-noun}{a lawyer}
253
254 \newentry
255 [
256 phonetic={\stress{ay}-tri-uhm},
257 altplural={atria},
258 parenthetical={pl.\ \namefont{atria}
259 \phoneticformat{\stress{ay}-tri-uh}
260 or \namefont{atriums}},
261 derivatives={\derivativeformat{atrial}{adjective}},
262 origin={Latin}
263 ]
264 {atrium}{noun}{}
265
266 \newentrysubcat{atrium-noun}{a central hall rising through several
267 storeys and having a glazed roof}
268
269 \newentrysubcat{atrium-noun}{an open area in the centre of an
270 ancient Roman house}
271
272 \newentrysubcat{atrium-noun}{each of the two cavities of the heart}
273
274 \newentry
275 [%
276 plural={austerities},
277 phonetic={oss-\stress{te}-ri-ti}
278 ]
279 {austerity}{noun}{}
280
281 \newentrysubcat{austerity-noun}{strictness or severity of appearance
282 or manner}
283 \newentrysubcat{austerity-noun}{difficult economic conditions
284 resulting from a cut in public spending}
285
286 \newentry
287 [
288 plural={cacti},
289 altplural={cactuses},
290 origin={Greek \originfont{kaktos} `cardoon'}
291 ]
292 {cactus}{noun}{a succulent plant with thick fleshy stems bearing
293 spikes but no leaves}
294
295 \newentry
296 [%
297 phonetic={chahf},
298 phrases={\namefont{separate} (or \namefont{sort}) \namefont{the
299 wheat from the chaff} distinguish valuable people or things from
300 worthless ones},
301 origin={Old English}
302 ]
303 {chaff\textsuperscript{1}}{noun}{}
304
305 \newentrysubcat{chaff1-noun}{the husks of grain from the seed by
306 winnowing or threshing}
307
308 \newentrysubcat{chaff1-noun}{chopped hay and straw used in cattle
309 fodder}
310
311 \newentry
312 [
313 phonetic={chaff},
314 ]
315 {chaff\textsuperscript{2}}{noun}{light-hearted joking}
316
317 \newentrycat{chaff2}{verb}{tease someone}
318
319 \newterm
320 [
321 plural={elves},%
322 derivatives={\derivativeformat{elfish}{adjective}
323 \derivativeformat{elven}{adjective (literary)}
324 \derivativeformat{elvish}{adjective}},%
325 origin={Old English},%
326 description={a supernatural creature of folk tales, represented as
327 a small human figure with pointed ears}
328 ]
329 {elf}
330
331 % Be careful of words starting with an accent.
332
333 \newterm
334 [
335 label={elite},%
336 phonetic={i-\stress{leet}},%
337 origin={French, `selection, choice'}%
338 ]
339 {élite}
340
341 \newentrycat{elite}{noun}{a group of people regarded as the best in a
342 particular society or organisation}
343
344 \newterm
345 [
346 description={plural of \Crossref{elf}}%
347 ]
348 {elves}
349
350 % Add all entries
351
352 \glsaddall{index}
353
354 % Customise index format
355
356 \renewcommand{\DTLgidxNameFont}[1]{\namefont{\large#1}}
357
358 \newcommand{\postnamespace}{\space}
359
360 \renewcommand{\DTLgidxPostName}{%
361 \ifdefempty\Subject
362 {%
363 }%
364 {%
365 \space\subjectfont{\Subject}%
366 }%
367 \ifdefempty\Phonetic
368 {%
369 }%
370 {%
371 \space\phoneticformat{\Phonetic}%
372 }%
373 \ifdefempty\Parenthetical
374 {%
375 \ifdefempty\AltPlural
376 {%
377 \ifthenelse{\equal{\Plural}{\Text s}}%
378 {%
379 }%
380 {%
381 \space (pl.\ \namefont{\Plural})%
382 }%
383 }%
384 {%
385 \space (pl. \namefont{\Plural} or \namefont{\AltPlural})%
386 }%
387 }%
388 {%
389 \space (\Parenthetical)%
390 }%
391 \postnamespace
392 }
393
394 \renewcommand{\DTLgidxCategoryNameFont}[1]{\categoryfont{#1}}
395 \renewcommand{\DTLgidxCategorySep}{\space\textbullet\space}
396 \renewcommand*{\DTLgidxChildCountLabel}{%
397 \def\postnamespace{~\def\postnamespace{\space}}%
398 \textbf{\sffamily\theDTLgidxChildCount}%
399 }
400
401 \renewcommand{\DTLgidxDictPostItem}{%
402 \ifdefempty\Derivatives
403 {}
404 {%
405 \par
406 \datagidxdictparshape
407 -- \textsc{derivatives} \Derivatives.
408 }%
409 \ifdefempty\Phrases
410 {}
411 {%
412 \par
413 \datagidxdictparshape
414 -- \textsc{phrases} \Phrases.
415 }%
416 \ifdefempty\Origin
417 {}
418 {%
419 \par
420 \datagidxdictparshape
421 -- \textsc{origin} \Origin.
422 }%
423 \par
424 }
425
426 \begin{document}
427
428 \printterms
429 [
430 database=index,
431 postheading={This is an example document illustrating
432 the use of the datagidx package. The examples here are taken from
433 the Compact Oxford English Dictionary.\medskip
434 },
435 balance=false,
436 columns=2,
437 postdesc=dot,%
438 childsort=false,% don't sort the child lists
439 style={dict} % use the 'dict' style
440 ]
441
442 \end{document}