glossary

55
glossary.sty v 2.4: L A T E X2 ε Package to Assist Generating Glossaries Nicola L.C. Talbot 20th July 2006 Contents 1 Introduction 2 2 Installation 2 3 Generating Glossary Information 3 3.1 Storing Glossary Information ..................... 5 4 makeglos.pl 7 5 Displaying the Glossary 8 6 Package Options 8 6.1 Examples ................................ 10 7 Defining New Glossary Types 11 8 Acronyms 13 8.1 Examples ................................ 16 9 Customizing the Glossary 17 10 Sample Documents 20 11 LaTeX2HTML Style File 22 11.1 Limitations ............................... 23 12 Troubleshooting 23 13 Obsolete Commands 28 14 Contact Details 28 15 Acknowledgements 28 1

Upload: duong-thao

Post on 14-Dec-2014

321 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: glossary

glossary.sty v 2.4: LATEX2ε Package to Assist

Generating Glossaries

Nicola L.C. Talbot

20th July 2006

Contents

1 Introduction 2

2 Installation 2

3 Generating Glossary Information 33.1 Storing Glossary Information . . . . . . . . . . . . . . . . . . . . . 5

4 makeglos.pl 7

5 Displaying the Glossary 8

6 Package Options 86.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

7 Defining New Glossary Types 11

8 Acronyms 138.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

9 Customizing the Glossary 17

10 Sample Documents 20

11 LaTeX2HTML Style File 2211.1 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

12 Troubleshooting 23

13 Obsolete Commands 28

14 Contact Details 28

15 Acknowledgements 28

1

Page 2: glossary

16 The Code 2816.1 Package Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . 2816.2 Redefining \glossary format . . . . . . . . . . . . . . . . . . . . . 3216.3 Storing Glossary Entries . . . . . . . . . . . . . . . . . . . . . . . . 3416.4 Makeindex style file . . . . . . . . . . . . . . . . . . . . . . . . . . 4516.5 Defining a new glossary type . . . . . . . . . . . . . . . . . . . . . 4616.6 Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4716.7 Glossary Hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . 51

Change History 54

Index 55

1 Introduction

The glossary package is provided to assist generating a glossary. It has a certainamount of flexibility, allowing the user to customize the format of the glossary,and define new glossary-style objects.

2 Installation

You need to make sure you have downloaded the following three files:

glossary.ins

glossary.dtx

README

To extract the code from the glossary.dtx file, you will need to run the instal-lation file through LaTeX:

latex glossary.ins

This will create the following files:

glossary.sty

glossary.perl

makeglos.pl

makeglos.bat

along with several sample files. The file glossary.sty should be placed somewherein the LATEX path, e.g. texmf/tex/latex/glossary/ or localtexmf/tex/latex/glossary/.Remember to update the TEX database if you are installing this package for thefirst time. The file glossary.perl is a LATEX2HTML style file, and should beplaced in the LATEX2HTML style file directory (usually latex2html/styles/).The file makeglos.pl is a Perl script which calls makeindex. If you are usingUNIX or Linux, you will need to set the permissions so that you can execute thefile:

chmod a+x makeglos.pl

2

Page 3: glossary

You should then place this file somewhere on your path. (You may also need to editthe first line of this file, if perl is located in a directory other than /usr/bin/1.)

If you are not using UNIX or Linux etc, you may have to explicitly loadthe file into Perl, so you would need to do perl makeglos.pl instead of justmakeglos.pl. If you are using Windows, a batch file, makeglos.bat is pro-vided which will run Perl on makeglos.pl. Both makeglos.pl and makeglos.batshould be placed somewhere specified by the PATH environment variable. (Forexample, put them both in the same directory as makeindex, which will probablybe in \texmf\miktex\bin\).

If you don’t have Perl installed on your system, you can just use makeindex,only you will have to remember all the command line switches, and you won’t beable to merge entries that have the same name, but different descriptions.

Note that if you are updating the glossary package, it is a good idea to updatemakeglos.pl as it may also have been modified.

3 Generating Glossary Information

The standard LATEX command \makeglossary (analogous to \makeindex) should\makeglossary

be placed in the document preamble. If this command is omitted, glossary in-formation will be ignored. Glossary entries are generated using the command\glossary{〈key-val list〉}. This command is a slightly modified version of the\glossary

standard \glossary command, in order to separate out the information into〈entry-name〉 and 〈entry-description〉. The argument to \glossary must be acomma-separated list of 〈key〉=〈value〉 pairs. The following keys are available:

Key Valuename The entry namedescription A description about the entrysort How to sort the entry. (Entry name used if sort omitted)format How to format the page numbernumber Override the page number with a different counter. The value

should be the name of a counter (e.g. number=section).

For example:

\glossary{name={singular matrix},

description={A matrix with zero determinant}}

The following example sorts on the text U instead of $\mathcal{U}$:

\glossary{name={$\mathcal{U}$},

description={The universal set},

sort=U}

Note that you should always use the sort key if the name key contains com-mands, this is particularly important if you are using hyperlinks, as the target isconstructed from the name key if the sort key is omitted.

In the glossary, each entry is followed by a list of page numbers that corre-spond to the pages where the relevant \glossary command is placed. By defaultthe numbers are formatted in the current font, but the page number format for

1and you can also remove the .pl extension which isn’t to everyone’s liking.

3

Page 4: glossary

individual entries can be changed using the format key. This should be the nameof a LATEX formatting command without the preceding \ (as with the | operatorin \index.) For example:

\glossary{name={$\mathbb{R}$},

description={The set of real numbers},

sort=R,

format=textbf}

In addition, the following formats are also available:

hyperrm The number is a hyper link in romanhypersf The number is a hyper link in sans-serifhypertt The number is a hyper link in typewriter fonthyperbf The number is a hyper link in boldhypermd The number is a hyper link in medium weighthyperit The number is a hyper link in italichypersl The number is a hyper link in slanted fonthyperup The number is a hyper link in upright fonthypersc The number is a hyper link in small capshyperem The number is a hyper link using \emph

If the hyper option has not been set, hyperem is equivalent to emph, and theremaining hyperrm etc are equivalent to textrm etc. Note that it is importantthe you use hyperrm instead of hyperpage, as the \hyperpage command won’twork on a list or range of numbers in the glossary 2. If you want to define yourown command that uses hyper links, it must be defined in an analogous mannerto \hyperrm. For example, if you want to display a page number in a bold italicformat, that contains a hyperlink to the appropriate page, you would need todefine it as follows:

