Debian Codegraph @

texmf-dist/doc/latex/glossaries/samples/sample.tex

raw
1 % This file is public domain
2 % If you want to use arara, you need the following directives:
3 % arara: pdflatex: { synctex: on }
4 % arara: makeglossaries
5 % arara: pdflatex: { synctex: on }
6 % arara: pdflatex: { synctex: on }
7 %
8 %http://mirrors.ctan.org/macros/latex/contrib/glossaries/glossaries-user.html#sample
9 \documentclass[a4paper]{report}
10
11 \usepackage[plainpages=false,colorlinks]{hyperref}
12 \usepackage[toc,style=treenonamegroup,subentrycounter]{glossaries}
13
14 \makeglossaries
15
16 \newcommand{\scriptlang}[1]{\textsf{#1}}
17
18 \newglossaryentry{Perl}{name=\scriptlang{Perl},
19 sort=Perl, % need a sort key because name contains a command
20 description={A scripting language}}
21
22 \newglossaryentry{glossary}{name=glossary,
23 description={\nopostdesc},
24 plural={glossaries}}
25
26 \newglossaryentry{glossarycol}{
27 description={collection of glosses},
28 sort={2},
29 parent={glossary}}
30
31 \newglossaryentry{glossarylist}{
32 description={list of technical words},
33 sort={1},
34 parent={glossary}}
35
36 \newglossaryentry{pagelist}{name=page list,
37 % description value has to be enclosed in braces
38 % because it contains commas
39 description={a list of individual pages or page ranges
40 (e.g.\ 1,2,4,7-9)}}
41
42 \newglossaryentry{mtrx}{name=matrix,
43 description={rectangular array of quantities},
44 % plural is not simply obtained by appending an s, so specify
45 plural=matrices}
46
47 % Entry with a paragraph break in the description:
48 % (If you use \newglossaryentry, the paragraph break
49 % must be identified with \glspar not with \par or a blank line.
50 % It's easier to use \longnewglossaryentry.)
51
52 \longnewglossaryentry{par}% label
53 {name=paragraph}% options
54 {% multi-paragraph description
55 distinct section of a piece of writing.
56
57 Beginning on new, usually indented, line}
58
59 % entry with two types of plural. Set the plural form to the
60 % form most likely to be used. The alternative plural is stored in
61 % the 'user1' key. Another option is to define your own custom
62 % storage key for alternative plurals.
63 \newglossaryentry{cow}{name=cow,
64 % this isn't necessary, as this form (appending an s) is
65 % the default
66 plural=cows,
67 % alternative plural:
68 user1=kine,
69 % description:
70 description={(\emph{pl.}\ cows, \emph{archaic} kine) an adult
71 female of any bovine animal}}
72
73 \newglossaryentry{bravo}{name={bravo},
74 description={\nopostdesc}}
75
76 \newglossaryentry{bravocry}{description={cry of approval (pl.\ bravos)},
77 sort={1},
78 parent=bravo}
79
80 \newglossaryentry{bravoruffian}{description={hired ruffian or killer (pl.\ bravoes)},
81 sort={2},
82 plural={bravoes},
83 parent=bravo}
84
85 \newglossaryentry{seal}{%
86 name=seal,%
87 description={sea mammal with flippers that eats fish}
88 }
89
90 \newglossaryentry{sealion}{%
91 name={sea lion},%
92 description={large seal}%
93 }
94
95 % If a value contains a comma, you must use braces to hide
96 % it from the key=value list parser. Take care to avoid
97 % accidentally introducing unwanted space as leading and trailing
98 % spaces within the braces aren't stripped. For example,
99 % text={ spurious space } will result in extra space appearing
100 % when the entry is referenced.
101 \newglossaryentry{spuriousspace}{%
102 name={space, spurious},
103 text={spurious space},
104 description={unwanted spaces accidentally introduced by
105 uncommented line breaks or attempts to pretty-print the \LaTeX\ code}
106 }
107
108 \begin{document}
109
110 \title{Sample Document Using the glossaries Package}
111 \author{Nicola Talbot}
112 \pagenumbering{alph}% prevent duplicate page link names if using PDF
113 \maketitle
114
115 \pagenumbering{roman}
116 \tableofcontents
117
118 \chapter{Introduction}
119 \pagenumbering{arabic}
120
121 A \gls{glossarylist} (definition~\glsrefentry{glossarylist}, plural
122 \glspl{glossarylist}) is a very useful addition to any technical
123 document, although a \gls{glossarycol}
124 (definition~\glsrefentry{glossarycol}, plural \glspl{glossarycol})
125 can also simply be a collection of glosses, which is another thing
126 entirely. Some documents have multiple \glspl{glossarylist}.
127
128 Once you have run your document through \LaTeX, you will then need
129 to run the \texttt{.glo} file through \texttt{makeindex} (default)
130 or \texttt{xindy}. You will need to set the output file so that the
131 indexing application
132 creates a \texttt{.gls} file instead of an \texttt{.ind} file, and
133 change the name of the log file so that it doesn't overwrite the
134 index log file (if you have an index for your document). Rather
135 than having to remember all the command line switches, you can call
136 the \gls{Perl} script \texttt{makeglossaries} which provides a
137 convenient wrapper. See
138 \href{https://www.dickimaw-books.com/latex/buildglossaries}{Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build} for help.
139
140 If a comma appears within the name or description, grouping
141 must be used, e.g.\ in the description of \gls{pagelist}.
142 Be careful about \glspl{spuriousspace} appearing in your code.
143
144 \chapter{Plurals and Paragraphs}
145
146 Plurals are assumed to have the letter ``s'' appended, but if this is
147 not the case, as in \glspl{mtrx}, then you need to specify the
148 plural when you define the entry. If a term may have multiple
149 plurals (for example \glspl{cow}/\glsuseri{cow}) then
150 define the entry with the plural form most likely to be used.
151 The alternative can simply be referenced with \verb|\glslink|
152 (e.g.\ \glslink{cow}{kine})
153 or \verb|\glsdisp| (e.g.\ \glsdisp{cow}{kine}).
154 Another option is to save the alternative plural in another key. In
155 this case, the ``user1'' key has been used, but a custom key can be
156 defined instead.
157
158 \Glspl{seal} and \glspl{sealion} have regular plural forms.
159
160 \Gls{bravo} is a homograph, but the plural forms are spelt
161 differently. The plural of \gls{bravocry}, a cry of approval
162 (definition~\glsrefentry{bravocry}), is \glspl{bravocry}, whereas the
163 plural of \gls{bravoruffian}, a hired ruffian or killer
164 (definition~\glsrefentry{bravoruffian}), is \glspl{bravoruffian}.
165
166 \Glspl{par} can cause a problem in commands, so care is needed
167 when having a paragraph break in a \gls{glossarylist} entry.
168
169 \chapter{Ordering}
170
171 There are two types of ordering: word ordering (which places
172 ``\gls{sealion}'' before ``\gls{seal}'') and letter ordering
173 (which places ``\gls{seal}'' before ``\gls{sealion}'').
174
175 \printglossaries
176
177 \end{document}