Resurchify

# Glossaries in LaTeX

Technical documents such as conference papers, journal paper, etc. use various acronyms and terms which are generally unknown or new to common readers. Hence, to make these documents easily understandable, it is advised to add glossary/glossaries. This tutorial teaches how one can use the glossary in LaTeX to make their documents more accessible.

## Introduction

Let's consider the below example to understand:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{glossaries} \makeglossaries \newglossaryentry{latex} { name=latex, description={LaTeX (short for Lamport TeX) is a document preparation system. The user has to think about only the content to put in the document and the software will take care of the formatting. } } \newglossaryentry{glsy} { name=glossary, description={Acronyms and terms which are generally unknown or new to common readers.} } \title{How to use glossary in LaTeX} \author{ } \date{ } \begin{document} \maketitle \Gls{latex} is very useful and can use \gls{glsy}. \clearpage \printglossaries \end{document} 

In order to use glossaries in LaTeX, you need to include \usepackage{glossaries} package in the preamble of your document. Add the command \makeglossaries before the first entry of the glossary as shown in the above example.

For creating an entry in the glossary you need to use the \newglossaryentry command which takes two parameters as shown in the above example. Once the entry is added, you can refer to this entry later anywhere in your document using the gls command.

To print all glossary entries with their definitions and respective descriptions, use the command \printglossaries. This will be printed under the title Glossary.

## Terms and Acronyms

In general, the glossary has two categories of entries: acronyms and respective meaning, or terms and its respective definition. You can print these categories/types separately in your document.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[acronym]{glossaries} \makeglossaries \newglossaryentry{latex} { name=latex, description={LaTeX (short for Lamport TeX) is a document preparation system. The user has to think about only the content to put in the document and the software will take care of the formatting. } } \newglossaryentry{glsy} { name=glossary, description={Acronyms and terms which are generally unknown or new to common readers.} } \newacronym{s2e}{S2E}{Start to End} \newacronym{b2e}{B2E}{Beginner to Expert} \title{How to add glossary in LaTeX} \author{ } \date{ } \begin{document} \maketitle This \Gls{latex} tutorial is very important and will talk about the use of \gls{glsy}. Plural of \Gls{glsy} is not \Glspl{glsy}. This tutorial which teach you glossary use from \acrlong{s2e}, which is later abbreviated as \acrshort{s2e} in this tutorial. This tutorial is useful for \acrlong{b2e}. \clearpage \printglossary[type=\acronymtype] \end{document} 

To understand in detail how one can create these different lists, refer to the next section.

### Terms

To define the terms use the command \newglossaryentry as discussed in the introduction.

Let's understand the use with an example:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{glossaries} \makeglossaries \newglossaryentry{latex} { name=latex, description={LaTeX (short for Lamport TeX) is a document preparation system.} } \newglossaryentry{glsy} { name=glossary, description={Acronyms and terms which are generally unknown or new to common readers.} } \title{How to use glossary in LaTeX} \author{ } \date{ } \begin{document} \maketitle This \Gls{latex} tutorial is very important and will talk about the use of \gls{glsy}. Plural of \Gls{glsy} is not \Glspl{glsy}. \clearpage \printglossary \end{document} 

There are three parameters which are passed to the \newglossaryentry command. Details of these parameters with respect first glossary entry in the above example are as follows:

1. latex : This parameter is called as the label of the entry and used by the gls command to refer to this entry within the LaTeX document.
2. name=latex : The word which is to be defined. Here, latex. It is advised to write this in lowercase letters.
3. description={LaTeX (short for Lamport TeX) is a document preparation system.} Definition of the current term is defined under the curly braces.

Once the terms are defined, you can refer them using the following LaTeX commands in your documents:

1. \gls{ } : This command prints the term in lowercase characters. For example, \gls{glsy} will print glossary.
2. \Gls{ } : This is similar to \gls{ } command. The only difference is it will print the first character in the uppercase For example, \Gls{glsy} will print Glossary.
3. \glspl{ } : This command is similar to \gls{ }. The only difference is that it will convert the term into its plural form.
4. \Glspl{ } : This command is similar to \Gls{ } command, with the difference that it will convert the term in its plural also.

Now, in order to print/show the glossaries, use the command \printglossary

### Acronyms

An abbreviation consisting of the first letters of each word in the name of something pronounced as a word.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[acronym]{glossaries} \makeglossaries \newacronym{s2e}{S2E}{Start to End} \newacronym{b2e}{B2E}{Beginner to Expert} \title{How to use glossary in LaTeX} \author{ } \date{ } \begin{document} \maketitle This tutorial which teach you glossary use from \acrlong{s2e}, which is later abbreviated as \acrshort{s2e} in this tutorial. This tutorial is useful for \acrlong{b2e}. \clearpage \printglossary[type=\acronymtype] \end{document} 

In order to use the acronyms in your LaTeX document, you need to add/pass the parameter acronym along with the glossaries package as shown below:

\usepackage[acronym]{glossaries}

After adding the above command in the preamble of the document, you can declare or define the new acronyms using the command \newacronym.

Let's understand the \newacronym command usage and parameter description with an example \newacronym{s2e}{S2E}{Start to End} :

1. s2e : represents the label. This is used to refer to this acronym later in the document.
2. S2E : represents the acronym. It is recommended to write the acronym in uppercase.
3. Start to End : represents the full form or expansion of the acronym written within the curly braces.

Once you include the acronyms within the preamble of the document, it can be referenced using the following commands:

1. \acrlong{ } : This command prints the acronym full form/expansion. For example, \acrlong{s2e} displays Start to End.
2. \acrshort{ } : This command displays the name of the acronym whose label is passed as an argument. For example,

\acrshort{s2e} prints/rendered as S2E.
3. \acrfull{ } : This command renders the acronym along with its definition/description.

For example, \arcfull{s2e} will produce the output Start to End (S2E).

To print the list of all acronyms with their defination/description, use command \printglossary[type=\acronymtype].

However, \printglossary[type=\acronymtype] needs a temporary file which is created by \printglossary to work properly. To make it work properly include the command \printglossary just before the command \printglossary[type=\acronymtype].

Please note that you can delete the \printglossary command after the first compilation.

## Change the default title of the Glossary

It is very simple to change or re-write the glossary default title. It can be achieved using the command \printglossary with two more parameters as shown in the below example:

Following are the two parameters which are passed with \printglossary command:

• title=(Special terms) This is what to be displayed on top of the glossary.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[toc]{glossaries} \makeglossaries \newglossaryentry{glsy} { name=glossary, description={Acronyms and terms which are generally unknown or new to common readers.} } \title{How to use glossary in LaTeX} \author{ } \date{ } \begin{document} \maketitle \section{First Section} LaTeX is very useful and can use \gls{glsy}. \printglossary[title=Terms Used, toctitle=List of Terms] \end{document} 

Look at the below example to understand:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[toc]{glossaries} \makeglossaries \newglossaryentry{glsy} { name=glossary, description={Acronyms and terms which are generally unknown or new to common readers.} } \title{How to use glossary in LaTeX} \author{ } \date{ } \begin{document} \maketitle \tableofcontents \section{First Section} LaTeX is very useful and can use \gls{glsy}. \printglossary \end{document} 

## Compiling the glossary

In order to compile a LaTeX document using "glossary.tex", run the following commands:

1. pdflatex glossaries.tex
2. makeglossaries glossaries
3. pdflatex glossaries.tex