\newcommand{\hyperbfit}[2][\gls@number]{%

\textbf{\itshape\glshyper{#1}{#2}}}

As can be seen from the definition, all the \hyper〈xx 〉 commands have an optionalargument. This argument is the name of the counter being used. You do notneed to worry about this argument if you only use these commands within the\glossary command. So the previous example can simply be rewritten as:

\glossary{name={$\mathbb{R}$},

description={The set of real numbers},

sort=R,

format=hyperbf}

Note: although the numbers in the glossary are referred to as “page” numbersin this manual, they may in fact refer to some other counter, such as the sectioncounter, depending on whether the number key has been used.

As with the \index command, care must be taken if you want to use the specialcharacters: @ | " and !. These characters should be preceded by the double quotecharacter. For example:

\glossary{name={$"|\mathcal{S}"|$,

description=The cardinality of the set \mathcal{S}}}

2This is because the list and number ranges are delimited using \delimR and \delimN insteadof explicitly using a comma or en-dash.

4

Page 5: glossary

There is no provision for sub-entries, as these are generally only applicable in anindex, and not in a glossary.

As from version 2.14, there is an additional command available:\xglossary

\xglossary{〈gls-entry〉 }{〈text〉}

This is equivalent to〈text〉\glossary{〈gls-entry〉}, where 〈text〉 will be made ahyper link to the relevant entry in the glossary, if hyper links are supported.

3.1 Storing Glossary Information

It is very cumbersome having to use the \glossary command throughout yourdocument, every time you use a term that you want in your glossary. This isparticularly true for terms with a long description. The glossary package providesa means of storing the glossary information at the beginning of the document,and then using it whenever required. It is strongly recommended that you usethis approach, rather than explicity using the \glossary command.

The following command:\storeglosentry

\storeglosentry[〈gls-type〉]{〈label〉}{〈gls-entry〉}

can be used to store glossary information, where 〈label〉 is a unique label assignedto this entry. The information can then be used later with any of the followingcommands:

\useglosentry[〈opt〉]{〈label〉}\useglosentry

\useGlosentry[〈opt〉]{〈label〉}{〈text〉}\useGlosentry

\gls[〈opt〉]{〈label〉}\gls

\useglosentry adds the glossary entry whose label is given by 〈label〉 to theappropriate glossary, \useGlosentry adds the glossary entry, and makes 〈text〉 ahyperlink to that entry (if hyperlinks are supported). The third command, \gls,is like \useGlosentry, but forms 〈text〉 from the name given in the glossary entry.

Returning to an earlier example, instead of typing:

\glossary{name={$\mathcal{U}$},

description={The universal set},

sort=U}

every time you want to add this entry to the glossary, you can instead store theinformation:

\storeglosentry{glos:U}{name={$\mathcal{U}$},

description={The universal set},

sort=U}

Now, instead of continually copying and pasting the glossary command for thisentry (which can have quite a large description field), you can use either:

\useglosentry{glos:U}

which is equivalent to:

\glossary{name={$\mathcal{U}$},

description={The universal set},

sort=U}

5

Page 6: glossary

or you can use:

\useGlosentry{glos:U}{text}

which is equivalent to:

\xglossary{name={$\mathcal{U}$},

description={The universal set},

sort=U}{text}

or you can use:

\gls{glos:U}

which is equivalent to:

\xglossary{name={$\mathcal{U}$},

description={The universal set},

sort=U}{$\mathcal{U}$}

If you want to use glossary entries in an equation, it is better to use \ensuremathinstead of $. . . $. For example:

\storeglosentry{Gamma}{name=\ensuremath{\Gamma(z)},

description=Gamma function,

sort=Gamma}

You can then use this entry in either text or math mode:

The \useGlosentry{Gamma}{Gamma function} is defined as

\begin{equation}

\gls{Gamma} = \int_{0}^{\infty}e^{-t}t^{z-1}\,dt

\end{equation}

If you are using hyper links, and you want to use \useGlosentry within mathmode, you must use \ensuremath:

\begin{equation}

\useGlosentry{Gamma}{\ensuremath{\Gamma(x+1)}} = x\Gamma(x)

\end{equation}

The optional argument to \storeglosentry (〈gls-type〉) indicates the glossarytype (see section 7 to find out how to define new glossary types). If omitted, thestandard glossary is used.

The optional argument to \useglosentry, \useGlosentry and \gls (〈opt〉)allows you to add additional information to the glossary entry, for example:

\useglosentry[format=textbf]{glos:U}

is equivalent to:

\glossary{name={$\mathcal{U}$},

description={The universal set},

sort=U,

format=textbf}

Since version 2.4, \storeglosentry is robust, and \protect should no longerbe needed, however the identifying label, 〈label〉, should not contain any specialcharacters.

As from version 2.36, if you want to use all glossary entries which have beendefined using \storeglosentry, do: \useglosentry{*}. (Note that this optionis not available for \useGlosentry and \gls.)

6

Page 7: glossary

4 makeglos.pl

Whenever a glossary entry is used, either explicity using \glossary or \xglossaryor implicitly using \useglosentry, \useGlosentry and \gls, the information issaved in a file with the extension glo (unless the \makeglossary command isomitted, in which case the glossary information is simply ignored.) A makeindexstyle file (ist) is also created, which is customized for the document, and can bepassed to makeindex.

For example, suppose your document is called mydoc.tex, the glossary willbe saved in the file mydoc.glo, and the makeindex style file mydoc.ist will becreated. These files can then be passed to makeindex as follows:

makeindex -s mydoc.ist -t mydoc.glg -o mydoc.gls mydoc.glo

which generates the output file mydoc.gls, with transcript written to mydoc.glg.The Perl script makeglos.pl provided with this package allows you to use

makeindex without having to remember all the command line options. The com-mand

makeglos.pl mydoc

will perform the command:

makeindex -s mydoc.ist -t mydoc.glg -o mydoc.gls mydoc.glo

In addition, makeglos.pl also takes the option -m which can be used to collateentries where the same name has multiple descriptions.

makeglos.pl has the following syntax:

makeglos.pl [-ilqrgm] [-s sty] [-o gls] [-t log] [-p num] <filename>

where all switches, apart from -m are the same as those for makeindex. If thereare multiple glossary types (see section 7) and the file extension is omitted,makeglos.pl will iterate through each glossary type (it will pick up the relevantinformation from the auxiliary file).

The name of the ist file can be changed by redefining the command\istfilenamebefore \makeglossary. For example:\istfilename

\renewcommand{\istfilename}{foo.ist}

\makeglossary

Only one ist file will be created per document, even if you have multiple glossarieswith different styles. The only circumstance where you will need multiple istfiles for a single document is when you have multiple glossaries that use differentcounters with different compositors, but this is rarely likely to occur.

Creation of the ist file can be suppressed by issuing the command \noist\noist

before \makeglossary. It will also be suppressed when the command \nofilesis used, or if the command \makeglossary is omitted.

It should be noted that there are a few packages that can cause problemswith the creation of the ist file, for example ngerman. If you encounter problemswhen LATEX is processing the \makeglossary command, or if you get errors frommakeindex complaining about the style file, this is the most probable cause. Seesection 12, item 16 for information on how to fix this.

7

Page 8: glossary

5 Displaying the Glossary

Once the gls file has been created by makeindex (as described in the previoussection) the glossary can then be included in the document with the command\printglossary. If chapters are defined, the glossary will start with\printglossary

\chapter*{\glossaryname}

If not, it will start with

\section*{\glossaryname}

The format of the main body of the glossary depends on the options passed to thepackage.

6 Package Options

The package options must be specified as a comma-separated list of 〈key〉=〈value〉pairs. Available options are:

style The glossary style. Values:

list use description environment in the glossary

altlist modified version of style=list. The description starts on the linefollowing the name of the term being defined.

super use supertabular environment in the glossary

long use longtable environment in the glossary (Default)

header Glossary header. Values:

none The glossary doesn’t have a heading (Default)

plain The glossary has a heading

border Glossary border. Values:

none The glossary doesn’t have a border (Default)

plain Border around the main body of the glossary

cols Number of columns. Values:

2 The entry name and description are in two separate columns with theassociated page numbers in the same column as the description. (De-fault)

3 The entry name, description and associated page numbers are in threeseparate columns.

number Associated number corresponding to each entry. This may either bethe keyword none indicating that the corresponding numbers should besuppressed, or it can be the name of a LATEX counter. The default isnumber=page.

toc Boolean variable:

8

Page 9: glossary

true Add glossary to table of contents

false Omit glossary from table of contents (Default)

Note that if you specify this option, you will need to run LATEX twice aftergenerating the glossary.

hypertoc Boolean variable. This is similar to the package option toc, but if youare using the hyperref package, hypertoc will generate a link to the pointimmediately before the glossary title, whereas toc will have a hyperlink tojust after the glossary title. Note that you can not use both toc=true andhypertoc=true. Default value: hypertoc=false.

hyper Boolean variable:

true Make associated numbers in the glossary a hypertext link, and alsomake acronyms, and the text given by \xglossary have a hyperlink totheir corresponding entries in the glossary.

false Don’t make associated numbers a hypertext link

If the hyperref or html package has been loaded prior to loading glossary.sty,hyper=true is set, otherwise the default is hyper=false. Note that thispackage option now encompasses the old hyperacronym option.

section Boolean variable:

true Make the glossary an unnumbered section, even if chapters are defined

false Only make glossary an unnumbered section if chapters are not defined(default).

acronym Boolean variable:

true Make the list of acronyms separate from the main glossary.

false The acronyms will all be placed in the main glossary. (Default)

global Boolean variable:

false Acronym commands only have a local effect. (Default)

true Acronym commands have a global effect.

The border, header and cols options should not be used in conjunction withstyle=list or style=altlist, as they only make sense with one of the tabular-style options. The value for the boolean variables can be omitted if they are tobe set. For example toc is equivalent to toc=true. Note that the altlist styleis better suited to glossaries with long entry names.

You can set up your own preferred defaults in a configuration file . The file mustbe called glossary.cfg and should be placed somewhere on the TEX path. In thisfile you can use the command \glossarypackageoptions{〈option-list〉} where\glossarypackageoptions

〈option-list〉 is a comma-separated list of 〈key〉=〈value〉 pairs, as passed to theglossary package. Note that this command may only be used in the configurationfile.

9

Page 10: glossary

6.1 Examples

Suppose the document has the following \glossary commands:

Page Command1 \glossary{name=diagonal matrix,

description=Matrix whose only non-zeroentries are along the leading diagonal}

2 \glossary{name=identity matrix,description=Diagonal matrix with 1s along theleading diagonal}

4 \glossary{name=singular matrix,description=Matrix with zero determinant}

Variations:

1. If style=list is chosen, the glossary will look like:

diagonal matrix Matrix whose only non-zero entries are along the leadingdiagonal, 1

identity matrix Diagonal matrix with 1s along the leading diagonal, 2

singular matrix Matrix with zero determinant, 4

2. If style=altlist is chosen, the glossary will look like:

diagonal matrixMatrix whose only non-zero entries are along the leading diagonal, 1

identity matrixDiagonal matrix with 1s along the leading diagonal, 2

singular matrixMatrix with zero determinant, 4

3. If style=list,number=none is chosen, the glossary will look like:

diagonal matrix Matrix whose only non-zero entries are along the leadingdiagonal

identity matrix Diagonal matrix with 1s along the leading diagonal

singular matrix Matrix with zero determinant

4. If style=long,border=none, header=none,number=page is chosen (default),the glossary will look like:

diagonal matrix Matrix whose only non-zero entries are along theleading diagonal, 1

identity matrix Diagonal matrix with 1s along the leading diago-nal, 2

singular matrix Matrix with zero determinant, 4

10

Page 11: glossary

5. If style=long,border=plain, header=none is chosen, the glossary will looklike:

diagonal matrix Matrix whose only non-zero entries are along theleading diagonal, 1

identity matrix Diagonal matrix with 1s along the leading diago-nal, 2

singular matrix Matrix with zero determinant, 4

6. If style=long,border=plain, header=plain is chosen, the glossary willlook like:

Notation Description

diagonal matrix Matrix whose only non-zero entries are along theleading diagonal, 1

identity matrix Diagonal matrix with 1s along the leading diago-nal, 2

singular matrix Matrix with zero determinant, 4

7. If style=long,border=none, header=plain,cols=3 is chosen, the glossarywill look like:

Notation Description

diagonal matrix Matrix whose only non-zero entries are along theleading diagonal

1

identity matrix Diagonal matrix with 1s along the leading diago-nal

2

singular matrix Matrix with zero determinant 4

7 Defining New Glossary Types

A new type of glossary can be defined using the command:\newglossarytype

\newglossarytype[〈log-ext〉]{〈name〉}{〈out-ext〉}{〈in-ext〉}[〈style list〉]For example, suppose you want your document to have a separate index of termsand index of notation, you could use \makeglossary, \glossary, \xglossary and\printglossary for the first glossary, and define a new type of glossary called say,notation, using

\newglossarytype[nlg]{notation}{not}{ntn}

11

Page 12: glossary

which will create the analogous commands: \makenotation, \notation, \xnotationand \printnotation which can be used for the second glossary.

As from version 2.3, \newglossarytype now has an additional optional argu-ment 〈style list〉. This should be a comma separated list of 〈key〉=〈value〉 pairsthat can be used to specify the style of the new glossary. If omitted, the newglossary will have the same format as the main glossary. The following optionsare available: number, style, header, border and cols. These can take the samevalues as those given in the package options (described in section 6).

The command \newglossarytype should only occur in the preamble. Thenew commands \make〈name〉, \〈name〉, \x〈name〉 and \print〈name〉 all havethe same format as their “glossary” counter-parts.

The glossary information will be saved to a file with the extension given by〈out-ext〉 (analogous to glo), which can then be passed to makeindex either di-rectly or via makeglos.pl, and the file to be read in (i.e. the file created bymakeindex) will have the extension 〈in-ext〉 (analogous to gls).

The optional argument 〈log-ext〉 indicates the extension for the makeindex logfile, if omitted the extension glg is used. This is not used by LATEX, howevermakeglos.pl reads in this information from the LATEX auxiliary file and passes itto makeindex.

For the above notation example, if your document is called, say, mydoc.tex,you will need to do the following:

latex mydoc

makeglos.pl mydoc

latex mydoc

(You may need to do an extra latex mydoc to get cross-references up-to-date.)Note that if you don’t specify the file extension when using makeglos.pl, it willcheck the transcript file from the LATEX run to determine all the glossary types,so, for this example,

makeglos.pl mydoc

is equivalent to:

makeglos.pl mydoc.glo

makeglos.pl mydoc.not

since makeglos.pl has read in the information for the notation glossary typefrom the file mydoc.log.

If you don’t have Perl installed on your system, or for any other reason areunable to use makeglos.pl, you can call makeindex explicitly:

latex mydoc

makeindex -s mydoc.ist -t mydoc.glg -o mydoc.gls mydoc.glo

makeindex -s mydoc.ist -t mydoc.nlg -o mydoc.ntn mydoc.not

latex mydoc

Note that you can use the command \printglossary[〈name〉] instead of\print〈name〉. These two commands have the same effect when using LATEX,however, they have a slightly different effect when using LATEX2HTML (see sec-tion 11).

If the command \〈glossary-type〉name is defined, (e.g. \notationname in theabove example) this will be used as the title for the specified glossary. If this

12

Page 13: glossary

command is not defined, \glossaryname will be used instead. If the com-mand \short〈glossary-type〉name is defined, (e.g. \shortnotationname in theabove example) this will be used for the table of contents entry, otherwise\〈glossary-type〉name will be used instead. For example:

\newglossarytype[nlg]{notation}{not}{ntn}

\newcommand{\notationname}{Index of Notation}

\newcommand{\shortnotationname}{Notation}

8 Acronyms

The glossary package provides the command:\newacronym

\newacronym[〈cmd-name〉]{〈acronym〉}{〈long〉}{〈glossary entry〉}which can be used to define acronyms. The argument 〈long〉 is the full name, theargument 〈acronym〉 is the acronym for 〈long〉 and 〈glossary entry〉 is the glos-sary information in the form used by the \glossary command. If the optionalargument 〈cmd-name〉 is missing, \newacronym will create a command called\〈acronym〉, otherwise it will create a command called \〈cmd-name〉 (henceforthdenoted \〈acr-name〉). This command can then be used throughout the text. Thefirst instance of this command is equivalent to:

〈long〉 (\xacronym{name=〈long〉 (〈acronym〉),〈glossary entry〉}{〈acronym〉})

subsequent instances will be equivalent to:

\xacronym{name=〈long〉 (〈acronym〉),〈glossary entry〉}{〈acronym〉}

The command \〈acr-name〉 also has a starred version, which will make the firstletter of 〈long〉 uppercase (for use at the start of a sentence).

Note that if you want to change the format of the acronym, for example, ifyou want the acronym to appear in small caps, you will need to not only use theoptional argument, but you will also need to use the sort key, otherwise you willget an error. For example:

\newacronym[SVM]{\textsc{svm}}{Support Vector Machine}%

{description=Statistical pattern recognition

technique,sort=svm}

If the package option acronym is not set (default) \xacronym, is a synonymfor \xglossary, and the acronyms will appear in the main glossary (remem-ber to specify \makeglossary and \printglossary). If the package optionacronym=true is specified, a new glossary type called acronym will be definedas:

\newglossarytype[alg]{acronym}{acr}{acn}

\providecommand{\acronymname}{List of Acronyms}

You will then need to use the commands \makeacronym and \printacronym tomake the list of acronyms appear. You will also need to run the acr file throughmakeindex (or makeglos.pl). For example:

makeindex -s mydoc.ist -t mydoc.alg -o mydoc.acn mydoc.acr

13

Page 14: glossary

alternatively:

makeglos.pl mydoc

Note that the package option acronym=true is only appropriate if you want botha glossary and a separate list of acronyms. If you do not write in English, youcan set up your own language definition for \acronymname in the configurationfile glossarycfg. For example:

\newcommand{\acronymname}{Akronyme}

(If glossary.cfg does not exist, create a new file, add the appropriate definitionof \acronymname, and save it to the same directory as glossary.sty.)

The name key does not need to appear in 〈glossary entry〉, as it is con-structed from 〈long〉 and 〈acronym〉. By default this will be in the form: 〈long〉(〈acronym〉), however the format can be overridden using the command:\setacronymnamefmt

\setacronymnamefmt{〈format〉}

Within 〈format〉 the following commands may be used to represent 〈long〉 and〈acronym〉: \glolong and \gloshort. For example, suppose you just want the\glolong

\gloshort acronym to appear in the glossary entry, and not its full length name, then youwould need to do:

\setacronymnamefmt{\gloshort}

As from version 2.32, you can also modify the way the description key isformatted for acronyms using:\setacronymdescfmt

\setacronymdescfmt{〈format〉}

Within 〈format〉 you may use the commands \glolong and \gloshort (as above),and you can also use the command \glodesc which is the description as specifiedby the description key in \newacronym. This means that if you are using atabular style glossary, you can have the abbreviated form in one column and thelong form in the second column with the description. For example, the following:

\setacronymnamefmt{\gloshort}

\setacronymdescfmt{\glolong: \glodesc}

\newacronym{svm}{support vector machine}{description=Statistical

pattern recognition technique}

will generate a glossary entry of the form:

\glossary{name=svm,description=support vector machine: Statistical

pattern recognition technique}

Note that if you omit \glodesc from \setacronymdescfmt the description spec-ified in \newacronym will be ignored. So

\setacronymnamefmt{\gloshort}

\setacronymdescfmt{\glolong}

\newacronym{svm}{support vector machine}{description=Statistical

pattern recognition technique}

will generate a glossary entry of the form:

\glossary{name=svm,description=support vector machine}

14

Page 15: glossary

You will need to specify the name key explicitly if the name contains amakeindex special character. For example:

\newacronym{RNA}{Ribonukleins\"aure}{name={Ribonukleins\""aure (RNA)}}

Note that this will override any formatting specified by \setacronymnamefmt.Given an acronym named 〈acr-name〉 (the command name associated with

the acronym as defined in \newacronym without the preceding backslash), thefollowing commands are also available:

\useacronym[〈insert〉]{〈acr-name〉}\useacronym

This command can be used instead of \〈acr-name〉. \useacronym also has astarred version equivalent to \〈acr-name〉*. The optional argument 〈insert〉 allowsyou to insert text after 〈long〉, if this is the first occurrence of the acronym, orafter the acronym on subsequent occurrences.

\resetacronym{〈acr-name〉}\resetacronym

This command will cause the next use of \〈acr-name〉 to produce the long version.To reset all acronyms do \resetallacronyms.\resetallacronyms

\unsetacronym{〈acr-name〉}\unsetacronym

This command will cause all subsequent uses of \〈acr-name〉 to produce the shortversion. To unset all acronyms do \unsetallacronyms.\unsetallacronyms

\ifacronymfirstuse {〈acr-name〉 }{〈true text〉}{〈false text〉}\ifacronymfirstuse

This will test if the acronym has been used yet. If it has been used, 〈true text〉will be implemented, otherwise 〈false text〉 will be implemented.

The long and short forms of an acronym can be produced explicitly without acorresponding glossary entry, using the commands:

\acrln{〈acr-name〉}\acrln

\acrsh{〈acr-name〉}\acrsh

Or, alternatively:

\〈acr-name〉long\〈acr-name〉short

The first two commands (\acrln and \acrsh) have a starred form that makesthe first letter uppercase. The other two commands, simply contain 〈long〉 and〈acronym〉.

Note that since these four commands do not generate glossary entries they willtherefore not contain any hyperlinks, even if you have specified the hyper packageoption. They are provided for use in situations where the associated glossarycommand may cause problems (e.g. in a sectioning command.)

Note that, as with all LATEX commands, spaces following command names areignored so if, for example, you defined a new acronym called, say, SVM, then thecommand \SVM will ignore any spaces following it. To force a space, you can eitherplace an empty set of braces after the command name (e.g. \SVM{}) or use \ i.e.

15

Page 16: glossary

a backslash followed by a space (e.g. \SVM\ ). Alternatively, as from version 2.22,if you load the xspace package before loading the glossary package, spaces will beput in automatically using \xspace.

If you want the acronym to appear in a particular font, for example, small\acronymfont

caps, you can redefine the command \acronymfont. For example:

\renewcommand{\acronymfont}[1]{\textsc{#1}}

The default definition of \acronymfont is:

\newcommand{\acronymfont}[1]{#1}

8.1 Examples

\newacronym{SVM}{Support Vector Machine}{description=Statistical

pattern recognition technique}

This will define the command \SVM. The first time this command is used willdisplay the text: Support Vector Machine (SVM). Subsequent use will simplydisplay: SVM. The next example uses the optional argument 〈cmd-name〉 sincethe acronym contains a non-alphabetical character:

\newacronym[KSVM]{K-SVM}{Kernel Support Vector

Machine}{description=Statistical pattern recognition

technique using the ‘‘kernel trick’’}

This will define the command \KSVM. The first time this command is used willdisplay the text: Kernel Support Vector Machine (K-SVM). Subsequent use willsimply display: K-SVM.

To test whether or not an acronym has been used:

\ifacronymfirstuse{SVM}{a}{an} \SVM\ is \ldots

If the acronym has not been used, the following text will be produced:

a Support Vector Machine is . . .

otherwise it will produce:

an SVM is . . .

To expand the acronym a second time:

\chapter{An overview of the \protect\SVM}

\resetacronym{SVM}

The \SVM\ \ldots

Note the use of \protect (see note 15 on page 26.) In fact, in this situation itwould be better to do:

\chapter[An overview of the \SVMlong]{An overview of the \protect\SVM}

\resetacronym{SVM}

The \SVM\ \ldots

16

Page 17: glossary

Now suppose you want the text: support vector machine, instead of SupportVector Machine (i.e. you don’t like the uppercase letters). You can define theacronym as follows:

\newacronym{SVM}{support vector machine}{description=Statistical

pattern recognition technique}

however, if the command \SVM occurs at the start of the sentence, you wouldclearly want the first letter as an uppercase letter. This can be done using \SVM*instead of \SVM. For example:

\SVM*\ techniques are widely used \ldots

This will then come out as: Support vector machine (SVM) techniques are widelyused . . . (Assuming this is the first use of either \SVM or \SVM*.)

Alternatively, \useacronym{SVM} can be used instead of \SVM. For example:

\useacronym*[s]{SVM} are widely used in the area of pattern

recognition.

If this is the first use of the acronym SVM, it will produce the following text:

Support vector machines (SVM) are widely used in the area of pattern recognition.

If this is not the first use of this acronym, it will produce the following text:

SVMs are widely used in the area of pattern recognition.

9 Customizing the Glossary

The glossary package provides commands which can be redefined to customize theglossary. The following name commands are defined by this package:

Command Default Value\glossaryname Glossary\shortglossaryname \glossaryname\entryname Notation\descriptionname Description

\glossaryname

\entryname

\descriptionname

The commands \entryname and \descriptionname are put in the first twocolumns of the header row if you are using one of the tabular glossary stylestogether with a header row (as specified by the header=true package option).If you are using cols=3, the command \glspageheader will be put in the third\glspageheader

column of the header row. By default, this command does nothing.The command \shortglossaryname is used for the page headers and table\shortglossaryname

of contents entry. Any text required before or after the glossary can be addedby redefining the commands \glossarypreamble and \glossarypostamble. For\glossarypreamble

\glossarypostamble example.

\renewcommand{\glossarypreamble}{Page numbers in

italic indicate the main definition\par}

17

Page 18: glossary

By default, \glossarypreamble and \glossarypostamble do nothing.Any text required before or after the list of page numbers are specified by the

commands \glsbeforenum and \glsafternum. By default, these commands do\glsbeforenum

\glsafternum nothing, any redefinition of these commands should come somewhere before therelevant \printglossary command. For example:

\printglossary

\renewcommand{\glsbeforenum}{(}

\renewcommand{\glsafternum}{)}

\printnotation

This will put the page number list in brackets for the second glossary, but not thefirst.

Individual glossaries can have their styles changed either by setting the stylein the final optional argument to \newglossarystyle (see section 7) or using thecommand:setglossarystyle

\setglossarystyle[〈type〉]{〈style list〉}

For example:

\setglossarystyle[acronym]{style=long,border=true,cols=2}

If 〈type〉 is omitted, the change is applied to the main glossary.The command \setglossary{〈key-val list〉} can be used to modify some of\setglossary

the glossary settings. The argument 〈key-val list〉 is a comma-separated list of〈key〉=〈value〉 pairs. Available keys are:

type This is the glossary type. If it is omitted, the standard glossary is assumed.

glsnumformat This is the name of the command, without the preceding back-slash3, to format the entry numbers. For example, to make all the entrynumbers italic, do:

\setglossary{glsnumformat=textit}

To suppress numbering altogether, you can do:

\setglossary{glsnumformat=ignore}

glodelim This specifies what to do after the entry description and before thepage numbers. The default value is a comma, unless the cols=3 option isspecified, in which case it has the value &, or if style=altlist, in whichcase it is simply a space4. If the package option number=none is specified,glodelim will have an empty value (unless cols=3 is specified, where, again,it will have the value &.) This setting corresponds to the delim 0 key in themakeindex style file.

Note that if you want a new line between the description and the list of pagenumbers you will need to use \noexpand. For example:

\setglossary{glodelim={\noexpand\newline}}

3Note, you should no longer try redefining the command \glsnumformat, as this now takesan optional argument, allowing for different glossary types

4This is because the altlist style is intended for use with long descriptions that will lookbetter ending with a full stop which the user can add if desired.

18

Page 19: glossary

delimN The delimiter to be inserted between two page numbers for the sameentry. (This corresponds to the delim n key in the makeindex style file.)By default, this has the value , (comma followed by a space). If the packageoption number=none is chosen, the value is set to empty.

delimR The delimiter to be inserted between the starting and ending page numberrange for the same entry. (This corresponds to the delim r key in themakeindex style file.) By default, this has the value --. If the packageoption number=none is chosen, the value is set to empty.

gloskip This specifies what to do between groups. If style=list or style=altlistthis has the value \indexspace, otherwise it creates a blank row in thelongtable or supertabular environment. This command corresponds to thegroup skip key in the makeindex style file. Note that as from version 2.3,you should no longer redefine the command \gloskip.

delimT The text to be inserted after the list of page numbers for an entry. (Thiscorresponds to the delim t key in the makeindex style file.) The defaultvalue depends on the glossary style. It does nothing for the list-type styles,and has the value \\ for the tabular-type styles. Note that delimT is separatefrom \glsafternum.

For example, if you are using a 2 column tabular style, and you want a blankline after every entry (not just after every group) you can do the following:

\setglossary{delimT={\cr & \cr},gloskip={}}

Note the use of \cr instead of \\ and gloskip is set to nothing otherwisethere would be a double space between groups.

Note that:

\setglossary{glsnumformat=ignore}

is equivalent to

\setglossary{glsnumformat=ignore,delimN={},delimR={}}

As from version 2.4, you can insert text between groups by redefining thecommands \glogroupSymbols, \glogroupNumbers, \glogroupA . . . \glogroupZ.For example, if you are using one of the list styles, the following will print theappropriate heading in bold, followed by a gap:

\renewcommand{\glogroupSymbols}{\textbf{Symbols}\indexspace}

\renewcommand{\glogroupNumbers}{\textbf{Numbers}\indexspace}

\renewcommand{\glogroupA}{\textbf{A}\indexspace}

....% similar lines omitted

\renewcommand{\glosgroupZ}{\textbf{Z}\indexspace}

The start and end of the main body of the glossary is given by the commands:\beforeglossary and \afterglossary. If the style=list or style=altlist\beforeglossary

\afterglossary package options are chosen these commands simply begin and end the descriptionenvironment, otherwise these commands begin and end the longtable or supertab-ular environment with argument specified by \glossaryalignment5.\glossaryalignment

5This isn’t quite true anymore, see the documented code for clarification

19

Page 20: glossary

The glossary package no longer conflicts with the array package. Changescan now be made to \glossaryalignment regardless of whether or not the arraypackage has been used.

The command \gloitem indicates what to do at the start of each glossary\gloitem

entry. This command takes one argument, which will be the text specified bythe name key in the \glossary command. In the case of the style=list option,\gloitem{〈text〉} will do

\item[〈text〉]or if style=altlist:

\item[〈text〉]\mbox{}\parotherwise it will do

〈text〉 &

This command corresponds to the item 0 key in the makeindex style file.If the glossary has a tabular style with a header row (header=true and either

style=long or style=super), then the header row for cols=2 will be given by:

\bfseries\entryname & \bfseries \descriptionname\\

and the header row for cols=3 will be given by:

\bfseries\entryname & \bfseries\descriptionname &

\bfseries\glspageheader\\

(It may also contain \hline\hline if the border key is set.)If you want to override this, you need to define the command \glossaryheader6

.\glossaryheader

For example, if you are using a tabular style with cols=2, and you want the\descriptionname to be centred, you could do:

\newcommand{\glossaryheader}{\bfseries\entryname &

\hfil\bfseries\descriptionname\\}

If you want an extra row below the header row, you can define the com-mand\glossarysubheader For example, if you are using cols=3, and you want\glossarysubheader

an extra row after the header row, you can do:

\newcommand{\glossarysubheader}{ & & \\}

The command \glosstail indicates what to do at the end of the longtable or\glosstail

supertabular environment.The width of the second column for the tabular-type styles is given by the

length \descriptionwidth. This value can be changed using the \setlength\descriptionwidth

command (the default value is 0.6\linewidth).

10 Sample Documents

This package comes with the following sample documents:6Note that as from version 2.4, you must use \newcommand not \renewcommand

20

Page 21: glossary

• sampleSec.tex — This document uses the options: style=altlist, tocand number=section. It also loads the hyperref package before loading theglossary package, so the glossary has hyperlinks to the section numbers. Ex-perimenting with different package options, will illustrate the different glos-sary styles. You will need to do:

pdflatex sampleSec

makeglos.pl sampleSec

pdflatex sampleSec

pdflatex sampleSec

If you don’t want to use makeglos.pl, you will need to do

makeindex -s sampleSec.ist -t sampleSec.glg -o sampleSec.gls sampleSec.glo

• sampleNtn.tex — This has a glossary and defines a new glossary type callednotation. The glossary has associated page numbers, but the new glossarytype doesn’t. The two glossaries have different styles. You will need to do:

latex sampleNtn

makeglos.pl sampleNtn

latex sampleNtn

latex sampleNtn

If you don’t want to use makeglos.pl, you will need to do

makeindex -s sampleNtn.ist -t sampleNtn.glg -o sampleNtn.gls sampleNtn.glo

makeindex -s sampleNtn.ist -t sampleNtn.nlg -o sampleNtn.ntn sampleNtn.not

• sampleNtn2.tex —This is similar to sampleNtn.tex, but uses \storeglosentry.

• sampleEq.tex — This has a glossary where the numbers in the glossary re-fer to the equation number rather than the page number (achieved with thepackage option number=equation). The \entryname, \descriptionname,\glossaryname and \glspageheader are all redefined to customize the glos-sary. You will need to do:

latex sampleEq

makeglos.pl sampleEq

latex sampleEq

If you don’t want to use makeglos.pl, you will need to do

makeindex -s sampleEq.ist -t sampleEq.glg -o sampleEq.gls sampleEq.glo

• sampleEqPg.tex — This is a modified version of sampleEq.tex. This ex-ample has one glossary, where some of the entry numbers refer to the cor-responding page number, and some of the entry numbers refer to the corre-sponding equation number. You will need to do:

latex sampleEqPg

makeglos.pl sampleEqPg

latex sampleEqPg

21

Page 22: glossary

If you don’t want to use makeglos.pl, you will need to do

makeindex -s sampleEqPg.ist -t sampleEqPg.glg -o sampleEqPg.gls sampleEqPg.glo

• sampleAcr.tex — This has a glossary containing acronyms. It uses the stylealtlist as this is better suited to glossaries with long names. It also usesthe hyperref package, so the page numbers in the glossary will automaticallybe hyperlinks, and the acronyms within the text will have hyperlinks to theircorresponding entry in the glossary. You will need to do:

pdflatex sampleAcr

makeglos.pl sampleAcr

pdflatex sampleAcr

pdflatex sampleAcr

If you don’t want to use makeglos.pl, you will need to do

makeindex -s sampleAcr.ist -t sampleAcr.glg -o sampleAcr.gls sampleAcr.glo

• sample.tex — This has a glossary entry with two different definitions of thesame name. If you just use makeindex, the two entries will be treated sep-arately, however, if you want them concatenated, you can use makeglos.plwith the -m switch. You will need to do:

pdflatex sample

makeglos.pl -m sample

pdflatex sample

pdflatex sample

(Depending on the configuration of your system, you may have to do perlmakeglos.pl instead of just makeglos.pl)

If you don’t want to use makeglos.pl, you will need to do

makeindex -s sample.ist -t sample.glg -o sample.gls sample.glo

however, the entries with the same name but multiple descriptions will notbe merged. You will also have to given them different sort keys otherwiseyou will get duplicate hyper targets.

• sample4col.tex—This illustrates how to modify the glossary style so thatit has 4 columns. You will need to do:

latex sample4col

makeglos.pl sample4col

latex sample4col

11 LaTeX2HTML Style File

A LATEX2HTML Perl script, glossary.perl, is provided with this package forthose wishing to use the glossary package with the LATEX2HTML translator. Thefile glossary.perl should be extracted along with glossary.sty when you runthe installation script (glossary.ins) through LATEX.

22

Page 23: glossary

11.1 Limitations

• The only package options supported are: style=altlist, hyper=true,toc=true, acronym=true and acronym=false.

• If you have more than one glossary type, the secondary glossaries will oc-cur in the same segment as the primary glossary if you use the command\print〈name〉 instead of \printglossary[〈name〉], where 〈name〉 is thename of the glossary type.

• The command \setglossary must be placed in the preamble to have aneffect.

• The \storeglosentry commands must be in the document environment tohave an effect. (They don’t seem to work in the preamble, I don’t knowwhy.)

• If you place a \glossary command inside an environment not translated byLATEX2HTML (for example, inside a mathematics environment), it will notbe entered into the glossary.

• The combinations "", "|, "! and "@ will be correctly translated, unless theyoccur within a maths environment. This is because the maths environmentis translated before being passed to \glossary. You can overcome this bydoing, e.g.:\begin{latexonly}\glossary{name=$"|\mathcal{S}"|$,description=cardinality of set$\mathcal{S}$,sort=cardinality}\end{latexonly}\begin{htmlonly}\glossary{name=$|\mathcal{S}|$,description=cardinality of set$\mathcal{S}$,sort=cardinality}\end{htmlonly}

Alternative, you can use \mid instead:

\glossary{name=$\mid\mathcal{S}\mid$,description=cardinality of

set $\mathcal{S}$,sort=cardinality}

• Glossary items with the same names but different definitions will not bemerged.

• The configuration file glossary.cfg is ignored.

12 Troubleshooting

This is a list of common problems, for a more up-to-date FAQ, see http://theoval.cmp.uea.ac.uk/~nlct/packages/faq/.

1. My glossary hasn’t appeared.

Check the following:

• Have you included the command \makeglossary in the preamble?

23

Page 24: glossary

• Have you put the command \printglossary where you want the glos-sary to appear?

• Have you used makeglos.pl or makeindex, and if you did, did it suc-cessfully create the gls file? (Check the transcript glg file.)

– If you used makeindex directly, did you specify the ist file createdby \makeglossary, and did you remember to specify the outputfile with the extension gls?

– When makeindex scans the ist file, it should generate the message:9 attributes redefined, 0 ignored

If you have a number other than 0 ignored, then there is somethingwrong with the ist file. Some packages can cause problems withthe creation of this file, see item 16 below.

• Have you remembered to LATEX your document again after usingmakeglos.pl or makeindex?

• Have you used \glossary or \xglossary?

• If you have used \storeglosentry, have you also used \useglosentry,\useGlosentry or \gls?

If you have defined a new glossary type, have you checked all the analogouscommands to the above?

2. My list of acronyms hasn’t appeared.

Have you used the acronym=true package option? If no, check the answersto the previous item, if yes, make sure you have used \makeacronym and\printacronym. Have you used any of the acronyms you have defined?Remember that \acrsh, \acrln, \〈acr-name〉short and \〈acr-name〉longdon’t generate entries in the list of acronyms, where \〈acr-name〉 is the nameof an acronym command.

3. My acronym has been expanded twice.

By default, if any of your acronym commands occur within a group (thisincludes environments which form implicit grouping) the effect will be localto that group. You can either unset the acronym outside the group, or usethe global package option.

4. I get an error when using the command \saveglosentry.

Don’t use this command it’s obsolete, use \storeglosentry instead.

5. One of more of my glossary entries hasn’t appeared.

Check the following

• If you defined the entry using \storeglosentry have you used either\useglosentry, \useGlosentry or \gls?

• Have you remembered to \protect commands such as \mathcal within\storeglosentry?

• Have you used the characters @ ! | "? If so, have you preceded themwith a double quote character?

24

Page 25: glossary

Check the makeindex log file to see if there are any error messages.

6. My glossary has duplicate entries on separate lines.

LATEX treats multiple spaces equivalent to a single space, but makeindextakes spaces into account when determining whether two entries are identical.For example:

\glossary{name=Identity matrix,

description=diagonal matrix with 1’s along the diagonal}

and

\glossary{name=Identity matrix,

description=diagonal matrix with 1’s along the diagonal}

will be treated as different entries by makeindex, because the first has onlyone space between ‘Identity’ and ‘matrix’ and the second has two. Theeasiest way to ensure consistency is to use \storeglosentry together with\useglosentry, \useGlosentry or \gls.

7. I had an error, fixed it, but I keep getting the same error message.

Suppose you’ve made an error in the \glossary command. For example:

\glossary{name=Java,description=A programming language,format=texbf}

In this case textbf has been mis-spelt. This error will be copied to theglo file, which in turn will be copied to the gls file by makeindex. Asubsequent run of LATEX will read this error in. If you fix the error in yourmain document, the error will still be read in from the gls file. The bestthing to do is to delete the gls file, and try again.

8. My glossary has ended up wider than my page.

This may occur if you have long entry names, and you are using eitherthe style=long or style=super options. The width of the description col-umn is proportional to the line width (in fact, it’s 0.6\linewidth) but thefirst column is as wide as the widest entry name. You can either redefine\glossaryalignment to change the column specifications, or use one of thelist-type styles.

9. The page numbers in my glossary don’t match up with the actual pagenumbers where the entry was defined.

You may need to LATEX your document again (just as you have to do with\tableofcontents, \listoffigures etc).

10. I’m getting a keyval error.

The glossary package uses the keyval package to extract the information from〈key〉=〈value〉 comma separated lists. You need to make sure the syntax iscorrect. If your 〈value〉 contains a comma, you will need to enclose 〈value〉in curly braces. See the keyval documentation for further information7.

7This should be in the directory texmf/doc/latex/graphics/

25

Page 26: glossary

11. I’ve used the hyper option, but nothing happens when I click on the numbersin the glossary.

Check the following:

(a) Have you remembered to use PDFLATEX instead of LATEX, or used adriver that understands hyperlinks?

(b) Have you remembered to use the hyperref or html package?(c) Have you remembered to use a formatting command which uses

\hyperlink? (E.g. using hyperbf instead of textbf)? Remem-ber to check the format key in your \glossary commands, and theglsnumformat key in the \setglossary command.

(d) What application are you using to view the PDF file? Ghostview candisplay a PDF file, but ignores the links. If you are using Windows, tryusing Adobe’s Acrobat Reader, or if you are using UNIX or Linux, tryusing xpdf or acroread.

12. The glossary package conflicts with the datetime package.

This has been fixed in version 2.01.

13. I get an error when using certain commands, such as \cite or ~ in\newacronym.

This has been fixed in version 2.1.

14. I get the following error:

! Package array Error: Illegal pream-token (\glossaryalignment): ‘c’ used.

The glossary package used to conflict with the array package. This was fixedin version 2.1. As from version 2.3, it doesn’t matter whether you load theglossary package before or after the array package.

15. I get the following error:

Use of \@chapter doesn’t match its definition

or

! Argument of \@sect has an extra }

If you want to use an acronym command in a moving argument (such asa chapter heading) you need to \protect it first. Note that if you do putan acronym in a chapter etc heading, it will be expanded for the first timein the table of contents, not in the chapter heading. The best way to getaround this is to use the optional argument, e.g.

\chapter[Introduction to Kernel Support Vector Machines]{Introduction

to \protect\KSVM}

You will also need to do this if you are using bookmarks in a PDF document.

Alternatively, you can do:

\resetacronym{KSVM}

\chapter{Introduction to \protect\KSVM}

26

Page 27: glossary

or if you are using PDFLaTeX:

\resetacronym{KSVM}

\chapter{Introduction to \texorpdfstring{\protect\KSVM}{KSVM}}

16. The glossary package conflicts with ngerman.

This problem is caused by the fact that ngerman redefines the effect of thedouble quote character, but this character is used in the creation of the istmakeindex style file. Try one of the following methods:

(a) Include the ngerman package after the \makeglossary command:

\usepackage{glossary}

\makeglossary

\usepackage{ngerman}

(b) First omit the ngerman package and include \makeglossary then LATEXyour document. This will create the ist file. Then include the ngermanpackage, and insert \noist before the \makeglossary command, thiswill prevent further attempts to generate the ist file.

\usepackage{ngerman}

\usepackage{glossary}

\noist\makeglossary

(c) Use \noist, as above, and create the ist file in an ordinary text editor.The file should contain the following lines:

keyword "\\glossaryentry"

preamble "\\begin{theglossary}"

postamble "\n\\end{theglossary}\n"

group_skip "\\gloskip "

item_0 "\n\\gloitem "

delim_0 "\n\\glodelim "

page_compositor "-"

delim_n "\\delimN "

delim_r "\\delimR "

It is possible that there may be other packages which will also cause a prob-lem, if so, try any of the above.

17. makeglos.pl gives the following error message:

unable to extract name from glossary item:

You are using an old version of makeglos.pl with a new version of theglossary package. You will need to update your version makeglos.pl.

Let me know if you encounter any other problems or if you have any commentsregarding this package.

27

Page 28: glossary

13 Obsolete Commands

The commands described in this section are now obsolete, but are currently stillprovided for backwards compatibility. Their use is deprecated.

\saveglosentry{〈name〉}{〈description〉}\saveglosentry

This command has now been replaced by \storeglosentry.The command \glsprimaryfmt has now been removed.\glsprimaryfmt

The package option hyperacronym is now superseded by the package optionhyper. This option was implemented prior to the introduction of the command\xglossary. Since the acronyms now use \xglossary, there is no differencebetween the hyperacronym and hyper options. This option has a boolean value:

true Make acronyms link to their corresponding entry in the glossary

false Acronyms don’t have a hyperlink.

If the hyperref package has been loaded prior to loading glossary.sty or ifhyper=true is set, hyperacronym=true otherwise hyperacronym=false.

14 Contact Details

Dr Nicola TalbotSchool of Computing SciencesUniversity of East AngliaNorwich. NorfolkNR4 7TJ. United Kingdom.http://theoval.cmp.uea.ac.uk/~nlct/

15 Acknowledgements

I would like to thank all the many people who have made suggestions and pointedout bugs.

16 The Code

〈∗glossary.sty〉

16.1 Package Definition

\NeedsTeXFormat{LaTeX2e}

\ProvidesPackage{glossary}[2006/07/20 2.4 (NLCT)]

Load packages needed by glossary.sty:\RequirePackage{ifthen}

\RequirePackage{keyval}

The package options are in the form of a comma-separated list of 〈key〉=〈value〉pairs. First need to set up the keys.

The style key. This may be one of list, altlist (use description environ-ment), super (use supertabular environment) or long (use longtable environment).

\define@key{gloss}

{style}

28

Page 29: glossary

{\ifthenelse{\equal{#1}{list} \or \equal{#1}{altlist}

\or \equal{#1}{super} \or \equal{#1}{long}}

{\def\gls@style{#1}}

{\PackageError{glossary}

{Unknown glossary style ’#1’}

{Available styles are: list, altlist, super and long}}}

The header key. This can either be none or plain. Should only be used inconjunction with super=style or style=long.

\define@key{gloss}

{header}[plain]{\ifthenelse{\equal{#1}{none} \or \equal{#1}{plain}}

{\def\gls@header{#1}}

{\PackageError{glossary}

{Unknown glossary style ’#1’}

{Available styles are: none and plain}}}

The border key. This can either be none or plain. Should only be used inconjunction with style=super or style=long.

\define@key{gloss}

{border}[plain]{\ifthenelse{\equal{#1}{none} \or \equal{#1}{plain}}

{\def\gls@border{#1}}

{\PackageError{glossary}

{Unknown glossary border ’#1’}

{Available styles are: none and plain}}}

Number of columns (either 2 or 3). Should only be used in conjunction withstyle=super or style=long.

\newcount\gls@cols

\define@key{gloss}{cols}{\gls@cols=#1\relax

\ifthenelse{\gls@cols<2 \or \gls@cols>3}

{\PackageError{glossary}

{invalid number of columns}

{The cols option can only be 2 or 3}}

{}}

The number key may either be none or the name of a counter.\define@key{gloss}

{number}

{\ifthenelse{\equal{#1}{none}}

{\def\gls@glossary@number{#1}}

{\@ifundefined{c@#1}{

\PackageError{glossary}

{Unknown glossary number style ’#1’}

{You may either specify "none" or the name of a counter,

e.g. "section"}\def\gls@glossary@number{page}}{\def\gls@glossary@number{#1}}}}

The toc key. If set, adds the glossary to the table of contents\newif\ifgls@toc

\define@key{gloss}{toc}[true]{\ifthenelse{\equal{#1}{true}

\or \equal{#1}{false}}

{\csname gls@toc#1\endcsname}

{\PackageError{glossary}{Glossary option ’toc’ is boolean}

{The value of ’toc’ can only be set to ’true’ or ’false’}}}

The hypertoc key. Like toc, but puts the anchor before the section head-ing. Should only be used if the hyperref package is used (because it uses\phantomsection).

\newif\ifgls@hypertoc

29

Page 30: glossary

\define@key{gloss}{hypertoc}[true]{%

\ifthenelse{\equal{#1}{true} \or \equal{#1}{false}}

{\csname gls@hypertoc#1\endcsname}

{\PackageError{glossary}{Glossary option ’hypertoc’ is boolean}

{The value of ’hypertoc’ can only be set to ’true’ or ’false’}}}

The section key. This will put the glossary in an unnumbered section, even ifchapters are defined.

\newif\ifgls@section

\define@key{gloss}{section}[true]{%

\ifthenelse{\equal{#1}{true} \or \equal{#1}{false}}

{\csname gls@section#1\endcsname}

{\PackageError{glossary}{Glossary option ’section’ is boolean}

{The value of ’section’ can only be set to ’true’ or ’false’}}}

\gls@sectionfalse

Enable hyperlinks. If hyperref or html packages loaded, hyper=true is the default.\newif\ifglshyper

\newif\ifglshyperacronym

\define@key{gloss}{hyper}[true]{%

\ifthenelse{\equal{#1}{true} \or \equal{#1}{false}}

{\csname glshyper#1\endcsname\glshyperacronymtrue}

{\PackageError{glossary}{Glossary option ’hyper’ is boolean}

{The value of ’hyper’ can only be set to ’true’ or ’false’}}}

Enable hyperlinks for acronyms. Deprecated: use hyper instead.\define@key{gloss}{hyperacronym}[true]{%

\ifthenelse{\equal{#1}{true} \or \equal{#1}{false}}

{\csname glshyperacronym#1\endcsname}

{\PackageError{glossary}{Glossary option ’hyperacronym’ is boolean}

{The value of ’hyperacronym’ can only be set to ’true’ or ’false’}}}

The acronym key. If set, the acronyms will be separate from main glossary entries.Remember to use \makeacronym and \printacronym if true.

\newif\ifglsacronym

\define@key{gloss}{acronym}[true]{%

\ifthenelse{\equal{#1}{true} \or \equal{#1}{false}}

{\setboolean{glsacronym}{#1}}{%

\PackageError{glossary}{Glossary option ’acronym’ is boolean}{The

value of ’acronym’ can only be set to ’true’ or ’false’}}}

The global key. If not set, any acronyms expanded in a group will be treated asunused once outside of the group. Set global=true to prevent this.

\newif\ifglsglobal

\define@key{gloss}{global}[true]{\ifthenelse{\equal{#1}{true}\or

\equal{#1}{false}}{\setboolean{glsglobal}{#1}}{%

\PackageError{glossary}{Glossary option ’global’ is boolean}{The

value of ’global’ can only be set to ’true’ or ’false’}}}

Set up defaults\def\gls@style{long}

\def\gls@header{none}

\def\gls@border{none}

\def\gls@glossary@number{page}

\gls@cols=2\relax

\gls@tocfalse

If \hyperpage is defined, then assume hyperlinks required

30

Page 31: glossary

\@ifundefined{hyperpage}{\glshyperfalse\glshyperacronymfalse}{%

\glshypertrue\glshyperacronymtrue}

If \hypertarget defined, then \glosslabel will make a target (#1) and\glossref will make a hyperlink (to #1). Otherwise will simply print the sec-ond argument.

\@ifundefined{hypertarget}{

% no hyperlinks

\newcommand{\glosslabel}[2]{#2}%

\newcommand{\glossref}[2]{#2}%

}{%

\newcommand{\glosslabel}[2]{\hypertarget{#1}{#2}}%

\newcommand{\glossref}[2]{\hyperlink{#1}{#2}}

}

If the xspace package has been loaded, use \xspace in acronyms.\@ifundefined{xspace}{%

\let\glsxspace\relax}{%

\let\glsxspace\xspace}

Set \glossaryalignment to \relax before loading configuration file.\let\glossaryalignment\relax

Load configuation file if it exists\newcommand{\glossarypackageoptions}[1]{\setkeys{gloss}{#1}}

\InputIfFileExists{glossary.cfg}{%

\typeout{Glossary configuration file loaded}}{%

\typeout{No configuration file glossary.cfg found}}

\renewcommand{\glossarypackageoptions}[1]{%

\PackageError{glossary}{Command \string\glossarypackageoptions

^^Jcan only be used in configuration file}{}}

Set up the options so that they are treated as a 〈key〉=〈value〉 list.\DeclareOption*{\edef\@pkg@ptions{\noexpand

\setkeys{gloss}{\CurrentOption}}

\ifthenelse{\equal{\CurrentOption}{}}{}{\@pkg@ptions}}

Process options\ProcessOptions

Check to make sure that the options don’t conflict.\ifthenelse{\(\equal{\gls@style}{list} \or

\equal{\gls@style}{altlist}\) \and

\(\not\equal{\gls@header}{none} \or \not\equal{\gls@border}{none}

\or \gls@cols=3\)}

{\PackageError{glossary}{You can’t have option ’style=list’ or

’style=altlist’ in combination with any of the other style

options}{The ’list’ and ’altlist’ options don’t have a header,

border or number of columns option.}}

{}

Can’t have both toc and hypertoc. Make it a warning rather than an error.\ifthenelse{\boolean{gls@hypertoc} \and \boolean{gls@toc}}{%

\PackageWarning{glossary}{Can’t have both ’toc’ and

’hypertoc’, ignoring ’toc’ option}

\ifgls@hypertoc\gls@tocfalse\fi}{}

31

Page 32: glossary

16.2 Redefining \glossary format

The glossary is going to be redefined so that it accepts 〈key〉=〈value〉 information,so need to define the keys (see keyval documentation for further details on how todo this.) Added \@onelevel@sanitize at the recommendation of Dan Lueckingand Ulrich Diez.

\define@key{wrgloss}{name}{%

\def\@glo@n@me{#1}%

\@onelevel@sanitize\@glo@n@me%

\global\let\@glo@n@me\@glo@n@me}

\define@key{wrgloss}{description}{%

\def\@descr{#1}%

\@onelevel@sanitize\@descr}

\define@key{wrgloss}{sort}{%

\def\@s@rt{#1}%

\@onelevel@sanitize\@s@rt

\global\let\@s@rt\@s@rt}

\define@key{wrgloss}{format}{\def\@f@rm@t{#1}}

\define@key{wrgloss}{number}{\def\@glo@num{#1}}

Redefine \@wrglossary so that it separates out the entry name and entry descrip-tion. This was rewritten in version 2.4. It is now used for both the main glossary,and user-defined glossaries. The command \@@wrglossary is called at the endof \@wrglossary, by default this does nothing, but some commands temporarilyredefine it.

\newcommand{\@@wrglossary}{}

The label for each entry is usually made up of the glossary prefix followed by thesort value, this can be over-ridden by redefining \@glo@l@bel. (This is done ifthe optional argument to \glossary is used.) By default this does nothing.

\newcommand{\@glo@l@bel}{}

Define the prefix for the principle glossary. (Added to version 2.4.)\newcommand{\@gls@glossary@type}{glo}

The optional first argument was added in version 2.4. This is the name of theglossary type.

\renewcommand{\@wrglossary}[2][glossary]{\relax

\gdef\@glo@n@me{}\def\@descr{}\def\@s@rt{}\def\@f@rm@t{}%

\edef\@glo@num{\csname gls@#1@number\endcsname}\relax

\xdef\@pr@fix{\csname @gls@#1@type\endcsname}%

\setkeys{wrgloss}{#2}\relax

\ifthenelse{\equal{\@glo@num}{none}}{\def\@@glo@num{\thepage}}{%

\@ifundefined{c@\@glo@num}{\PackageError{glossary}{%

Not such counter ’\@glo@num’}{The value of the ’number’ key

must be the name of a counter or the word "none"}%

\def\@@glo@num{\thepage}}{%

\edef\@@glo@num{\csname the\@glo@num\endcsname}}}%

\ifthenelse{\equal{\@s@rt}{}}{\gdef\@s@rt{\@glo@n@me}}{}%

\ifthenelse{\equal{\@glo@l@bel}{}}{%

\gdef\@glo@l@bel{\@pr@fix:\@s@rt}}{}%

User has not specified a format, so use default\ifthenelse{\equal{\@f@rm@t}{}}

{\expandafter\protected@write\csname @#1file\endcsname{}%

32

Page 33: glossary

{\string\glossaryentry{\@s@rt @{%

\string\glosslabel{\@glo@l@bel}{\@glo@n@me}}\@descr

\string\relax|glsnumformat}{\@@glo@num}}}

User has specified a format. If it is one of the \hyper〈xx 〉 types, append therequired counter. This is needed if the glossary contains a mixture of countersused (as in sampleEqPg.tex).

{\ifthenelse{\equal{\@f@rm@t}{hyperrm} \or

\equal{\@f@rm@t}{hypersf} \or \equal{\@f@rm@t}{hypertt}

\or \equal{\@f@rm@t}{hypermd} \or \equal{\@f@rm@t}{hyperbf}

\or \equal{\@f@rm@t}{hyperit} \or \equal{\@f@rm@t}{hyperem}

\or \equal{\@f@rm@t}{hypersl} \or \equal{\@f@rm@t}{hyperup}

\or \equal{\@f@rm@t}{hypersc}}

{\expandafter\protected@write\csname @#1file\endcsname{}%

{\string\glossaryentry{\@s@rt @{%

\string\glosslabel{\@glo@l@bel}{\@glo@n@me}}\@descr

\string\relax|\@f@rm@t[\@glo@num]}{\@@glo@num}}}

{\expandafter\protected@write\csname @#1file\endcsname{}%

{\string\glossaryentry{\@s@rt @{%

\string\glosslabel{\@glo@l@bel}{\@glo@n@me}}\@descr

\string\relax|\@f@rm@t}{\@@glo@num}}}}\relax

\endgroup\@esphack

\@@wrglossary

}

Command to extract name key from glossary entry. This shouldn’t be sanitized,so define a new key for this

\define@key{wrnsgloss}{name}{\def\@glo@n@me{#1}}

\define@key{wrnsgloss}{description}{\def\@descr{#1}}

\define@key{wrnsgloss}{sort}{\def\@s@rt{#1}}

\define@key{wrnsgloss}{format}{\def\@f@rm@t{#1}}

\define@key{wrnsgloss}{number}{\def\@glo@num{#1}}

Extract name from key-value list. Name stored in \@glo@n@me.\newcommand{\@gls@getn@me}[1]{%

\def\@glo@n@me{}\setkeys{wrnsgloss}{#1}%

}

Command to extract description key from glossary entry.\newcommand{\@gls@getdescr}[1]{%

\@bsphack\begingroup

\def\@descr{}%

\setkeys{wrgloss}{#1}%

\global\let\@glo@desc\@descr

\endgroup\@esphack

}

Now define \xglossary so you can have a hyperlink that takes you to the entryin the glossary

\newcommand{\xglossary}{\renewcommand{\@@wrglossary}[1]{%

\glossref{\@glo@l@bel}{##1}\renewcommand{\@@wrglossary}{}}%

\glossary}

33

Page 34: glossary

16.3 Storing Glossary Entries

Provide a means to store glossary information to save typing and ensure consis-tency (new to v2.17).

Store label in list (new to version 2.36) so that all entries can be added to theglossary with a single command.

\newcommand*{\@glo@label@list}{}

\toksdef\gls@ta=0 \toksdef\gls@tb=2

\newcommand{\@glo@label@addtolist}[1]{%

\gls@ta={{#1}}\gls@tb=\expandafter{\@glo@label@list}%

\xdef\@glo@label@list{\the\gls@ta,\the\gls@tb}}

First define command to store details (don’t allow a label consisting solely of a *as this represents all entries when passed to \useglosentry.)

\newcommand*{\storeglosentry}[3][glossary]{%

\ifthenelse{\equal{#2}{*}}{%

\PackageError{glossary}{Glossary label ’*’ invalid}{You can’t have

a glossary entry with a * as the label}}{%

\@ifundefined{glo@#2@entry}{%

\@glo@label@addtolist{#2}%

\expandafter\def\csname glo@#2@type\endcsname{#1}%

\expandafter\def\csname glo@#2@entry\endcsname{#3}%

\@gls@getn@me{#3}%

\expandafter\protected@edef\csname glo@#2@name\endcsname{\@glo@n@me}%

}{%

\PackageError{glossary}{Glossary entry ’#2’ already

defined}{There already exists a glossary entry with the label ’#2’}}}%

}

This command will not produce text in the document, but will produce the relevantglossary entry.

\providecommand{\useglosentry}[2][\relax]{%

\ifthenelse{\equal{#2}{*}}{\@for\@glolab:=\@glo@label@list\do{%

\ifthenelse{\equal{\@glolab}{}}{}{\useglosentry[#1]{\@glolab}}}}{%

\@ifundefined{glo@#2@type}{%

\PackageError{glossary}{Glossary entry ’#2’ undefined}{You need

to define the entry using \string\storeglosentry\space before

using it.}}{{%

\edef\@glostype{\csname glo@#2@type\endcsname}%

\@glo@tb=\expandafter\expandafter\expandafter

{\csname glo@#2@entry\endcsname}%

\ifx#1\relax

\edef\@glo@cmd{\expandafter\noexpand

\csname\@glostype\endcsname{\the\@glo@tb}}%

\else

\edef\@glo@cmd{\expandafter\noexpand

\csname\@glostype\endcsname{\the\@glo@tb,#1}}%

\fi

\@glo@cmd

}}}}

This command will produce the specified text in the document (with a hyperlinkif enabled), and will produce the relevant glossary entry.

\providecommand{\useGlosentry}[3][\relax]{%

\@ifundefined{glo@#2@type}{%

34

Page 35: glossary

\PackageError{glossary}{Glossary entry ’#2’ undefined}{You need

to define the entry using \string\storeglosentry\space before

using it.}}{{%

\edef\@glostype{x\csname glo@#2@type\endcsname}%

\@glo@tb=\expandafter\expandafter\expandafter

{\csname glo@#2@entry\endcsname}%

\ifx#1\relax

\edef\@glo@cmd{\expandafter\noexpand

\csname\@glostype\endcsname{\the\@glo@tb}}%

\else

\edef\@glo@cmd{\expandafter\noexpand

\csname\@glostype\endcsname{\the\@glo@tb,#1}}%

\fi

\@glo@cmd{#3}%

}}}

As above, but the text displayed in the document is constructed from the namekey.

\newcommand{\gls}[2][\relax]{%

\useGlosentry[#1]{#2}{%

\csname glo@#2@name\endcsname}}

This command was defined in earlier verions, but doesn’t work very well, currentlyretained for backwards compatibility, but may well be removed at a later date.

\providecommand{\saveglosentry}[3][glossary]{%

\PackageWarning{glossary}{\string\saveglosentry\space is obsolete,

please use \string\storeglosentry\space instead}%

\expandafter\def\csname glo@#2@type\endcsname{#1}%

\expandafter\def\csname glo@#2@entry\endcsname{%

name={#2},description={#3}}}

Set up default number formats, dependent on the package number option. Definedefault page compositor. Any redefinition of the page compositor will need tocome before the .ist file is written. The other commands can be redefined at anypoint before \printglossary.

Define a command to set up the glossary counter. The optional argument spec-ifies the glossary type (defaults to the main glossary). The mandatory commandis the name of the counter, or none.

\newcommand*{\@gls@setnumbering}[2][glossary]{%

If no numbering (number=none):\ifthenelse{\equal{#2}{none}}{%

\def\pagecompositor{-}

\expandafter\def\csname @#1@delimN\endcsname{}

\expandafter\def\csname @#1@delimR\endcsname{}

\expandafter\def\csname glsX#1Xnumformat\endcsname##1{}}{%

If number=page, set the page compositor to - (dash) otherwise set it to . (dot).\ifthenelse{\equal{#2}{page}}{%

\def\pagecompositor{-}}{%

\def\pagecompositor{.}}

Set up delimiters and formats\expandafter\def\csname @#1@delimN\endcsname{, }

\expandafter\def\csname @#1@delimR\endcsname{--}

\ifglshyper

35

Page 36: glossary

\expandafter\def\csname glsX#1Xnumformat\endcsname##1{%

\hyperrm[#2]{##1}}%

\else

\expandafter\def\csname glsX#1Xnumformat\endcsname##1{##1}\fi

}

End of \@gls@setnumbering definition:}

Now call it to set up current numbering:\@gls@setnumbering{\gls@glossary@number}

Provide a means of changing the page number format for a given glossary type.\newcommand{\glsnumformat}[1]{%

\@ifundefined{\@glostype}{\def\@glostype{glossary}}{}%

\@ifundefined{glsX\@glostype Xnumformat}{%

\PackageError{glossary}{Glossary type ’\@glostype’ undefined}{}}{%

\csname glsX\@glostype Xnumformat\endcsname{#1}}}

Set the default glossary type\def\@glostype{glossary}

Make the delimiters etc depend on the glossary type. \@glostype should be setto the appropriate glossary type before using any of these commands.

\newcommand{\delimN}{\csname @\@glostype @delimN\endcsname}

\newcommand{\delimR}{\csname @\@glostype @delimR\endcsname}

\newcommand{\gloitem}{\csname @\@glostype @gloitem\endcsname}

\newcommand{\gloskip}{\csname @\@glostype @gloskip\endcsname}

\newcommand{\delimT}{\glsafternum

\csname @\@glostype @delimT\endcsname}

\newcommand{\glodelim}{\csname @\@glostype @glodelim\endcsname

\glsbeforenum}

Add facility to insert text between groups. By default these do nothing.\newcommand{\glogroupSymbols}{}

\newcommand{\glogroupNumbers}{}

\newcommand{\glogroupA}{}

\newcommand{\glogroupB}{}

\newcommand{\glogroupC}{}

\newcommand{\glogroupD}{}

\newcommand{\glogroupE}{}

\newcommand{\glogroupF}{}

\newcommand{\glogroupG}{}

\newcommand{\glogroupH}{}

\newcommand{\glogroupI}{}

\newcommand{\glogroupJ}{}

\newcommand{\glogroupK}{}

\newcommand{\glogroupL}{}

\newcommand{\glogroupM}{}

\newcommand{\glogroupN}{}

\newcommand{\glogroupO}{}

\newcommand{\glogroupP}{}

\newcommand{\glogroupQ}{}

\newcommand{\glogroupR}{}

\newcommand{\glogroupS}{}

\newcommand{\glogroupT}{}

36

Page 37: glossary

\newcommand{\glogroupU}{}

\newcommand{\glogroupV}{}

\newcommand{\glogroupW}{}

\newcommand{\glogroupX}{}

\newcommand{\glogroupY}{}

\newcommand{\glogroupZ}{}

Allow user to change number format for different glossary types.\define@key{glossnum}{glsnumformat}{\def\@glsnumformat{#1}}

\define@key{glossnum}{type}{\def\@glsnumtype{#1}}

\define@key{glossnum}{delimN}{\def\@delimN{#1}}

\define@key{glossnum}{delimR}{\def\@delimR{#1}}

\define@key{glossnum}{delimT}{\def\@delimT{#1}}

\define@key{glossnum}{gloskip}{\def\@gloskip{#1}}

\define@key{glossnum}{glodelim}{\def\@glodelim{#1}}

Define a command that will ignore its argument. This is used when suppressingthe page numbers.

\providecommand{\ignore}[1]{}

Define command that allows the user to modify the style for a given glossary type.\newcommand{\setglossary}[1]{%

\def\@glsnumformat{}%

\def\@glsnumtype{glossary}%

\def\@delimN{@dontchange@}%

\def\@delimR{@dontchange@}%

\def\@delimT{@dontchange@}%

\def\@gloskip{@dontchange@}%

\def\@glodelim{@dontchange@}%

\setkeys{glossnum}{#1}\relax

\@ifundefined{print\@glsnumtype}{%

\PackageError{glossary}{Invalid glossary type ’\@glsnumtype’}{%

Glossary type ’\@glsnumtype’ has not been defined}

}{%

\ifthenelse{\equal{\@glsnumformat}{}}{}{%

\expandafter\xdef\csname glsX\@glsnumtype Xnumformat\endcsname{%

\noexpand\csname\@glsnumformat\noexpand\endcsname}%

\ifthenelse{\equal{\@glsnumformat}{ignore}}{%

\expandafter\xdef\csname @\@glsnumtype @delimN\endcsname{}%

\expandafter\xdef\csname @\@glsnumtype @delimR\endcsname{}%

}{}%

}%

%

\ifthenelse{\equal{\@delimN}{@dontchange@}}{}{%

\expandafter\xdef\csname @\@glsnumtype @delimN\endcsname{%

\@delimN}}%

%

\ifthenelse{\equal{\@delimR}{@dontchange@}}{}{%

\expandafter\xdef\csname @\@glsnumtype @delimR\endcsname{%

\@delimR}}%

%

\ifthenelse{\equal{\@delimT}{@dontchange@}}{}{%

\expandafter\xdef\csname @\@glsnumtype @delimT\endcsname{%

\@delimT}}%

%

37

Page 38: glossary

\ifthenelse{\equal{\@gloskip}{@dontchange@}}{}{%

\expandafter\xdef\csname @\@glsnumtype @gloskip\endcsname{%

\@gloskip}}%

%

\ifthenelse{\equal{\@glodelim}{@dontchange@}}{}{%

\expandafter\xdef\csname @\@glsnumtype @glodelim\endcsname{%

\@glodelim}%

}%

}}

Now define the command \printglossary which will print the contents of theglossary file. Define the file extension for the main glossary:

\newcommand{\@gls@glossary@inext}{gls}

The optional argument is the glossary type, the default is the main glossary. Thissets \gls@number to \gls@#1@number before reading in the file. This ensures that\hyperrm etc use the correct counter in the target name.

\newcommand\printglossary[1][glossary]{%

\def\@glostype{#1}%

\@ifundefined{#1name}{%

\renewcommand{\@glossaryname}{\glossaryname}}{%

\renewcommand{\@glossaryname}{\csname #1name\endcsname}}%

\@ifundefined{short#1name}{%

\renewcommand{\@shortglossaryname}{\@glossaryname}}{%

\renewcommand{\@shortglossaryname}{\csname short#1name\endcsname}}%

\expandafter\let\expandafter\gls@number\csname gls@#1@number\endcsname

\@input@{\jobname.\csname @gls@#1@inext\endcsname}}

Define contextual names. Changed \newcommand to \providecommand in version2.2.

\providecommand{\glossaryname}{Glossary}

\newcommand{\shortglossaryname}{\glossaryname}

\newcommand{\entryname}{Notation}

\newcommand{\descriptionname}{Description}

\newcommand{\istfilename}{\jobname.ist}

\def\@glossaryname{\glossaryname}

\def\@shortglossaryname{\shortglossaryname}

Version 2.4 also writes ist filename to aux file. This is only used by makeglos.pl,so ignore.

\newcommand{\@istfilename}[1]{}

Define command to generate glossary title (new to version 2.24)\providecommand{\glossarytitle}{%

\@ifundefined{chapter}%

\chapter not defined, use \section*

{%

\ifgls@hypertoc

hypertoc option used, so use \phantomsection to add anchor before \section*

\phantomsection

\@glosaddtoc{section}%

\section*{\@glossaryname}\relax

\else

38

Page 39: glossary

hypertoc=false: add to toc after \section*\section*{\@glossaryname}\relax

only add contentsline if toc=true\ifgls@toc\@glosaddtoc{section}\fi

\fi}%

\chapter defined, but has user requested \section instead?{%

\ifthenelse{\boolean{gls@section}}%

{%

user requested \section

\ifgls@hypertoc

User request hypertoc=true, so add anchor before \section:\phantomsection

\@glosaddtoc{section}%

\section*{\@glossaryname}\relax

\else

hypertoc=false so add contentsline (if applicable) after \section\section*{\@glossaryname}\relax

\ifgls@toc\@glosaddtoc{section}\fi

\fi}%

{%

User has not requested \section, so use \chapter

\ifgls@hypertoc

User has requested hypertoc=true. Chapters usually start a new page, soto ensure anchor is at the top of the correct page, issue a \clearpage (or\cleardoublepage) to place the anchor at the correct place.

\@ifundefined{if@twoside}{%

Document class doesn’t support twosided documents so just do \clearpage

\clearpage}{%

\if@twoside

Document is two-sided If \cleardoublepage is defined, use that otherwise justdo \clearpage

\@ifundefined{cleardoublepage}{\clearpage}{\cleardoublepage}%

\else

One-sided document, just do \clearpage

\clearpage

\fi}%

add anchor before \chapter

\phantomsection

\@glosaddtoc{chapter}%

\fi

\chapter*{\@glossaryname}\relax

both hypertoc=true and toc=true, so won’t get toc entry twice.)\ifgls@toc\@glosaddtoc{chapter}\fi}}

\markboth{\@shortglossaryname}{\@shortglossaryname}%

}

39

Page 40: glossary

Now define theglossary environment. Version 2.2: check to see if defined already\@ifundefined{theglossary}{%

\newenvironment{theglossary}{}{}}{%

\PackageWarning{glossary}{Redefining ’theglossary’ environment}}

\renewenvironment{theglossary}{%

\glossarytitle

\glossarypreamble\@bef@reglos}{\@ftergl@s\glossarypostamble}

Provide a means to add text to the beginning or end of the glossary.\newcommand{\glossarypreamble}{}

\newcommand{\glossarypostamble}{}

By default, add the short title to the table of contents.\newcommand{\@glosaddtoc}[1]{%

\addcontentsline{toc}{#1}{\@shortglossaryname}

}

Set up switch to determine whether the item is the first item in the glossary (inthe event that a special case is needed for the first item)

\newif\ifgloitemfirst

\newcommand{\@bef@reglos}{\global\gloitemfirsttrue\beforeglossary}

\newcommand{\@ftergl@s}{\afterglossary\global\gloitemfirstfalse}

Set up defaults.\newcommand{\glossaryalignment}{\relax}

\newcommand{\@gls@align@glossary}{}

\newcommand{\glosstail}{%

\@ifundefined{@gls@tail@\@glostype}{%

\PackageError{glossary}{No glossary tail defined for glossary

type ’\@glostype’}{}}{%

\csname @gls@tail@\@glostype\endcsname}}

\newcommand{\@gls@tail@glossary}{}

\newcommand{\afterglossary}{%

\@ifundefined{@gls@afterglos@\@glostype}{%

\PackageError{glossary}{No after glossary defined for glossary

type ’\@glostype’}{}}{%

\csname @gls@afterglos@\@glostype\endcsname}}

\newcommand{\beforeglossary}{%

\@ifundefined{@gls@beforeglos@\@glostype}{%

\PackageError{glossary}{No before glossary defined for glossary

type ’\@glostype’}{}}{%

\csname @gls@beforeglos@\@glostype\endcsname}}

\newcommand{\@gls@beforeglos@glossary}{}

\newcommand{\@gls@afterglos@glossary}{}

\newcommand{\@glossary@glodelim}{}

\newcommand{\@glossary@delimT}{}

\newcommand{\glsafternum}{}

\newcommand{\glsbeforenum}{}

\newcommand{\@glossary@gloskip}{}

\newcommand{\@glossary@gloitem}[1]{#1}

Now define what to do depending on which style has been selected. First definecommand to switch to list style:

\newcommand{\gls@setlist}[1][glossary]{%

\expandafter\def\csname @gls@beforeglos@#1\endcsname{%

\begin{description}}%

40

Page 41: glossary

\expandafter\def\csname @gls@afterglos@#1\endcsname{%

\end{description}}%

\expandafter\def\csname @#1@gloskip\endcsname{\indexspace}%

\ifthenelse{\equal{\csname gls@#1@number\endcsname}{none}}{%

\expandafter\def\csname @#1@glodelim\endcsname{}}{%

\expandafter\def\csname @#1@glodelim\endcsname{, }}%

\expandafter\def\csname @#1@gloitem\endcsname##1{\item[##1]}%

\expandafter\def\csname @#1@delimT\endcsname{}

}

Next define command to switch to altlist style:\newcommand{\gls@setaltlist}[1][glossary]{%

\expandafter\def\csname @gls@beforeglos@#1\endcsname{%

\begin{description}}%

\expandafter\def\csname @gls@afterglos@#1\endcsname{%

\end{description}}%

\expandafter\def\csname @#1@gloskip\endcsname{\indexspace}%

\expandafter\def\csname @#1@gloitem\endcsname##1{%

\item[##1]\mbox{}\nopagebreak\par\nopagebreak}%

\expandafter\def\csname @#1@glodelim\endcsname{ }%

\expandafter\def\csname @#1@delimT\endcsname{}

}

Now deal with the other styles. I orginally used a tabular environment, but obvi-ously this doesn’t work for a glossary longer than one page (this package startedout as a simple example accompanying one of my tutorials). Nick van Foreest rec-ommended the supertabular environment. The longtable environment also works,so have both options, and leave it to the user.

\ifthenelse{\equal{\gls@style}{super}}{

\IfFileExists{supertab.sty}{\RequirePackage{supertab}}

{\IfFileExists{supertabular.sty}{\RequirePackage{supertabular}}

{\PackageError{glossary}{Option "super" chosen, but can’t find

"supertab" package}{If you want the "super" option, you have to have

the "supertab" package installed.}}}}

{\RequirePackage{longtable}}

Define new length specifying the width of the description field.\newlength{\descriptionwidth}

\setlength{\descriptionwidth}{0.6\linewidth}

If user has defined the command \glossaryheader, use it otherwise use headeras specified by glossary style. Added \glossarysubheader in version 2.4. This isprovided to add a sub heading, or to add a bit of space between the header rowand the table.

\newcommand{\@glossaryheader}{%

\@ifundefined{glossaryheader}{\csname @\@glostype @header\endcsname}

{\glossaryheader}%

\@ifundefined{glossarysubheader}{}{\glossarysubheader}%

}

Define command to set header style. Added \glspageheader in version 2.4.(Third column header)

\newcommand{\gls@setheader}[1][glossary]{%

\ifthenelse{\equal{\gls@header}{none}}%

{%

41

Page 42: glossary

\ifthenelse{\equal{\gls@border}{none}}

{\expandafter\def\csname @#1@header\endcsname{}%

}{\expandafter\def\csname @#1@header\endcsname{\hline}}%

}{%

\ifnum\gls@cols=2\relax

\ifthenelse{\equal{\gls@border}{none}}

{%

\expandafter\def\csname @#1@header\endcsname{%

\bfseries\entryname & \bfseries \descriptionname\\}}%

{%

\expandafter\def\csname @#1@header\endcsname{%

\hline\bfseries\entryname & \bfseries\descriptionname

\\\hline\hline}}%

\else

\ifthenelse{\equal{\gls@border}{none}}

{%

\expandafter\def\csname @#1@header\endcsname{%

\bfseries\entryname & \bfseries \descriptionname &

\bfseries \glspageheader \\}}%

{%

\expandafter\def\csname @#1@header\endcsname{%

\hline\bfseries\entryname &\bfseries\descriptionname &

\bfseries \glspageheader \\\hline\hline}}%

\fi

}}

Define \glspageheader to do nothing, to keep it compatible with earlier versions:\newcommand*{\glspageheader}{}

Define command to set glossary alignment and borders\newcommand{\gls@setalignment}[1][glossary]{%

\ifthenelse{\equal{\gls@border}{none}}

{

\ifnum\gls@cols=2\relax

\expandafter\def\csname @gls@align@#1\endcsname{%

@{\hspace{\tabcolsep}\bfseries}lp{\descriptionwidth}}

\else

\expandafter\def\csname @gls@align@#1\endcsname{%

@{\hspace{\tabcolsep}\bfseries}lp{\descriptionwidth}l}

\fi

%

\expandafter\def\csname @gls@tail@#1\endcsname{}%

}{%

\ifnum\gls@cols=2\relax

\expandafter\def\csname @gls@align@#1\endcsname{%

|@{\hspace{\tabcolsep}\bfseries

}lp{\descriptionwidth}|}

\else

\expandafter\def\csname @gls@align@#1\endcsname{%

|@{\hspace{\tabcolsep}\bfseries

}lp{\descriptionwidth}l|}

\fi

%

\expandafter\def\csname @gls@tail@#1\endcsname{\hline}%

}%

42

Page 43: glossary

%

\expandafter\def\csname @#1@delimT\endcsname{\\}

%

\ifnum\gls@cols=2\relax

\expandafter\def\csname @#1@gloskip\endcsname{& \\}%

\ifthenelse{\equal{\csname gls@#1@number\endcsname}{none}}{%

\expandafter\def\csname @#1@glodelim\endcsname{}}{%

\expandafter\def\csname @#1@glodelim\endcsname{, }}%

\else

\expandafter\def\csname @#1@gloskip\endcsname{& & \\}%

\expandafter\def\csname @#1@glodelim\endcsname{& }%

\fi

\expandafter\def\csname @#1@gloitem\endcsname##1{##1 &}%

}

Need a way to avoid conflict with the array package. In an earlier version I defineda new column type if the array package was being used, however this restricts theability to have multiple glossaries with different column alignments.

\newcommand{\@st@rtglostable}[2]{%

\gls@ta={\begin{#1}}\gls@tb=\expandafter{#2}%

\edef\@st@rtglost@ble{\the\gls@ta{\the\gls@tb}}

\@st@rtglost@ble}

Define command to switch to super style:\newcommand{\gls@setsuper}[1][glossary]{%

\gls@setalignment[#1]%

\gls@setheader[#1]%

%

\expandafter\def\csname @gls@beforeglos@#1\endcsname{%

\tablehead{\@glossaryheader}\tabletail{\glosstail}%

\if\glossaryalignment\relax

\expandafter\let\expandafter\@glossaryalignment

\csname @gls@align@#1\endcsname

\else

\let\@glossaryalignment\glossaryalignment

\fi

\@st@rtglostable{supertabular}\@glossaryalignment}

%

\expandafter\def\csname @gls@afterglos@#1\endcsname{%

\end{supertabular}}%

}

Define command to switch to long style:\newcommand{\gls@setlong}[1][glossary]{%

\gls@setalignment[#1]%

\gls@setheader[#1]%

%

\expandafter\def\csname @gls@beforeglos@#1\endcsname{%

\if\relax\glossaryalignment

\expandafter\let\expandafter\@glossaryalignment

\csname @gls@align@#1\endcsname

\else

\let\@glossaryalignment\glossaryalignment

\fi

\@st@rtglostable{longtable}{\@glossaryalignment}

43

Page 44: glossary

\@glossaryheader\endhead\glosstail\endfoot}

%

\expandafter\def\csname @gls@afterglos@#1\endcsname{%

\end{longtable}}%

}

Define command to set the glossary style.\newcommand{\@setglossarystyle}[1][glossary]{%

\@ifundefined{gls@set\gls@style}{%

\PackageError{glossary}{Glossary style ’\gls@style’ undefined}{}}{%

\ifthenelse{\equal{\gls@number}{}}{}{%

\expandafter\edef\csname gls@#1@number\endcsname{\gls@number}%

\@gls@setnumbering[#1]{\gls@number}%

}%

\csname gls@set\gls@style\endcsname[#1]}}

Set main glossary style as per package options\let\gls@number\gls@glossary@number

\@setglossarystyle

Define keys to change glossary style. The style key sets the basic style.\define@key{glosstyle}

{style}

{\ifthenelse{\equal{#1}{list} \or \equal{#1}{altlist}

\or \equal{#1}{super} \or \equal{#1}{long}}

{\def\gls@style{#1}}

{\PackageError{glossary}

{Unknown glossary style ’#1’}

{Available styles are: list, altlist, super and long}}}

The header key should only be used in conjunction with one of the tabular-typestyles. If set to plain, a header row will be used.

\define@key{glosstyle}

{header}[plain]{\ifthenelse{\equal{#1}{none} \or \equal{#1}{plain}}

{\def\gls@header{#1}}

{\PackageError{glossary}

{Unknown glossary style ’#1’}

{Available styles are: none and plain}}}

The border key should only be used in conjunction with one of the tabular-typestyles. If set to plain, a border will be placed around the glossary.

\define@key{glosstyle}

{border}[plain]{\ifthenelse{\equal{#1}{none} \or \equal{#1}{plain}}

{\def\gls@border{#1}}

{\PackageError{glossary}

{Unknown glossary border ’#1’}

{Available styles are: none and plain}}}

The cols key should only be used in conjunction with one of the tabular-typestyles. If set to 2, the description and page list will both be placed in the secondcolumn, if set to 3, the description will go in the second column, and the page listwill go in the third column.

\define@key{glosstyle}{cols}{\gls@cols=#1\relax

\ifthenelse{\gls@cols<2 \or \gls@cols>3}

{\PackageError{glossary}

{invalid number of columns}

44

Page 45: glossary

{The cols option can only be 2 or 3}}

{}}

The number key may either be none or the name of a counter.\define@key{glosstyle}

{number}

{\ifthenelse{\equal{#1}{none}}

{\def\gls@number{#1}}

{\@ifundefined{c@#1}{

\PackageError{glossary}

{Unknown glossary number style ’#1’}

{You may either specify "none" or the name of a counter,

e.g. "section"}\def\gls@number{page}}{\def\gls@number{#1}}}}

Provide a means of setting the style for a given glossary type.\newcommand{\setglossarystyle}[2][glossary]{%

\def\gls@number{}%

\setkeys{glosstyle}{#2}%

\@setglossarystyle[#1]%

}

Set the delimiter for the case where there is no numbering and there aren’t 3columns.

\ifthenelse{\equal{\gls@glossary@number}{none} \and \gls@cols<3}{%

\renewcommand{\@glossary@glodelim}{}}{}

16.4 Makeindex style file

This is the code to generate the .ist file. First define a switch that governswhether or not to write the ist file.

\newif\ifist

\let\noist=\istfalse

\if@filesw\isttrue\else\istfalse\fi

Provide a command to write the ist file. This will cause a problem with ngermanbecause the behaviour of the double quote character changes. Any packages thatmodify this character should be loaded after the .ist file is written.

\newwrite\istfile

\catcode‘\%11\relax

\newcommand{\writeist}{

\protected@write\@auxout{}{\protect\@istfilename{\istfilename}}

\openout\istfile=\istfilename

\write\istfile{% makeindex style file created by LaTeX for document "\jobname" on \the\year-\the\month-\the\day}

\write\istfile{keyword "\string\\glossaryentry"}

\write\istfile{preamble "\string\\begin{theglossary}"}

\write\istfile{postamble "\string\n\string\\end{theglossary}\string\n"}

\write\istfile{group_skip "\string\\gloskip "}

\write\istfile{item_0 "\string\n\string\n\string\\gloitem "}

\write\istfile{delim_0 "\string\n\string\\glodelim "}

\write\istfile{page_compositor "\pagecompositor"}

\write\istfile{delim_n "\string\\delimN "}

\write\istfile{delim_r "\string\\delimR "}

\write\istfile{delim_t "\string\\delimT "}

\write\istfile{headings_flag 1}

\write\istfile{heading_prefix "\string\\glogroup"}

45

Page 46: glossary

\write\istfile{symhead_positive "Symbols"}

\write\istfile{numhead_positive "Numbers"}

\closeout\istfile

}

\catcode‘\%14\relax

Redefine \makeglossary so that it creates the .ist file. Once it is created, the\ifist flag is set to false to prevent repeated creation of the file in the eventthat another glossary-style type is created. If a different .ist file is desired foreach glossary type, you will need to precede each \make〈type〉 with \isttrue andchanged the definition of \istfilename. (This is unlikely to occur unless morethan one type of page compositor is required.) If you do this, remember to pass thecorrect ist file to makeindex. I have removed \@sanitize at the recommendationof Ulrich Diez.

\renewcommand{\makeglossary}{

\newwrite\@glossaryfile

\immediate\openout\@glossaryfile=\jobname.glo

\renewcommand{\glossary}[1][]{\gdef\@glo@l@bel{##1}%

\@bsphack \begingroup \@wrglossary }

\typeout {Writing glossary file \jobname .glo }

\let \makeglossary \@empty

\ifist\writeist\fi

\noist}

The \glossary command has been modified to allow for an optional argumentto modify the label. This is the default definition of \glossary, it doesn’t writeanything to the .glo file. It doesn’t use \setkeys, so \@sanitize is used here.Use \makeglossary to redefine it so that entries are written to the .glo file.

\renewcommand{\glossary}[1][]{%

\@bsphack\begingroup\@sanitize\@index}

16.5 Defining a new glossary type

First parameter (optional) is the extension of the log file (information used bymakeglos.pl but not LATEX). Second parameter is the name of new glossary typee.g. notation. Third parameter is the extension of output file (equivalent to indor glo. Fourth parameter is the extension of input file (equivalent to idx or gls).The fifth parameter (optional) is the format.

\newcommand{\newglossarytype}[4][glg]{

\@ifundefined{#2}{%

\protected@write\@auxout{}{\@newglossarytype[#1]{#2}{#3}{#4}}%

\def\@glstype{#2}\def\@glsout{#3}\def\@glsin{#4}%

\expandafter\edef\csname gls@\@glstype @number\endcsname{%

\gls@glossary@number}%

\expandafter\gdef\csname glsX\@glstype Xnumformat\endcsname{%

\glsXglossaryXnumformat}%

\expandafter\gdef\csname @\@glstype @delimN\endcsname{%

\@glossary@delimN}%

\expandafter\gdef\csname @\@glstype @delimR\endcsname{%

\@glossary@delimR}%

\expandafter\gdef\csname @gls@\@glstype @inext\endcsname{#4}%

\expandafter\def\csname @gls@#2@type\endcsname{#4}%

\expandafter\edef\csname make\@glstype\endcsname{%

46

Page 47: glossary

\noexpand\@m@kegl@ss{\@glstype}{\@glsout}}

\expandafter\edef\csname \@glstype\endcsname{%

\noexpand\@gl@ss@ary{\@glstype}}

\expandafter\edef\csname x\@glstype\endcsname{%

\noexpand\@Gl@ss@ary{\@glstype}}

\@namedef{print\@glstype}{%

\printglossary[#2]}%

}{\PackageError{glossary}{Command

\expandafter\string\csname #2\endcsname \space already defined}{%

You can’t call your new glossary type ’#2’ because there already

exists a command with this name}}%

\@@n@wglostype}

\newcommand{\@@n@wglostype}[1][]{%

\setglossarystyle[\@glstype]{#1}}

The command \@newglossarytype is written to the auxiliary file and is only usedby makeglos.pl. LATEX should ignore it.

\newcommand{\@newglossarytype}[4][glg]{}

Define equivalent of \makeglossary:\newcommand\@m@kegl@ss[2]{%

\expandafter\newwrite\csname @#1file\endcsname

\expandafter\immediate\expandafter

\openout\csname @#1file\endcsname=\jobname.#2

\typeout {Writing #1 file \jobname .#2 }

\expandafter\let \csname make#1\endcsname \@empty

\ifist\writeist\fi

\expandafter\def\csname the#1num\endcsname{\thepage}

\noist

}

Define the equivalent of \glossary.\newcommand\@gl@ss@ary[2][]{\@ifundefined{@#2file}{%

\@bsphack\begingroup\@sanitize \@index}{%

\gdef\@glo@l@bel{#1}%

\@bsphack \begingroup \@wrglossary[#2]}}

Define the equivalent of \xglossary.\newcommand{\@Gl@ss@ary}{%

\renewcommand{\@@wrglossary}[1]{%

\glossref{\@glo@l@bel}{##1}\renewcommand{\@@wrglossary}{}}%

\@gl@ss@ary}

The command \newglossarytype should only be used in the preamble.\@onlypreamble{\newglossarytype}

16.6 Acronyms

Define \newacronym[〈cmd-name〉]{〈abbrv〉}{〈long name〉}{〈glos entry〉}\newcommand\@acrnmsh{}

\newcommand\@sacrnmsh{}

\newcommand\@acrnmln{}

\newcommand\@acrnmcmd{}

\newcommand\@acrnmgls{}

\newcommand\@acrnmins{}

47

Page 48: glossary

List of all defined acronyms.\toksdef\@glo@tb=2

\newcommand{\@acr@list}{}

append acronym to list\newcommand{\@acr@addtolist}[1]{\edef\@glo@ta{#1}%

\ifthenelse{\equal{\@acr@list}{}}{%

\edef\@acr@list{\@glo@ta}}{%

\@glo@tb=\expandafter{\@acr@list}%

\edef\@acr@list{\the\@glo@tb,\@glo@ta}}}

Specify how to control the way the name key is set for acronyms.\newcommand{\@acronymnamefmt}{\glolong\ (\gloshort)}

\newcommand{\setacronymnamefmt}[1]{\def\@acronymnamefmt{#1}}

Specify how to control the way the description key is set for acronyms.\newcommand{\@acronymdescfmt}{\glodesc}

\newcommand{\setacronymdescfmt}[1]{\def\@acronymdescfmt{#1}}

Format the acronym abbreviation in the format specified by \acronymfont. Thissimply prints its argument by default.

\newcommand{\acronymfont}[1]{#1}

This command has been restructured as from v2.17\newcommand{\newacronym}[4][]{%

\ifthenelse{\equal{#1}{}}{\renewcommand\@acrnmcmd{#2}}{%

\renewcommand\@acrnmcmd{#1}}

\@ifundefined{\@acrnmcmd}{%

\expandafter\newcommand\csname\@acrnmcmd short\endcsname{%

#2\protect\glsxspace}

\expandafter\newcommand\csname\@acrnmcmd @nx@short\endcsname{#2}

\expandafter\newcommand\csname\@acrnmcmd long\endcsname{%

#3\protect\glsxspace}

\expandafter\newcommand\csname\@acrnmcmd @nx@long\endcsname{#3}

\def\@acrn@entry{#4}%

{%

% extract description

\expandafter\@gls@getdescr\expandafter{\@acrn@entry}%

\let\glodesc\@glo@desc%

\def\glolong{#3}%

\@onelevel@sanitize\glolong

\def\gloshort{\noexpand\acronymfont{#2}}%

\@onelevel@sanitize\gloshort

\expandafter\protected@xdef\expandafter\@acrnamefmt{\@acronymnamefmt}

\expandafter\protected@xdef\expandafter\@acrdesc{\@acronymdescfmt}

}%

\@acr@addtolist{\@acrnmcmd}

\@glo@tb=\expandafter{\@acrn@entry}%

\protected@edef\@acr@glsentry{name={\@acrnamefmt},%

format=glsnumformat,sort={\@acrnmcmd},\the\@glo@tb,%

description={\@acrdesc}}%

\@glo@tb=\expandafter{\@acr@glsentry}%

\newboolean{\@acrnmcmd first}\setboolean{\@acrnmcmd first}{true}

\expandafter\protected@edef\csname \@acrnmcmd\endcsname{%

\noexpand\@ifstar{\csname @s@\@acrnmcmd\endcsname}{%

\csname @\@acrnmcmd\endcsname}}

48

Page 49: glossary

\ifglshyperacronym % hyperlinks

% unstarred version

\expandafter\protected@edef\csname @\@acrnmcmd\endcsname{%

\noexpand\ifthenelse{\noexpand\boolean{\@acrnmcmd first}}{%

\csname\@acrnmcmd @nx@long\endcsname\noexpand\@acrnmins\

(\noexpand\xacronym{\the\@glo@tb}{%

\noexpand\acronymfont{\csname\@acrnmcmd @nx@short\endcsname}%

})\noexpand\unsetacronym{\@acrnmcmd}%

}{\noexpand\xacronym{\the\@glo@tb}{%

\noexpand\acronymfont{\csname\@acrnmcmd @nx@short\endcsname}%

\noexpand\@acrnmins}}\noexpand\glsxspace}

% starred version

\expandafter\protected@edef\csname @s@\@acrnmcmd\endcsname{%

\noexpand\ifthenelse{\noexpand\boolean{\@acrnmcmd first}}{%

\noexpand\expandafter\noexpand\MakeUppercase

\csname\@acrnmcmd @nx@long\endcsname\noexpand\@acrnmins\

(\noexpand\xacronym{\the\@glo@tb}{%

\noexpand\acronymfont{\csname\@acrnmcmd @nx@short\endcsname}%

})%

\noexpand\unsetacronym{\@acrnmcmd}}{%

\noexpand\xacronym{\the\@glo@tb}{%

\noexpand\acronymfont{\noexpand\expandafter\noexpand\MakeUppercase

\csname\@acrnmcmd @nx@short\endcsname}%

\noexpand\@acrnmins}}\noexpand\glsxspace}

\else % no hyperlinks

% unstarred version

\expandafter\protected@edef\csname @\@acrnmcmd\endcsname{%

\noexpand\ifthenelse{\noexpand\boolean{\@acrnmcmd first}}{%

\csname\@acrnmcmd @nx@long\endcsname\noexpand\@acrnmins\

(\noexpand\acronym{\the\@glo@tb}{%

\noexpand\acronymfont{\csname\@acrnmcmd @nx@short\endcsname}%

})\noexpand\unsetacronym{\@acrnmcmd}%

}{\noexpand\acronym{\the\@glo@tb}{%

\noexpand\acronymfont{\csname\@acrnmcmd @nx@short\endcsname}%

\noexpand\@acrnmins}}%

\noexpand\glsxspace}

% starred version

\expandafter\protected@edef\csname @s@\@acrnmcmd\endcsname{%

\noexpand\ifthenelse{\noexpand\boolean{\@acrnmcmd first}}{%

\noexpand\expandafter

\noexpand\MakeUppercase

\csname\@acrnmcmd @nx@long\endcsname\noexpand\@acrnmins\

(\noexpand\acronym{\the\@glo@tb}{%

\noexpand\acronymfont{\csname\@acrnmcmd @nx@short\endcsname}%

})%

\noexpand\unsetacronym{\@acrnmcmd}}{%

\noexpand\acronym{\the\@glo@tb}{%

\noexpand\acronymfont{\noexpand\expandafter\noexpand\MakeUppercase

\csname\@acrnmcmd @nx@short\endcsname}%

\noexpand\@acrnmins}}\noexpand\glsxspace}

\fi

}{%

\PackageError{glossary}{Command ’\expandafter\string

\csname\@acrnmcmd\endcsname’ already defined}{%

49

Page 50: glossary

The command name specified by \string\newacronym already exists.}}}

Define a command to use a given acronym.\newcommand{\useacronym}{\@ifstar\@suseacronym\@useacronym}

\newcommand{\@suseacronym}[2][]{{\let\glsxspace\relax

\def\@acrnmins{#1}\csname @s@#2\endcsname}%

\setboolean{#2first}{false}}

\newcommand{\@useacronym}[2][]{{\let\glsxspace\relax

\def\@acrnmins{#1}\csname @#2\endcsname}%

\setboolean{#2first}{false}}

Define a command to use the long form of an acronym without generating aglossary entry. The starred form makes the first character uppercase.

\newcommand{\acrln}{\@ifstar\@sacrln\@acrln}

Unstarred form:\newcommand{\@acrln}[1]{\@ifundefined{#1long}{%

\PackageError{glossary}{Acronym ’#1’ has not been defined}{}}{%

\csname#1@nx@long\endcsname}}

Starred form:\newcommand{\@sacrln}[1]{\@ifundefined{#1long}{%

\PackageError{glossary}{Acronym ’#1’ has not been defined}{}}{%

\expandafter\expandafter\expandafter

\MakeUppercase\csname#1@nx@long\endcsname}}

As above, but for the short form.\newcommand{\acrsh}{\@ifstar\@sacrsh\@acrsh}

Unstarred form:\newcommand{\@acrsh}[1]{\@ifundefined{#1short}{%

\PackageError{glossary}{Acronym ’#1’ has not been defined}{}}{%

\acronymfont{\csname#1@nx@short\endcsname}}}

Starred form:\newcommand{\@sacrsh}[1]{\@ifundefined{#1short}{%

\PackageError{glossary}{Acronym ’#1’ has not been defined}{}}{%

\acronymfont{\expandafter\expandafter\expandafter

\MakeUppercase\csname#1@nx@short\endcsname}}}

Define a means of determining whether an acronym has been used or not. Thiswas mainly included for use with LaTeX2HTML which currently has no ifthenstyle.

\newcommand{\ifacronymfirstuse}[3]{%

\@ifundefined{if#1first}{%

\PackageError{glossary}{Acronym ’#1’ not defined}{}}{%

\ifthenelse{\boolean{#1first}}{#2}{#3}}}

Provide a means of resetting an acronym so that it is expanded next time it isused.

\newcommand{\resetacronym}[1]{%

\@ifundefined{if#1first}{%

\PackageError{glossary}{Acronym ’#1’ not defined}{}}{%

\ifglsglobal

\expandafter\global\csname #1firsttrue\endcsname

\else

\setboolean{#1first}{true}%

\fi}}

50

Page 51: glossary

Reverse of the above.\newcommand{\unsetacronym}[1]{%

\@ifundefined{if#1first}{%

\PackageError{glossary}{Acronym ’#1’ not defined}{}}{%

\ifglsglobal

\expandafter\global\csname #1firstfalse\endcsname

\else

\setboolean{#1first}{false}%

\fi}}

Reset all acronyms so that they will all be expanded when next used.\newcommand{\resetallacronyms}{%

\@for\@acr:=\@acr@list\do{\resetacronym{\@acr}}}

Ensure that all acronyms are not expanded, even if they haven’t yet been used.\newcommand{\unsetallacronyms}{%

\@for\@acr:=\@acr@list\do{\unsetacronym{\@acr}}}

Check to see if acronyms should be separate from glossary\ifglsacronym

\newglossarytype[alg]{acronym}{acr}{acn}

\providecommand{\acronymname}{List of Acronyms}

\else

\let\acronym=\glossary

\let\xacronym=\xglossary

\fi

16.7 Glossary Hyperlinks

This section deals with commands that are used to make the numbers in theglossary have hyperlinks, if hyperlinks are supported.

The command \glshyper is a modification of hyperref’s \hyperpage com-mand, but it uses \delimR instead of a dash, and \delimN instead of a comma.The command was originally called \glshyperpage but was modified in version2.4 to enable page to be substituted with some arbitrary counter (which shouldbe specified as the first argument).

\ifglshyper

\def\glshyper#1#2{\@glshyper{#1}#2\delimR \delimR \\}

\def\@glshyper#1#2\delimR #3\delimR #4\\{%

\ifx\\#3\\%

\@delimNhyper{#1}{#2}%

\else

\@ifundefined{hyperlink}{#2\delimR #3}{%

\hyperlink{#1.#2}{#2}\delimR \hyperlink{#1.#3}{#3}}%

\fi

}

For a list of individual pages instead of a range:\def\@delimNhyper#1#2{\@@delimNhyper{#1}#2\delimN \delimN\\}

\def\@@delimNhyper#1#2\delimN #3\delimN #4\\{%

\ifx\\#3\\%

\@ifundefined{hyperlink}{#2}{\hyperlink{#1.#2}{#2}}%

\else

\@ifundefined{hyperlink}{#2\delimN #3}{%

51

Page 52: glossary

\hyperlink{#1.#2}{#2}\delimN \hyperlink{#1.#3}{#3}}%

\fi

}

To maintain backwards compatibility, define \glshyperpage and \glshypersection.These commands may be removed at a later date, so don’t use them.

\newcommand\glshyperpage[1]{\glshyper{page}{#1}}

\newcommand\glshypersection[1]{\glshyper{section}{#1}}

If chapters are defined, modify \@chapter so that is adds a section.〈n〉.0 target(otherwise it gets too complicated if you have to work out whether to use thechapter or section counter—there’s more than enough conditional code in thispackage already!)

\@ifundefined{chapter}

{}

{\let\@gls@old@chapter\@chapter

\def\@chapter[#1]#2{\@gls@old@chapter[{#1}]{#2}%

\@ifundefined{hyperdef}{}{\hyperdef{section}{\thesection}{}}}}

Provide \hyper〈xx 〉 to make it easier to change the page number format to bf,sf, tt and it if you are using hyperlinks. The optional first argument (new toversion 2.4) specifies the counter being used.

\providecommand\hyperrm[2][\gls@number]{%

\textrm{\glshyper{#1}{#2}}}

\providecommand\hypersf[2][\gls@number]{%

\textsf{\glshyper{#1}{#2}}}

\providecommand\hypertt[2][\gls@number]{%

\texttt{\glshyper{#1}{#2}}}

\providecommand\hyperbf[2][\gls@number]{%

\textbf{\glshyper{#1}{#2}}}

\providecommand\hyperit[2][\gls@number]{%

\textit{\glshyper{#1}{#2}}}

The following were added in version 2.4:\providecommand\hyperem[2][\gls@number]{%

\emph{\glshyper{#1}{#2}}}

\providecommand\hyperup[2][\gls@number]{%

\textup{\glshyper{#1}{#2}}}

\providecommand\hypersl[2][\gls@number]{%

\textsl{\glshyper{#1}{#2}}}

\providecommand\hypersc[2][\gls@number]{%

\textsc{\glshyper{#1}{#2}}}

\providecommand\hypermd[2][\gls@number]{%

\textmd{\glshyper{#1}{#2}}}

Hyperlinks not enabled.\else

\providecommand\hyperrm[2][]{\textrm{#2}}

\providecommand\hypersf[2][]{\textsf{#2}}

\providecommand\hypertt[2][]{\texttt{#2}}

\providecommand\hypermd[2][]{\textmd{#2}}

\providecommand\hyperbf[2][]{\textbf{#2}}

\providecommand\hyperit[2][]{\textit{#2}}

\providecommand\hypersl[2][]{\textsl{#2}}

\providecommand\hyperup[2][]{\textup{#2}}

\providecommand\hypersc[2][]{\textsc{#2}}

52

Page 53: glossary

\providecommand\hyperem[2][]{\emph{#2}}

\fi

Change History

1.0General: Initial version . . . . . . . . 1

1.1General: ’delimR . . . . . . . . . . . . 18

’glossarypostamble . . . . . . . . . 16’glossarypreamble . . . . . . . . . . 16Increased User Flexibility . . . . 17’delimN . . . . . . . . . . . . . . . . 18’glsnumformat . . . . . . . . . . . 17Package option number . . . . . . . 7

2.0General: Acronyms . . . . . . . . . . 12

Hyper page formats: ’hypersf,’hypertt, ’hyperbf and’hyperbf . . . . . . . . . . . . . . . . 3

Package option altlist style . . 7Package option hyper . . . . . . . . 8Package option toc . . . . . . . . . 7primary acronym number format’glsprimaryfmt . . . . . . . . . . 27

2.01General: Fixed conflict with date-

time package . . . . . . . . . . . . 252.1

General: made glossary compatiblewith array package . . . . . . . . 18

name field can be omitted in’newacronym . . . . . . . . . . . . . 13

2.11General: ’useacronym . . . . . . . . 14

2.12General: Hyper page format:

’hyperrm . . . . . . . . . . . . . . . . 3Package option section . . . . . . 8primary acronym number format’glsprimaryfmt no longer used 27

2.13General: Package option

hyperacronym . . . . . . . . . . . . 272.14

General: ’ifacronymfirstuse added 14’resetacronym added . . . . . . . 14’saveglosentry added . . . . . . . 27’setglossary added . . . . . . . . . 17’useGlosentry added . . . . . . . . . 4’useglosentry added . . . . . . . . . 4’xglossary added . . . . . . . . . . . 4

makeglos -m switch added . . . . 62.15

General: ’shortglossaryname . . . . 162.16

General: fixed bug preventingchanges to ’glossaryname and’shortglossaryname . . . . . . . . 16

2.17General: ’storeglosentry added . . . 4

Package option acronym . . . . . . 82.18

General: ’gls added . . . . . . . . . . . 4Fixed bug in ’useacronym . . . . 14

2.19General: ’acrln added . . . . . . . . . 14

’acrsh added . . . . . . . . . . . . . 14fixed bug in ’storeglosentry . . . . 4

2.2General: ’glossaryname now defined

using ’providecommand insteadof ’newcommand . . . . . . . . . . 16

2.21General: ’resetallacronyms added 14

2.22General: Added ’acronymfont . . . 15

added makeglos.bat file . . . . . . 2Added provision for ’xspace . . 15changed makeglos to read infor-mation in from .aux instead of.log file . . . . . . . . . . . . . . . . . 11

2.23General: Fixed minor bug with hy-

perlinks and ’glsxspace . . . . . 152.24

General: Package option hypertoc 82.26

General: Fixed bug in ’useacronym 142.28

General: Fixed erroneous spaces oc-curing while using xspace . . . 15

2.3General: ’delimT . . . . . . . . . . . . 18

’gloskip . . . . . . . . . . . . . . . . . 18’glsafternum . . . . . . . . . . . . . 17’glsbeforenum . . . . . . . . . . . . 17Added extra optional argumentto ’newglosarytype . . . . . . . . 11

53

Page 54: glossary

made glossary compatible witharray package . . . . . . . . . . . . 18

2.31

General: ’unsetacronym added . . 14

’unsetallacronyms added . . . . . 14

Package option global . . . . . . . 8

2.32

General: added ’setacronymdescfmt

. . . . . . . . . . . . . . . . . . . . . . . 13

2.4

General: ’glspageheader added . . 16

Added facility to insert text be-tween groups . . . . . . . . . . . . 18

Hyper page formats updated totake two arguments. Additionalformats also provided . . . . . . . 3

Package option number modifiedso that any counter can be used 7

primary acronym number format’glsprimaryfmt has been re-moved . . . . . . . . . . . . . . . . . 27

provision for ’glossarysubheaderadded . . . . . . . . . . . . . . . . . . 19

Index

A\acrln . . . . . . . . . . . 14\acronymfont . . . . . . 15acroread . . . . . . . . . 25\acrsh . . . . . . . . . . . 14\afterglossary . . . . 18array . . . . . . . . 19, 25, 42

B\beforeglossary . . . 18

Ddatetime . . . . . . . . . . 25\delimN . . . . . . . . . . 50\delimR . . . . . . . . . . 50\descriptionname . .

. . . . . . . 16, 19, 20\descriptionwidth . 19

E\entryname . . . . . 16, 20

Ffile types

acr . . . . . . . . . . . 12cfg . . . . . . . . . . 8, 13glg . . . . . . . 6, 11, 23glo . . . . . . . 6, 11, 24gls . . 6, 7, 11, 23, 24ist . . . . . . . 6, 23, 26perl . . . . . . . . . . 21

G\glodesc . . . . . . . . . 13\gloitem . . . . . . . . . 19\glolong . . . . . . . 13, 13\gloshort . . . . . . 13, 13

glossary . . 1, 4, 8, 12,15, 16, 20, 24–26

\glossary . . . . 2, 3,4, 9, 10, 12, 19,22–25, 31, 45, 46

glossary border . . . . .. . . . see pack-age options, border

glossary columns . . . .. . . . see pack-age options, cols

glossary header . . . . .. . . . see pack-age options, header

\glossary keysdescription . . 2, 4, 13format . . . . . 2, 3, 25

hyperbf . . . . . 3, 25hyperem . . . . . . 3hyperit . . . . . . . 3hypermd . . . . . . 3hyperrm . . . . . . 3hypersc . . . . . . . 3hypersf . . . . . . . 3hypersl . . . . . . . 3hypertt . . . . . . . 3hyperup . . . . . . 3

name 2, 12–14, 19, 34number . . . . . . . 2, 3sort . . . . . . . . . 2, 12

glossary style see pack-age options, style

glossary.cfg . . . . . . . .. . see file type, cfg

\glossaryalignment .. . . . . . . 18, 24, 30

\glossaryheader . 19, 40

\glossaryname . . . . .. . . . . 7, 12, 16, 20

\glossarypackageoptions

. . . . . . . . . . . . . 8\glossarypostamble . 16\glossarypreamble . 16\glossarysubheader .

. . . . . . . . . 19, 40\glosslabel . . . . . . . 30\glossref . . . . . . . . 30\glosstail . . . . . . . 19\gls . . . . . . . 4, 5, 23, 24\glsafternum . . . . . . 17\glsbeforenum . . . . . 17\glshyper . . . . . . . . 50\glshyperpage . . . 50, 51\glshypersection . . 51\glspageheader . . . .

. . . . 16, 20, 40, 41\glsprimaryfmt . . . . 27

Hhtml . . . . . . . . . 8, 25, 29\hyperpage . . . . . 29, 50hyperref . . . . . 8, 20,

21, 25, 27–29, 50\hyperrm . . . . . . . . 3, 37\hypertarget . . . . . . 30

I\ifacronymfirstuse . 14\ifist . . . . . . . . . . . 45ifthen . . . . . . . . . . . . 49\istfilename . . . . . 6, 45\isttrue . . . . . . . . . 45

Kkeyval . . . . . . . . . . . . 24

54

Page 55: glossary

keyval . . . . . . . . . . . 24

M\makeacronym . 12, 23, 29makeglos.pl . . 6, 11,

12, 20, 21, 23, 26\makeglossary 2, 6, 10,

22, 23, 26, 45, 46makeindex . . 1, 2, 6,

7, 11, 12, 14, 17–19, 21, 23, 24, 26

makeindex keydelim 0 . . . . . . . . 17delim n . . . . . . . . 18delim r . . . . . . . . 18delim t . . . . . . . . 18group skip . . . . . . 18item 0 . . . . . . . . . 19

makeindex style file(.ist) . . . . . . .. . see file types, ist

N\newacronym 12, 13, 25, 46\newglossarystyle . 17\newglossarytype 10, 46ngerman . . . . . . 6, 26, 44\nofiles . . . . . . . . . . 6\noist . . . . . . . . . . 6, 26

Ppackage options

,none . . . . . . . . . 7

acronym . . . 8, 12, 29false . . . . . . . 8, 22true . . . . . . 8,12, 13, 22, 23, 29

altlist . . . . . . . . . 40border 7, 8, 19, 28, 43

none . . 7, 9, 10, 28plain . 7, 10, 28, 43

cols . . . . . . . . 7, 8, 432 . . . . 7, 19, 28, 433 . . . . . . 7, 10,16, 17, 19, 28, 43

global . . . . . 8, 23, 29false . . . . . . . . . 8true . . . . . . . 8, 29

header . . 7, 8, 28, 43

none . . 7, 9, 10, 28plain . 7, 10, 28, 43true . . . . . . 16, 19

hyper . . . . . . . . .3, 8, 14, 25, 27, 29

false . . . . . . . . . 8true . 8, 22, 27, 29

hyperacronym . . 8, 27false . . . . . . . . 27true . . . . . . . . 27

hypertoc . . . 8, 28, 37false . . . . . . . 8, 38true . . . . . . . 8, 38

list . . . . . . . . . . . 39long . . . . . . . . . . 42number . . . . 7, 34, 44

equation . . . . . 20none . . . . . . 9,17, 18, 28, 34, 44

page . . . . . . . 7, 9section . . . . . . 20

section . . . . . . . 8, 29false . . . . . . . . . 8true . . . . . . . . . 8

style . . . . . . 7, 27, 43altlist . . . . . . .

. . . 7–9, 17–22, 27list . 7–9, 18, 19, 27long . . . . . . 7,9, 10, 19, 24, 27, 28

super . . . . . . .. . 7, 19, 24, 27, 28

super . . . . . . . . . 42style . . . . . . . . 28

toc . . . . . 7, 8, 20, 28false . . . . . . . . . 8true . . . . 8, 22, 38

page number formatshyperbf . . . . . . . 3, 25hyperem . . . . . . . . 3hyperit . . . . . . . . . 3hypermd . . . . . . . . 3hyperrm . . . . . . . . 3hypersc . . . . . . . . . 3hypersf . . . . . . . . . 3hypersl . . . . . . . . . 3hypertt . . . . . . . . . 3hyperup . . . . . . . . 3

perl . . . . . . . . . . . . . . 2

\phantomsection . . . 28\printacronym 12, 23, 29\printglossary . . 7,

10, 11, 23, 34, 37\protect . . . . . . . . . 23

R\resetacronym . . . . . 14\resetallacronyms . 14

S\saveglosentry 23, 27, 27\setacronymdescfmt . 13\setacronymnamefmt .

. . . . . . . . . 13, 14\setglossary . 17, 22, 25\setglossary keys

delimN . . . . . . . . 18delimR . . . . . . . . 18delimT . . . . . . . . 18glodelim . . . . . . . 17gloskip . . . . . . . . 18glsnumformat . 17, 25type . . . . . . . . . . 17

\setglossarystyle . 17\shortglossaryname . 16\storeglosentry . . .

. . . 4, 5, 20, 22–24

Ttable of contents,

adding to . seepackage options, toc

U\unsetacronym . . . . . 14\unsetallacronyms . 14\useacronym . . . . . 14, 16\useGlosentry 4, 5, 23, 24\useglosentry . . . . .

. . . 4, 5, 23, 24, 33

X\xacronym . . . . . . . . 12\xglossary . 4, 8, 10,

12, 23, 27, 32, 46xpdf . . . . . . . . . . . . . 25xspace . . . . . . . . . 15, 30\xspace . . . . . . . . 15, 30

55