summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/glossaries/samples/samplexdy.tex
blob: 808a1ac5ee3e449f00fb7f97f75b7c59db2e486c (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
% This file is public domain.
%
% This is a sample document illustrating how to use the
% glossaries package with xindy. To create the document:
%
%   latex samplexdy
%   makeglossaries samplexdy
%   latex samplexdy
%
% If you don't have Perl installed, then use one of the
% following instead of makeglossaries:
%
% If you want to have a separate "Mc" letter group do:
%
%    xindy -I xindy -M samplexdy-mc -t samplexdy.glg -o samplexdy.gls samplexdy.glo
%
% Otherwise do:
%
%  xindy -L english -C utf8 -I xindy -M samplexdy -t samplexdy.glg -o samplexdy.gls samplexdy.glo
%
% If you want to use arara, you need the following directives:
% arara: pdflatex: { synctex: on }
% arara: makeglossaries
% arara: pdflatex: { synctex: on }
\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[notext,notextcomp]{stix}

\usepackage[colorlinks,plainpages]{hyperref}
\usepackage[xindy,style=altlistgroup]{glossaries}

% Define a new command to do bold italic:

\newcommand*{\hyperbfit}[1]{\textit{\hyperbf{#1}}}

% Need to add this to the list of attributes in order
% to use it with xindy:
% (This command will have no effect if \noist is used)

\GlsAddXdyAttribute{hyperbfit}

% Redefine the page numbers to a custom format (requires stix
% package for the dice commands):

% \tallynum{n} displays a die or dice where the dots add up to n
\newrobustcmd{\tallynum}[1]{%
 \ifnum\number#1<7
  $\csname dice\romannumeral#1\endcsname$%
 \else
  $\dicevi$%
  \expandafter\tallynum\expandafter{\numexpr#1-6}%
 \fi
}

% \tally{counter} expands to \tallynum{n} where n is the counter
% value. In order to work with glossaries and xindy this requires
% a very specific format. (See the glossaries user manual for more
% details.)

\newcommand{\tally}[1]{\tallynum{\arabic{page}}}

% Now redefine \thepage
% (\texorpdfstring is used in case the page number ends up in a PDF
% bookmark, although this is unlikely)
\renewcommand*{\thepage}{\texorpdfstring{\tally{page}}{\arabic{page}}}

% Need to add this to the list of location styles.
% This requires knowing how \thepage expands when written to a file.
% You can check by inspecting the ':locref' attributes in the .glo
% file. In this case, \thepage expands to \tallynum {n}
% (the space is significant) where n is an arabic number.
% (This command will have no effect if \noist is used)

\GlsAddXdyLocation{tally}{% tally location format
 :sep "\string\tallynum\space\glsopenbrace" % -> \tallynum {
 "arabic-numbers" % -> arabic number (0, 1, 2, etc)
 :sep "\glsclosebrace" % -> }
}

% If the definition of \tally changes so that it expands to
% something slightly different then the above will have to be
% changed accordingly.

% (Need to redefine \glsXpageXhyperbfit and
% \glsXpageXglsnumberformat after \makeglossaries to get the
% hyperlinks working correctly.)

% To have Mc as a separate group uncomment the following three
% lines:

%\setStyleFile{samplexdy-mc} % note no extension
%\noist
%\GlsSetXdyLanguage{}

% The above three lines specify to use samplexdy-mc.xdy (supplied
% with this file) and don't overwrite it. The language is
% unset using \GlsSetXdyLanguage{} as all the language
% dependent information is contained in samplexdy-mc.xdy
% Note that using \noist means that commands like
% \GlsAddXdyAttribute and \GlsAddXdyLocation will no longer have
% an effect.

% Write the style file (if \noist isn't used)
% and activate glossary entries

\makeglossaries

% Each page location will be specified in the form:
%
% "\glsXpageXglsnumberformat{}{\tallynum {" number "}}"
% or
% "\glsXpageXhyperbfit{}{\tallynum {" number "}}"
%
% Knowing this, we can redefine \glsXpageXglsnumberformat
% and \glsXpageXhyperbfit to grab the number part to work out the
% location's numeric value. If the definition of \tally changes
% so that it expands to something slightly different then this
% code will no longer work.
%
% Redefine to allow hyperlinks:

\renewcommand{\glsXpageXglsnumberformat}[2]{%
 % remember that #2 is in the form \tallynum {n}
 % so this does \linkpagenumber\tallynum{n}
 \linkpagenumber#2%
}

\renewcommand{\glsXpageXhyperbfit}[2]{%
 \textbf{\em\linkpagenumber#2}%
}

% Syntax: \linkpagenumber\tallynum{page number}
% This creates hyperlink to the given page.
\newcommand{\linkpagenumber}[2]{\hyperlink{page.#2}{#1{#2}}}

% Define glossary entries
% \glshyperlink is used instead of \gls to prevent the glossary
% page numbers also appear in the locations, however I need
% to ensure that the referenced entries are added to the
% glossary via commands that use \glslink, \glsadd or \glssee

\newglossaryentry{mcadam}{name={McAdam, John Loudon},
first={John Loudon McAdam},text={McAdam},
description={Scottish engineer}}

\newglossaryentry{maclaurin}{name={Maclaurin, Colin},
first={Colin Maclaurin},text={Maclaurin},
description={Scottish mathematician best known for the
\gls{maclaurinseries}}}

\newglossaryentry{maclaurinseries}{name={Maclaurin series},
description={Series expansion},see={taylorstheorem}}

\newglossaryentry{taylorstheorem}{name={Taylor's theorem},
description={Theorem expressing a function $f(x)$ as the sum of
a polynomial and a remainder:
\[f(x) = f(a)+f'(a)(x-a)+f''(a)(x-a^2)/2!+\cdots+R_n\]
If $n\to\infty$ the expansion is a \glshyperlink{taylorseries}
and if $a=0$, the series is called a
\gls{maclaurinseries}}}

\newglossaryentry{taylorseries}{name={Taylor series},
description={Series expansion},see={taylorstheorem}}

\newglossaryentry{taylor}{name={Taylor, Brook},
first={Brook Taylor},text={Taylor},
description={English mathematician}}

\newglossaryentry{mcnemar}{name={McNemar, Quinn},
first={Quinn McNemar},text={McNemar},
description={Mathematician who introduced
\gls{mcnemarstest}. This entry has the number list
suppressed},nonumberlist}

\newglossaryentry{mcnemarstest}{name={McNemar's test},
description={A nonparametric test introduced by
\gls{mcnemar} in 1947}}

\newglossaryentry{mach}{name={Mach, Ernst},
first={Ernst Mach},text={Mach},
% if using samplexdy-mc.xdy, the following line is needed
% to prevent this entry being put in the "Mc" group
sort={mach, Ernst},
description={Czech/Austrian physicist and philosopher}}

\newglossaryentry{machnumber}{name={Mach number},
% if using samplexdy-mc.xdy, the following line is needed
% to prevent this entry being put in the "Mc" group
sort={mach number},
description={Ratio of the speed of a body in a fluid to the
speed of sound in that fluid named after \gls{mach}}}

\newglossaryentry{malthus}{name={Malthus, Thomas Robert},
first={Thomas Robert Malthus},text={Malthus},
description={English mathematician, sociologist and classicist}}

\newglossaryentry{ampereandre}{name={Ampère, André-Marie},
first={André-Marie Ampère},text={Ampère},
description={French mathematician and physicist}}

\newglossaryentry{ampere}{name={ampere},
description={SI unit of electric current named after
\gls{ampereandre}}}

\newglossaryentry{archimedes}{name={Archimedes of Syracuse},
first={Archimedes of Syracuse},text={Archimedes},
description={Greek mathematician}}

\newglossaryentry{archimedesprinciple}{name={Archimedes' principle},
description={Principle that if a body is submerged in a fluid
it experiences upthrust equal to the weight of the displaced
fluid. Named after \gls{archimedes}}}

\newglossaryentry{galton}{name={Galton, Sir Francis},
first={Sir Francis Galton},text={Galton},
description={English anthropologist}}

\newglossaryentry{gauss}{name={Gauss, Karl Friedrich},
first={Karl Friedrich Gauss},text={Gauss},
description={German mathematician}}

\newglossaryentry{gaussianint}{name={Gaussian integer},
description={Complex number where both real and imaginary
parts are integers}}

\newglossaryentry{gaussianfn}{name={Gaussian function},
 description={A function of the form:
 \[f(x) = a \exp\left(-\frac{(x-b)^2}{2c^2}\right)\]
 for some constants $a$, $b$ and $c$}}

\newglossaryentry{peano}{name={Peano, Giuseppe},
first={Giuseppe Peano},text={Peano},
description={Italian mathematician}}

\newglossaryentry{peanoscurve}{name={Peano's curve},
description={A space-filling curve discovered by
\gls{peano}}}

\newglossaryentry{pearson}{name={Pearson, Karl},
first={Karl Pearson},text={Pearson},
description={English mathematician}}

\newglossaryentry{pearspmcc}{name={Pearson's product moment
correlation coefficient},description={Product moment correlation
coefficient named after \gls{pearson}}}

\begin{document}
\title{Sample Document Using the Glossaries Package With Xindy}
\author{Nicola Talbot}
\maketitle

\section{\glsentryfirst{gauss}}

This is a section on \gls[format=(]{gauss}. This section spans
several pages.

\rule{1pt}{0.6\textheight}

This paragraph has been shoved to the bottom of the page using a rule.
This paragraph spans a page break for testing purposes to ensure the
glossary entry in this paragraph has the correct location. Here's
the glossary entry: \gls{gaussianfn}. Check that the location is
correct.

This page talks about \glspl[format=hyperbfit]{gaussianint}. Since
it's the principle definition, the user-defined hyperbfit format is
used.

\newpage

The section on \gls[format=)]{gauss} ends here.

\section{Series Expansions}

This section is about series expansions. It mentions
\gls{maclaurin} and \gls{taylor}. It also discusses
\gls{taylorstheorem} which is related to the \gls{taylorseries}.
The \gls{maclaurinseries} is a special case of the
\gls{taylorseries}.

\section{\glsentryname{archimedesprinciple}}

This section discusses \gls{archimedesprinciple} which was
introduced by \gls{archimedes}.

\section{Another section}

This section covers \gls{mach} who introduced the \gls{machnumber}.
It also mentions \gls{ampereandre} after whom the
SI unit \gls{ampere} is named. It then discusses \gls{galton}
and \gls{malthus}. Finally it mentions \gls{mcadam}.

\newpage
This page discusses \gls{mcnemar} who introduced
\gls{mcnemarstest} and \gls{peano} who discovered \gls{peanoscurve}.

\printglossaries
\end{document}