> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/document-structure/05-glossaries.md).

# Glossaries

## Introduction

When writing a document that contains some field-specific concepts it might be convenient to add a glossary. A glossary is a list of terms in a particular domain of knowledge with definitions for those terms. This article explains how to create one.

**Important advisory note**: Your project’s [main file](/latex/knowledge-base/127-set-main-document.md) should always be in the root directory (outside of any folders), to ensure that all of the compilation steps will be run in the correct directory and to ensure that the required auxiliary files are available, for instance, when creating a glossary or adding an index.

Let's start with a simple example.

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{latex}
{
    name=latex,
    description={Is a markup language specially suited
    for scientific documents}
}

\newglossaryentry{maths}
{
    name=mathematics,
    description={Mathematics is what mathematicians do}
}

\title{How to create a glossary}
\author{ }
\date{ }

\begin{document}
\maketitle

The \Gls{latex} typesetting markup language is specially suitable
for documents that include \gls{maths}.

\clearpage

\printglossaries

\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Glossaries+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Butf8%5D%7Binputenc%7D%0A%5Cusepackage%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++name%3Dlatex%2C%0A++++description%3D%7BIs+a+markup+language+specially+suited+%0A++++for+scientific+documents%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++name%3Dmathematics%2C%0A++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Ctitle%7BHow+to+create+a+glossary%7D%0A%5Cauthor%7B+%7D%0A%5Cdate%7B+%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%0A%0A%5Cclearpage%0A%0A%5Cprintglossaries%0A%0A%5Cend%7Bdocument%7D)

The following image shows the Glossary produced by the example above:

![Glossary1OLV2.png](/files/maZlWfec1vdfo2mRsxfS)

To create a glossary the package `glossaries` has to be imported. This is accomplished by the line

```latex
\usepackage{glossaries}
```

in the preamble. The command `\makeglossaries` must be written before the first glossary entry.

Each glossary entry is created by the command `\newglossaryentry` which takes two parameters, then each entry can be referenced later in the document by the command `\gls`. See the subsection about [terms](#terms) for a more complete description.

The command `\printglossaries` is the one that will actually render the list of words and definitions typed in each entry, with the title "Glossary". In this case it's shown at the end of the document, but `\printglossaries` can be used in any other location.

## Terms and Acronyms

Usually there are two types of entries in a glossary: terms and their definitions, or acronyms and their meaning. This two types can be printed separately in your LaTeX document.

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[acronym]{glossaries}

\makeglossaries

\newglossaryentry{latex}
{
        name=latex,
        description={Is a mark up language specially suited for
scientific documents}
}

\newglossaryentry{maths}
{
        name=mathematics,
        description={Mathematics is what mathematicians do}
}

\newglossaryentry{formula}
{
        name=formula,
        description={A mathematical expression}
}

\newacronym{gcd}{GCD}{Greatest Common Divisor}

\newacronym{lcm}{LCM}{Least Common Multiple}

\begin{document}

The \Gls{latex} typesetting markup language is specially suitable
for documents that include \gls{maths}. \Glspl{formula} are
rendered properly an easily once one gets used to the commands.

Given a set of numbers, there are elementary methods to compute
its \acrlong{gcd}, which is abbreviated \acrshort{gcd}. This
process is similar to that used for the \acrfull{lcm}.

\clearpage

\printglossary[type=\acronymtype]

\printglossary

\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Glossaries+Terms+and+Acronyms+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Butf8%5D%7Binputenc%7D%0A%5Cusepackage%5Bacronym%5D%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++++++name%3Dlatex%2C%0A++++++++description%3D%7BIs+a+mark+up+language+specially+suited+for+%0Ascientific+documents%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++++++name%3Dmathematics%2C%0A++++++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Bformula%7D%0A%7B%0A++++++++name%3Dformula%2C%0A++++++++description%3D%7BA+mathematical+expression%7D%0A%7D%0A%0A%5Cnewacronym%7Bgcd%7D%7BGCD%7D%7BGreatest+Common+Divisor%7D%0A%0A%5Cnewacronym%7Blcm%7D%7BLCM%7D%7BLeast+Common+Multiple%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%5CGlspl%7Bformula%7D+are+%0Arendered+properly+an+easily+once+one+gets+used+to+the+commands.%0A%0AGiven+a+set+of+numbers%2C+there+are+elementary+methods+to+compute+%0Aits+%5Cacrlong%7Bgcd%7D%2C+which+is+abbreviated+%5Cacrshort%7Bgcd%7D.+This+%0Aprocess+is+similar+to+that+used+for+the+%5Cacrfull%7Blcm%7D.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%5Btype%3D%5Cacronymtype%5D%0A%0A%5Cprintglossary%0A%0A%5Cend%7Bdocument%7D)

