| 1 |
% This file is public domain. |
| 2 |
% |
| 3 |
% This is a sample document illustrating how to use the |
| 4 |
% glossaries package with xindy. To create the document: |
| 5 |
% |
| 6 |
% latex samplexdy |
| 7 |
% makeglossaries samplexdy |
| 8 |
% latex samplexdy |
| 9 |
% |
| 10 |
% If you don't have Perl installed, then use one of the |
| 11 |
% following instead of makeglossaries: |
| 12 |
% |
| 13 |
% If you want to have a separate "Mc" letter group do: |
| 14 |
% |
| 15 |
% xindy -I xindy -M samplexdy-mc -t samplexdy.glg -o samplexdy.gls samplexdy.glo |
| 16 |
% |
| 17 |
% Otherwise do: |
| 18 |
% |
| 19 |
% xindy -L english -C utf8 -I xindy -M samplexdy -t samplexdy.glg -o samplexdy.gls samplexdy.glo |
| 20 |
% |
| 21 |
% If you want to use arara, you need the following directives: |
| 22 |
% arara: pdflatex: { synctex: on } |
| 23 |
% arara: makeglossaries |
| 24 |
% arara: pdflatex: { synctex: on } |
| 25 |
% |
| 26 |
%http://mirrors.ctan.org/macros/latex/contrib/glossaries/glossaries-user.html#sample |
| 27 |
\documentclass{article} |
| 28 |
|
| 29 |
\usepackage[utf8]{inputenc} |
| 30 |
\usepackage[T1]{fontenc} |
| 31 |
\usepackage[notext,notextcomp]{stix} |
| 32 |
|
| 33 |
\usepackage[colorlinks,plainpages]{hyperref} |
| 34 |
\usepackage[xindy,esclocations,style=altlistgroup]{glossaries} |
| 35 |
|
| 36 |
% Define a new command to do bold italic: |
| 37 |
|
| 38 |
\newcommand*{\hyperbfit}[1]{\textit{\hyperbf{#1}}} |
| 39 |
|
| 40 |
% Need to add this to the list of attributes in order |
| 41 |
% to use it with xindy: |
| 42 |
% (This command will have no effect if \noist is used) |
| 43 |
|
| 44 |
\GlsAddXdyAttribute{hyperbfit} |
| 45 |
|
| 46 |
% Redefine the page numbers to a custom format (requires stix |
| 47 |
% package for the dice commands): |
| 48 |
|
| 49 |
% \tallynum{n} displays a die or dice where the dots add up to n |
| 50 |
\newrobustcmd*{\tallynum}[1]{% |
| 51 |
\ifnum\number#1<7 |
| 52 |
$\csname dice\romannumeral#1\endcsname$% |
| 53 |
\else |
| 54 |
$\dicevi$% |
| 55 |
\expandafter\tallynum\expandafter{\numexpr#1-6}% |
| 56 |
\fi |
| 57 |
} |
| 58 |
|
| 59 |
% \tally{counter} expands to \tallynum{n} where n is the counter |
| 60 |
% value. In order to work with glossaries and xindy this requires |
| 61 |
% a very specific format. (See the glossaries user manual for more |
| 62 |
% details.) |
| 63 |
|
| 64 |
\newcommand*{\tally}[1]{\tallynum{\arabic{#1}}} |
| 65 |
|
| 66 |
% Now redefine \thepage |
| 67 |
% (\texorpdfstring is used in case the page number ends up in a PDF |
| 68 |
% bookmark, although this is unlikely) |
| 69 |
\renewcommand*{\thepage}{\texorpdfstring{\tally{page}}{\arabic{page}}} |
| 70 |
|
| 71 |
% Need to add this to the list of location styles. |
| 72 |
% This requires knowing how \thepage expands when written to a file. |
| 73 |
% You can check by inspecting the ':locref' attributes in the .glo |
| 74 |
% file. In this case, \thepage expands to \tallynum {n} |
| 75 |
% (the space is significant) where n is an arabic number. |
| 76 |
% (This command will have no effect if \noist is used) |
| 77 |
|
| 78 |
\GlsAddXdyLocation{tally}{% tally location format |
| 79 |
:sep "\string\tallynum\space\glsopenbrace" % -> \tallynum { |
| 80 |
"arabic-numbers" % -> arabic number (0, 1, 2, etc) |
| 81 |
:sep "\glsclosebrace" % -> } |
| 82 |
} |
| 83 |
|
| 84 |
% If the definition of \tally changes so that it expands to |
| 85 |
% something slightly different then the above will have to be |
| 86 |
% changed accordingly. |
| 87 |
|
| 88 |
% (Need to redefine \glsXpageXhyperbfit and |
| 89 |
% \glsXpageXglsnumberformat after \makeglossaries to get the |
| 90 |
% hyperlinks working correctly.) |
| 91 |
|
| 92 |
% To have Mc as a separate group uncomment the following three |
| 93 |
% lines: |
| 94 |
|
| 95 |
%\setStyleFile{samplexdy-mc} % note no extension |
| 96 |
%\noist |
| 97 |
%\GlsSetXdyLanguage{} |
| 98 |
|
| 99 |
% The above three lines specify to use samplexdy-mc.xdy (supplied |
| 100 |
% with this file) and don't overwrite it. The language is |
| 101 |
% unset using \GlsSetXdyLanguage{} as all the language |
| 102 |
% dependent information is contained in samplexdy-mc.xdy |
| 103 |
% Note that using \noist means that commands like |
| 104 |
% \GlsAddXdyAttribute and \GlsAddXdyLocation will no longer have |
| 105 |
% an effect. |
| 106 |
|
| 107 |
% Write the style file (if \noist isn't used) |
| 108 |
% and activate glossary entries |
| 109 |
|
| 110 |
\makeglossaries |
| 111 |
|
| 112 |
% Each page location will be specified in the form: |
| 113 |
% |
| 114 |
% "\glsXpageXglsnumberformat{}{\tallynum {" number "}}" |
| 115 |
% or |
| 116 |
% "\glsXpageXhyperbfit{}{\tallynum {" number "}}" |
| 117 |
% |
| 118 |
% Knowing this, we can redefine \glsXpageXglsnumberformat |
| 119 |
% and \glsXpageXhyperbfit to grab the number part to work out the |
| 120 |
% location's numeric value. If the definition of \tally changes |
| 121 |
% so that it expands to something slightly different then this |
| 122 |
% code will no longer work. |
| 123 |
% |
| 124 |
% Redefine to allow hyperlinks: |
| 125 |
|
| 126 |
\renewcommand{\glsXpageXglsnumberformat}[2]{% |
| 127 |
% remember that #2 is in the form \tallynum {n} |
| 128 |
% so this does \linkpagenumber\tallynum{n} |
| 129 |
\linkpagenumber#2% |
| 130 |
} |
| 131 |
|
| 132 |
\renewcommand{\glsXpageXhyperbfit}[2]{% |
| 133 |
\textbf{\em\linkpagenumber#2}% |
| 134 |
} |
| 135 |
|
| 136 |
% Syntax: \linkpagenumber\tallynum{page number} |
| 137 |
% This creates hyperlink to the given page. |
| 138 |
\newcommand{\linkpagenumber}[2]{\hyperlink{page.#2}{#1{#2}}} |
| 139 |
|
| 140 |
% Define glossary entries |
| 141 |
% \glshyperlink is used instead of \gls to prevent the glossary |
| 142 |
% page numbers also appear in the locations, however I need |
| 143 |
% to ensure that the referenced entries are added to the |
| 144 |
% glossary via commands that use \glslink, \glsadd or \glssee |
| 145 |
|
| 146 |
\newglossaryentry{mcadam}{name={McAdam, John Loudon}, |
| 147 |
first={John Loudon McAdam},text={McAdam}, |
| 148 |
description={Scottish engineer}} |
| 149 |
|
| 150 |
\newglossaryentry{maclaurin}{name={Maclaurin, Colin}, |
| 151 |
first={Colin Maclaurin},text={Maclaurin}, |
| 152 |
description={Scottish mathematician best known for the |
| 153 |
\gls{maclaurinseries}}} |
| 154 |
|
| 155 |
\newglossaryentry{maclaurinseries}{name={Maclaurin series}, |
| 156 |
description={Series expansion},see={taylorstheorem}} |
| 157 |
|
| 158 |
\newglossaryentry{taylorstheorem}{name={Taylor's theorem}, |
| 159 |
description={Theorem expressing a function $f(x)$ as the sum of |
| 160 |
a polynomial and a remainder: |
| 161 |
\[f(x) = f(a)+f'(a)(x-a)+f''(a)(x-a^2)/2!+\cdots+R_n\] |
| 162 |
If $n\to\infty$ the expansion is a \glshyperlink{taylorseries} |
| 163 |
and if $a=0$, the series is called a |
| 164 |
\gls{maclaurinseries}}} |
| 165 |
|
| 166 |
\newglossaryentry{taylorseries}{name={Taylor series}, |
| 167 |
description={Series expansion},see={taylorstheorem}} |
| 168 |
|
| 169 |
\newglossaryentry{taylor}{name={Taylor, Brook}, |
| 170 |
first={Brook Taylor},text={Taylor}, |
| 171 |
description={English mathematician}} |
| 172 |
|
| 173 |
\newglossaryentry{mcnemar}{name={McNemar, Quinn}, |
| 174 |
first={Quinn McNemar},text={McNemar}, |
| 175 |
description={Mathematician who introduced |
| 176 |
\gls{mcnemarstest}. This entry has the number list |
| 177 |
suppressed},nonumberlist} |
| 178 |
|
| 179 |
\newglossaryentry{mcnemarstest}{name={McNemar's test}, |
| 180 |
description={A nonparametric test introduced by |
| 181 |
\gls{mcnemar} in 1947}} |
| 182 |
|
| 183 |
\newglossaryentry{mach}{name={Mach, Ernst}, |
| 184 |
first={Ernst Mach},text={Mach}, |
| 185 |
% if using samplexdy-mc.xdy, the following line is needed |
| 186 |
% to prevent this entry being put in the "Mc" group |
| 187 |
sort={mach, Ernst}, |
| 188 |
description={Czech/Austrian physicist and philosopher}} |
| 189 |
|
| 190 |
\newglossaryentry{machnumber}{name={Mach number}, |
| 191 |
% if using samplexdy-mc.xdy, the following line is needed |
| 192 |
% to prevent this entry being put in the "Mc" group |
| 193 |
sort={mach number}, |
| 194 |
description={Ratio of the speed of a body in a fluid to the |
| 195 |
speed of sound in that fluid named after \gls{mach}}} |
| 196 |
|
| 197 |
\newglossaryentry{malthus}{name={Malthus, Thomas Robert}, |
| 198 |
first={Thomas Robert Malthus},text={Malthus}, |
| 199 |
description={English mathematician, sociologist and classicist}} |
| 200 |
|
| 201 |
\newglossaryentry{ampereandre}{name={Ampère, André-Marie}, |
| 202 |
first={André-Marie Ampère},text={Ampère}, |
| 203 |
description={French mathematician and physicist}} |
| 204 |
|
| 205 |
\newglossaryentry{ampere}{name={ampere}, |
| 206 |
description={SI unit of electric current named after |
| 207 |
\gls{ampereandre}}} |
| 208 |
|
| 209 |
\newglossaryentry{archimedes}{name={Archimedes of Syracuse}, |
| 210 |
first={Archimedes of Syracuse},text={Archimedes}, |
| 211 |
description={Greek mathematician}} |
| 212 |
|
| 213 |
\newglossaryentry{archimedesprinciple}{name={Archimedes' principle}, |
| 214 |
description={Principle that if a body is submerged in a fluid |
| 215 |
it experiences upthrust equal to the weight of the displaced |
| 216 |
fluid. Named after \gls{archimedes}}} |
| 217 |
|
| 218 |
\newglossaryentry{galton}{name={Galton, Sir Francis}, |
| 219 |
first={Sir Francis Galton},text={Galton}, |
| 220 |
description={English anthropologist}} |
| 221 |
|
| 222 |
\newglossaryentry{gauss}{name={Gauss, Karl Friedrich}, |
| 223 |
first={Karl Friedrich Gauss},text={Gauss}, |
| 224 |
description={German mathematician}} |
| 225 |
|
| 226 |
\newglossaryentry{gaussianint}{name={Gaussian integer}, |
| 227 |
description={Complex number where both real and imaginary |
| 228 |
parts are integers}} |
| 229 |
|
| 230 |
\newglossaryentry{gaussianfn}{name={Gaussian function}, |
| 231 |
description={A function of the form: |
| 232 |
\[f(x) = a \exp\left(-\frac{(x-b)^2}{2c^2}\right)\] |
| 233 |
for some constants $a$, $b$ and $c$}} |
| 234 |
|
| 235 |
\newglossaryentry{peano}{name={Peano, Giuseppe}, |
| 236 |
first={Giuseppe Peano},text={Peano}, |
| 237 |
description={Italian mathematician}} |
| 238 |
|
| 239 |
\newglossaryentry{peanoscurve}{name={Peano's curve}, |
| 240 |
description={A space-filling curve discovered by |
| 241 |
\gls{peano}}} |
| 242 |
|
| 243 |
\newglossaryentry{pearson}{name={Pearson, Karl}, |
| 244 |
first={Karl Pearson},text={Pearson}, |
| 245 |
description={English mathematician}} |
| 246 |
|
| 247 |
\newglossaryentry{pearspmcc}{name={Pearson's product moment |
| 248 |
correlation coefficient},description={Product moment correlation |
| 249 |
coefficient named after \gls{pearson}}} |
| 250 |
|
| 251 |
\begin{document} |
| 252 |
\title{Sample Document Using the Glossaries Package With Xindy} |
| 253 |
\author{Nicola Talbot} |
| 254 |
\maketitle |
| 255 |
|
| 256 |
\section{\glsentryfirst{gauss}} |
| 257 |
|
| 258 |
This is a section on \gls[format=(]{gauss}. This section spans |
| 259 |
several pages. |
| 260 |
|
| 261 |
\rule{1pt}{0.6\textheight} |
| 262 |
|
| 263 |
This paragraph has been shoved to the bottom of the page using a rule. |
| 264 |
This paragraph spans a page break for testing purposes to ensure the |
| 265 |
glossary entry in this paragraph has the correct location. Here's |
| 266 |
the glossary entry: \gls{gaussianfn}. Check that the location is |
| 267 |
correct. |
| 268 |
|
| 269 |
This page talks about \glspl[format=hyperbfit]{gaussianint}. Since |
| 270 |
it's the principle definition, the user-defined hyperbfit format is |
| 271 |
used. |
| 272 |
|
| 273 |
\newpage |
| 274 |
|
| 275 |
The section on \gls[format=)]{gauss} ends here. |
| 276 |
|
| 277 |
\section{Series Expansions} |
| 278 |
|
| 279 |
This section is about series expansions. It mentions |
| 280 |
\gls{maclaurin} and \gls{taylor}. It also discusses |
| 281 |
\gls{taylorstheorem} which is related to the \gls{taylorseries}. |
| 282 |
The \gls{maclaurinseries} is a special case of the |
| 283 |
\gls{taylorseries}. |
| 284 |
|
| 285 |
\section{\glsentryname{archimedesprinciple}} |
| 286 |
|
| 287 |
This section discusses \gls{archimedesprinciple} which was |
| 288 |
introduced by \gls{archimedes}. |
| 289 |
|
| 290 |
\section{Another section} |
| 291 |
|
| 292 |
This section covers \gls{mach} who introduced the \gls{machnumber}. |
| 293 |
It also mentions \gls{ampereandre} after whom the |
| 294 |
SI unit \gls{ampere} is named. It then discusses \gls{galton} |
| 295 |
and \gls{malthus}. Finally it mentions \gls{mcadam}. |
| 296 |
|
| 297 |
\newpage |
| 298 |
This page discusses \gls{mcnemar} who introduced |
| 299 |
\gls{mcnemarstest} and \gls{peano} who discovered \gls{peanoscurve}. |
| 300 |
|
| 301 |
\printglossaries |
| 302 |
\end{document} |