Quantcast
Channel: texblog » glossaries
Viewing all articles
Browse latest Browse all 2

Multiple glossaries in LaTeX

0
0

Recently I was asked how to produce multiple glossaries in the same document. The glossaries package, which supersedes glossary, provides such functionality. In this post, I primarily focus on adding topic-specific glossaries besides the main glossary and list of acronyms. Links to further readings are given for glossaries package basics as well as for chapter-/section-/equation-wise glossaries.

  1. Glossary basics
  2. Adding topic-specific glossaries
  3. Minimal working example
  4. Glossary for each chapter/section/equation

 

1. Glossary basics

This recent post introduces the basics of how to use the glossaries package to produce a glossary. A minimal example is given here. You might also want to look through the package documentation which comes in form of a beginner’s guide and a more comprehensive user manual.

 

2. Adding topic-specific glossaries

The glossaries package defines a default/main glossary with the option to produce a list of acronyms. All entries are automatically assigned to the default glossary or list of acronyms. The package also provides functionality to define additional glossaries, such as a list of symbols in an equation or a topic-specific glossary. Here is an example of a topic-specific glossary for top-level domains:

% Preamble
\usepackage{glossaries}
\newglossary[tlg]{domain}{tld}{tdn}{Top-Level Domains}

tlg, tld, and tdn are arguments used as meta-file endings. These files are required when the glossary is generated. The meta-file endings for the main glossary are: glg, gls, and glo. For the list of acronyms, alg, acn, and acr are reserved.
The second argument to newglossary, here domain, specifies the glossary type. It’s a keyword that is used to assign new entries to this specific glossary. The last argument defines the glossary title.

Having defined the new glossary, we can now add glossary entries to it. This works the same way as for the default glossary, with the only difference being the additional type keyword:

\newglossaryentry{tld:com}{%
	type=domain,
	name=.com, 
	description={Commercial entities}
}

Using a label of the form tld:com is not a requirement, but a recommendation. This convention helps to avoid multiply defined entries for different glossaries. Furthermore, it makes it easier to identify which glossary an entry belongs to.

Using glossary entries isn’t different from the default glossary, i.e. \gls{tld:com}, etc. Only glossary entries used in the text will appear in the respective glossary.

Finally, to print all glossaries, simply type:

\printglossaries % all glossaries

In case the order matters or you’d like to produce different glossaries in different positions of your document, you can print each glossary individually using the type keyword:

\printglossary % main glossary
\printglossary[type=domain] % domain glossary

 

3. Minimal working example

multiple-glossaries-latex

\documentclass{article}

\usepackage{glossaries}

%Alternative glossary for top-level domains
\newglossary[tlg]{domain}{tld}{tdn}{Top-Level Domains}

% Generate glossaries
\makeglossaries

\begin{document} 

\section{Top-level domains}

%Term definitions
\newglossaryentry{gls:tld}{name=TLD, description={List of top-level domains}}

\newglossaryentry{tld:com}{type=domain, name=.com, description={Commercial entities}}
\newglossaryentry{tld:net}{type=domain, name=.net, description={Network infrastructure}}
\newglossaryentry{tld:org}{type=domain, name=.org, description={Public interest registry}}

% Use the terms
Top-level domains (\gls{gls:tld}) include \gls{tld:com}, \gls{tld:net}, and \gls{tld:org}.

% Print the glossaries
\printglossary[type=domain]
\printglossary

\end{document}

 

4. Glossary for each chapter/section/equation

Although, you might want to think twice whether to have a glossary per chapter/section/equation, here is a solution for chapters/sections and with some modification for equations.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images