The following image shows part of the output produced by the example above:

![Glossary2OLV2.png](/files/HYCidpBHrK4buaWFNGlm)

The following subsections explain how to create each of the list types.

### Terms

As seen in the [introduction](#introduction), terms are defined by means of the command `\newglossaryentry`

```latex
\documentclass{article}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{maths}
{
    name=mathematics,
    description={Mathematics is what mathematicians do}
}

\newglossaryentry{latex}
{
    name=latex,
    description={Is a markup language specially suited for
scientific documents}
}

\newglossaryentry{formula}
{
    name=formula,
    description={A mathematical expression}
}

\begin{document}

The \Gls{latex} typesetting markup language is specially suitable
for documents that include \gls{maths}. \Glspl{formula} are rendered
properly an easily once one gets used to the commands.

\clearpage

\printglossary

\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+Glossary+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++name%3Dmathematics%2C%0A++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++name%3Dlatex%2C%0A++++description%3D%7BIs+a+markup+language+specially+suited+for+%0Ascientific+documents%7D%0A%7D%0A%0A%0A%5Cnewglossaryentry%7Bformula%7D%0A%7B%0A++++name%3Dformula%2C%0A++++description%3D%7BA+mathematical+expression%7D%0A%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%5CGlspl%7Bformula%7D+are+rendered+%0Aproperly+an+easily+once+one+gets+used+to+the+commands.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%0A%0A%5Cend%7Bdocument%7D)

The following image shows the Glossary created by the example above:

![Glossary3OLV2.png](/files/AwbPAUG8J4YVDDT5dAQy)

Let's see in more detail the syntax of each parameter passed to the command `\newglossaryentry`. The first term defined in the example is "mathematics".

* `maths`. This first parameter is the label of this term and is used to reference it within the document with `gls`
* `name=mathematics`. Includes The word to be defined, in this case "mathematics". It's recommended to write it in lowercase letters and singular form.
* `description={Mathematics is what mathematicians do}`. Inside the braces is the definition of the current term.

After you have defined the terms, to use them while you are typing your LaTeX file use one of the commands describe below:

**\gls{ }**

To print the term, lowercase. For example, \gls{maths} prints mathematics when used.

**\Gls{ }**

The same as \gls but the first letter will be printed in uppercase. Example: \Gls{maths} prints Mathematics

**\glspl{ }**

The same as \gls but the term is put in its plural form. For instance, \glspl{formula} will write formulas in your final document.

**\Glspl{ }**

The same as \Gls but the term is put in its plural form. For example, \Glspl{formula} renders as Formulas.

Finally, to print the glossary use the command

```latex
\printglossary
```

### Acronyms

An acronym is a word formed from the initial letters in a phrase. Below is an example of acronyms in LaTeX

```latex
\documentclass{article}
\usepackage[acronym]{glossaries}

\makeglossaries

\newacronym{gcd}{GCD}{Greatest Common Divisor}

\newacronym{lcm}{LCM}{Least Common Multiple}

\begin{document}
Given a set of numbers, there are elementary methods to compute
its \acrlong{gcd}, which is abbreviated \acrshort{gcd}. This process
is similar to that used for the \acrfull{lcm}.

\clearpage

\printglossary[type=\acronymtype]

\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+Glossary+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bacronym%5D%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%5Cnewacronym%7Bgcd%7D%7BGCD%7D%7BGreatest+Common+Divisor%7D%0A%0A%5Cnewacronym%7Blcm%7D%7BLCM%7D%7BLeast+Common+Multiple%7D%0A%0A%5Cbegin%7Bdocument%7D%0AGiven+a+set+of+numbers%2C+there+are+elementary+methods+to+compute+%0Aits+%5Cacrlong%7Bgcd%7D%2C+which+is+abbreviated+%5Cacrshort%7Bgcd%7D.+This+process+%0Ais+similar+to+that+used+for+the+%5Cacrfull%7Blcm%7D.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%5Btype%3D%5Cacronymtype%5D%0A%0A%5Cend%7Bdocument%7D)

