| 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-inline |
| 9 |
\documentclass[a4paper]{report} |
| 10 |
|
| 11 |
\usepackage[plainpages=false,colorlinks]{hyperref} |
| 12 |
\usepackage[toc,order=word,subentrycounter]{glossaries} |
| 13 |
|
| 14 |
\usepackage{glossary-inline} |
| 15 |
|
| 16 |
\renewcommand*{\glossarysection}[2][]{\textbf{#1}: } |
| 17 |
\renewcommand{\glsnamefont}[1]{\textsc{#1}} |
| 18 |
\setglossarystyle{inline} |
| 19 |
|
| 20 |
\makeglossaries |
| 21 |
|
| 22 |
\newcommand{\scriptlang}[1]{\textsf{#1}} |
| 23 |
|
| 24 |
\newglossaryentry{Perl}{name=\scriptlang{Perl}, |
| 25 |
sort=Perl, % need a sort key because name contains a command |
| 26 |
description=A scripting language} |
| 27 |
|
| 28 |
\newglossaryentry{glossary}{name=glossary, |
| 29 |
description={\nopostdesc}, |
| 30 |
plural={glossaries}} |
| 31 |
|
| 32 |
\newglossaryentry{glossarycol}{ |
| 33 |
description={collection of glosses}, |
| 34 |
sort={2}, |
| 35 |
parent={glossary}} |
| 36 |
|
| 37 |
\newglossaryentry{glossarylist}{ |
| 38 |
description={list of technical words}, |
| 39 |
sort={1}, |
| 40 |
parent={glossary}} |
| 41 |
|
| 42 |
\newglossaryentry{pagelist}{name=page list, |
| 43 |
% description value has to be enclosed in braces |
| 44 |
% because it contains commas |
| 45 |
description={a list of individual pages or page ranges |
| 46 |
(e.g.\ 1,2,4,7-9)}} |
| 47 |
|
| 48 |
\newglossaryentry{mtrx}{name=matrix, |
| 49 |
description={rectangular array of quantities}, |
| 50 |
% plural is not simply obtained by appending an s, so specify |
| 51 |
plural=matrices} |
| 52 |
|
| 53 |
% entry with a paragraph break in the description |
| 54 |
|
| 55 |
\newglossaryentry{par}{name=paragraph, |
| 56 |
description={distinct section of piece of |
| 57 |
writing. 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. If you want to use a different |
| 61 |
% plural, you will need to explicity specify it in \glslink |
| 62 |
\newglossaryentry{cow}{name=cow, |
| 63 |
% this isn't necessary, as this form (appending an s) is |
| 64 |
% the default |
| 65 |
plural=cows, |
| 66 |
user1=kine, |
| 67 |
% description: |
| 68 |
description={(\emph{pl.}\ cows, \emph{archaic} kine) an adult |
| 69 |
female of any bovine animal}} |
| 70 |
|
| 71 |
\newglossaryentry{bravo}{name={bravo}, |
| 72 |
description={\nopostdesc}} |
| 73 |
|
| 74 |
\newglossaryentry{bravo1}{description={cry of approval (pl.\ bravos)}, |
| 75 |
sort={1}, |
| 76 |
plural={bravos}, |
| 77 |
parent=bravo} |
| 78 |
|
| 79 |
\newglossaryentry{bravo2}{description={hired ruffian or killer (pl.\ bravoes)}, |
| 80 |
sort={2}, |
| 81 |
plural={bravoes}, |
| 82 |
parent=bravo} |
| 83 |
|
| 84 |
\newglossaryentry{seal}{name=seal,description={sea mammal with |
| 85 |
flippers that eats fish}} |
| 86 |
|
| 87 |
\newglossaryentry{sealion}{name={sea lion}, |
| 88 |
description={large seal}} |
| 89 |
|
| 90 |
\begin{document} |
| 91 |
|
| 92 |
\title{Sample Document Using glossary Package} |
| 93 |
\author{Nicola Talbot} |
| 94 |
\pagenumbering{alph}% prevent duplicate page link names if using PDF |
| 95 |
\maketitle |
| 96 |
|
| 97 |
\pagenumbering{roman} |
| 98 |
\tableofcontents |
| 99 |
|
| 100 |
\chapter{Introduction} |
| 101 |
\pagenumbering{arabic} |
| 102 |
|
| 103 |
This document has a glossary in a footnote\footnote{\printglossaries}. |
| 104 |
|
| 105 |
A \gls{glossarylist} (definition~\glsrefentry{glossarylist}) is a |
| 106 |
very useful addition to any technical document, although a |
| 107 |
\gls{glossarycol} (definition~\glsrefentry{glossarycol}) can also |
| 108 |
simply be a collection of glosses, which is another thing entirely. |
| 109 |
Some documents have multiple \glspl{glossarylist}. |
| 110 |
|
| 111 |
Once you have run your document through \LaTeX, you |
| 112 |
will then need to run the \texttt{.glo} file through |
| 113 |
\texttt{makeindex}. You will need to set the output |
| 114 |
file so that it creates a \texttt{.gls} file instead |
| 115 |
of an \texttt{.ind} file, and change the name of |
| 116 |
the log file so that it doesn't overwrite the index |
| 117 |
log file (if you have an index for your document). |
| 118 |
Rather than having to remember all the command line |
| 119 |
switches, you can call the \gls{Perl} script |
| 120 |
\texttt{makeglossaries} which provides a convenient |
| 121 |
wrapper. |
| 122 |
|
| 123 |
If a comma appears within the name or description, grouping |
| 124 |
must be used, e.g.\ in the description of \gls{pagelist}. |
| 125 |
|
| 126 |
\chapter{Plurals and Paragraphs} |
| 127 |
|
| 128 |
Plurals are assumed to have the letter s appended, but if this is |
| 129 |
not the case, as in \glspl{mtrx}, then you need to specify the |
| 130 |
plural when you define the entry. If a term may have multiple |
| 131 |
plurals (for example \glspl{cow}/\glsuseri{cow}) then |
| 132 |
define the entry with the plural form most likely to be used. |
| 133 |
The alternative can simply be referenced with \verb|\glslink| |
| 134 |
(e.g.\ \glslink{cow}{kine}) |
| 135 |
or \verb|\glsdisp| (e.g.\ \glsdisp{cow}{kine}). |
| 136 |
Another option is to save the alternative plural in another key. In |
| 137 |
this case, the ``user1'' key has been used, but a custom key can be |
| 138 |
defined instead. |
| 139 |
|
| 140 |
|
| 141 |
\Glspl{seal} and \glspl{sealion} have regular plural forms. |
| 142 |
|
| 143 |
\Gls{bravo} is a homograph, but the plural forms are spelt |
| 144 |
differently. The plural of \gls{bravo1}, a cry of approval |
| 145 |
(definition~\glsrefentry{bravo1}), is \glspl{bravo1}, whereas the |
| 146 |
plural of \gls{bravo2}, a hired ruffian or killer |
| 147 |
(definition~\glsrefentry{bravo2}), is \glspl{bravo2}. |
| 148 |
|
| 149 |
\Glspl{par} can cause a problem in commands, so care is needed |
| 150 |
when having a paragraph break in a \gls{glossarylist} entry. |
| 151 |
|
| 152 |
\chapter{Ordering} |
| 153 |
|
| 154 |
There are two types of ordering: word ordering (which places |
| 155 |
``\gls{sealion}'' before ``\gls{seal}'') and letter ordering |
| 156 |
(which places ``\gls{seal}'' before ``\gls{sealion}''). |
| 157 |
|
| 158 |
\end{document} |