The following image shows part of the output produced by the example above:

![Glossary4OLV2.png](/files/sNPTPueTTt6HJu60mPPp)

To use acronyms an additional parameter must be used when importing the **glossaries** package. The line to be added to the preamble is

```latex
\usepackage[acronym]{glossaries}
```

Once this line is added, the command `\newacronym` will declare a new acronym. For the sake of an example, below is a description of the command `\newacronym{gcd}{GCD}{Greatest Common Divisor}`

* `gcd` is the label, used latter in the document to reference this acronym.
* `GCD` the acronym itself. Usually acronyms are written in capital letters.
* `Greatest Common Divisor` is the phrase this acronym is used for.

After the acronyms have been included in the preamble, they can be used by means on the next commands:

**\acrlong{ }**

Displays the phrase which the acronyms stands for. Put the label of the acronym inside the braces. In the example, \acrlong{gcd} prints Greatest Common Divisor.

**\acrshort{ }**

Prints the acronym whose label is passed as parameter. For instance, \acrshort{gcd} renders as GCD.

**\acrfull{ }**

Prints both, the acronym and its definition. In the example the output of \acrfull{lcm} is Least Common Multiple (LCM).

To print the list of acronyms use the command

```latex
\printglossary[type=\acronymtype]
```

The acronyms list needs a temporary file generated by `\printglossary` to work, thereby you must add said command right before the line `\printglossary[type=\acronymtype]` and compile your document, once you've compiled your document for the first time you can remove the line `\printglossary`.

## Changing the title of the Glossary

If you want to change the default title of the glossary for something else, this is straightforward, two parameters must be added when printing the glossary. Below is an example.

```latex
\documentclass{article}
\usepackage{glossaries}

\makeglossaries

\newglossaryentry{maths}
{
    name=mathematics,
    description={Mathematics is what mathematicians do}
}

\newglossaryentry{latex}
{
    name=latex,
    description={Is a markup language specially suited for
scientific documents}
}

\newglossaryentry{formula}
{
    name=formula,
    description={A mathematical expression}
}

\begin{document}

The \Gls{latex} typesetting markup language is specially suitable
for documents that include \gls{maths}. \Glspl{formula} are rendered
properly an easily once one gets used to the commands.

\clearpage

\printglossary[title=Special Terms, toctitle=List of terms]

\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+Glossary+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++name%3Dmathematics%2C%0A++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++name%3Dlatex%2C%0A++++description%3D%7BIs+a+markup+language+specially+suited+for+%0Ascientific+documents%7D%0A%7D%0A%0A%0A%5Cnewglossaryentry%7Bformula%7D%0A%7B%0A++++name%3Dformula%2C%0A++++description%3D%7BA+mathematical+expression%7D%0A%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%5CGlspl%7Bformula%7D+are+rendered+%0Aproperly+an+easily+once+one+gets+used+to+the+commands.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%5Btitle%3DSpecial+Terms%2C+toctitle%3DList+of+terms%5D%0A%0A%5Cend%7Bdocument%7D)

The following image shows part of the output produced by the example above:

![Glossary5OLV2.png](/files/Ezfa0oFk9IGXRFPfTr84)

Notice that the command `\printglossary` has two comma-separated parameters:

* `title=Special Terms` is the title to be displayed on top of the glossary.
* `toctitle=List of terms` this is the entry to be displayed in the table of contents. See the [next section](#show-the-glossary-in-the-table-of-contents).

## Show the glossary in the table of contents

For the glossary to show up in the table of contents put

```latex
\usepackage[toc]{glossaries}
```

in the preamble of your document

```latex
\documentclass{article}
\usepackage[toc]{glossaries}

\makeglossaries

\newglossaryentry{maths}
{
    name=mathematics,
    description={Mathematics is what mathematicians do}
}

\newglossaryentry{latex}
{
    name=latex,
    description={Is a markup language specially suited for
scientific documents}
}

\newglossaryentry{formula}
{
    name=formula,
    description={A mathematical expression}
}

\begin{document}

\tableofcontents

\section{First Section}
The \Gls{latex} typesetting markup language is specially suitable
for documents that include \gls{maths}. \Glspl{formula} are rendered
properly an easily once one gets used to the commands.

\clearpage

\printglossary[title=Special Terms, toctitle=List of terms]

\end{document}
```

[Open this example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Another+Glossary+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Btoc%5D%7Bglossaries%7D%0A%0A%5Cmakeglossaries%0A%0A%5Cnewglossaryentry%7Bmaths%7D%0A%7B%0A++++name%3Dmathematics%2C%0A++++description%3D%7BMathematics+is+what+mathematicians+do%7D%0A%7D%0A%0A%5Cnewglossaryentry%7Blatex%7D%0A%7B%0A++++name%3Dlatex%2C%0A++++description%3D%7BIs+a+markup+language+specially+suited+for+%0Ascientific+documents%7D%0A%7D%0A%0A%0A%5Cnewglossaryentry%7Bformula%7D%0A%7B%0A++++name%3Dformula%2C%0A++++description%3D%7BA+mathematical+expression%7D%0A%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Ctableofcontents%0A%0A%5Csection%7BFirst+Section%7D+%0AThe+%5CGls%7Blatex%7D+typesetting+markup+language+is+specially+suitable+%0Afor+documents+that+include+%5Cgls%7Bmaths%7D.+%5CGlspl%7Bformula%7D+are+rendered+%0Aproperly+an+easily+once+one+gets+used+to+the+commands.%0A%0A%5Cclearpage%0A%0A%5Cprintglossary%5Btitle%3DSpecial+Terms%2C+toctitle%3DList+of+terms%5D%0A%0A%5Cend%7Bdocument%7D)

The following image shows the content of the 2 pages produced by the example above. Note how the command

```latex
\printglossary[title=Special Terms, toctitle=List of terms]
```

produces different titles for the table of contents ("List of terms") and the corresponding heading used in the text ("Special Terms"):

![Glossary6OLV2.png](/files/81NFheQvEQsiJh3lzprr)

## Compiling the glossary

To compile a document that contains a glossary in [Overleaf](http://overleaf.com) you don't have to do anything special, but if you add new terms to the glossary once you compiled it, make sure to click on *Clear cached files* first under logs option).

If you are compiling the document, for instance one called `glossaries.tex`, using pdflatex **on your local machine**, you have to use these commands:

`pdflatex glossaries.tex`

`makeglossaries glossaries`

`pdflatex glossaries.tex`

## Reference guide

**Styles available for glossaries**

The command `\setglossarystyle{style}` must be inserted before `\printglossaries`. Below a list of available styles:

* list. Writes the defined term in boldface font
* altlist. Inserts newline after the term and indents the description.
* listgroup. Group the terms based on the first letter.
* listhypergroup. Adds hyperlinks at the top of the index.

## Further reading

For more information see:

* [Indices](/latex/document-structure/04-indices.md)
* [Lists of tables and figures](/latex/figures-and-tables/03-lists-of-tables-and-figures.md)
* [Table of contents](/latex/document-structure/02-table-of-contents.md)
* [Sections and chapters](/latex/document-structure/01-sections-and-chapters.md)
* [Hyperlinks](/latex/document-structure/09-hyperlinks.md)
* [International language support](/latex/languages/03-international-language-support.md)
* [Cross referencing sections and equations](/latex/document-structure/03-cross-referencing-sections-equations-and-floats.md)
* [Management in a large project](/latex/document-structure/07-management-in-a-large-project.md)
* [Multi-file LaTeX projects](/latex/document-structure/08-multi-file-latex-projects.md)
* [Glossary article on WikiBooks](http://en.wikibooks.org/wiki/LaTeX/Glossary)
* [The glossaries package: a guide for beginners](http://theoval.cmp.uea.ac.uk/~nlct/latex/packages/glossaries/glossariesbegin.html)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/document-structure/05-glossaries.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
