According to Wikipedia, a glossary is an alphabetical list of terms in a particular domain of knowledge with the definitions for those terms. It doesn’t come as a surprise that there are several LaTeX packages that assist with the generation of glossaries. Among them are the nomencl package, the glossary package, and the glossaries package. Nomencl has been around for quite some time and I previously wrote about it on this blog. Glossary is obsolete and has been replaced by glossaries, the most recent and flexible of the three packages. Here, I’ll introduce the glossaries package and provide some code that I hope will help non-expert LaTeX users to generate a glossary or list of acronyms.
Overview of the steps to generate a glossary
- Prepare the tex file
- Load the package
- Tell LaTeX to generate a glossary
- Define the terms and their definitions
- Use the terms
- Print the glossary
- Typeset the document
- Generate the index file
- Typeset the document again
A basic example
\documentclass{article} % Load the package \usepackage{glossaries} % Generate the glossary \makeglossaries \begin{document} %Term definitions \newglossaryentry{utc}{name=UTC, description={Coordinated Universal Time}} \newglossaryentry{adt}{name=ADT, description={Atlantic Daylight Time}} \newglossaryentry{est}{name=EST, description={Eastern Standard Time}} % Use the terms \gls{utc} is 3 hours behind \gls{adt} and 10 hours ahead of \gls{est}. %Print the glossary \printglossaries \end{document}
Most commands are straight forward. A few remarks on the term definition command \newglossaryentry
. The first argument it takes is the label used to produce the term later. The second argument is a key-value pair defining the term and its description. Curly brackets are required if name
or description
consist of multiple words, commas, etc.
\newglossaryentry{⟨label⟩}{name={⟨key⟩}, description={⟨value⟩}}
Capitalize and pluralize terms
The command \gls
produces the name of the term given the label. To capitalize the first letter or pluralize the term, the package implements additional commands.
% Standard command \gls{⟨label⟩} % Capitalize first letter \Gls{⟨label⟩} % Pluralize term \glspl{⟨label⟩} %Capitalize and pluralize term \Glspl{⟨label⟩}
Acronyms
Acronyms are different from glossary entries. For acronyms, the definition is produced in the text with the acronym in parentheses. For glossary entries, only the name is produced. The package distinguishes between glossary and list of acronyms. To do that, the user defines acronyms differently from glossary entries.
\newacronym{⟨label⟩}{⟨abbrv⟩}{⟨full⟩}
By default, acronyms are produced as part of the glossary. To generate a separate list of acronyms, the package needs to be loaded with the acronym
option.
\usepackage[acronym]{glossaries}
Let’s see what the basic example above looks like when we define the terms as acronyms and use the acronym option.
And here is an example of a document with a list of acronyms.
\documentclass{article} % Load the package with the acronym option \usepackage[acronym,nomain]{glossaries} % Generate the glossary \makeglossaries \begin{document} \section*{Section with acronyms} % Acronym definitions \newacronym{utc}{UTC}{Coordinated Universal Time} \newacronym{adt}{ADT}{Atlantic Daylight Time} \newacronym{est}{EST}{Eastern Standard Time} % Use the acronyms \gls{utc} is 3 hours behind \gls{adt} and 10 hours ahead of \gls{est}. %Print the glossary \printglossaries \small\hfill Created by http://texblog.org \end{document}
The same alternative commands as for the glossary are used to capitalize and pluralize acronyms.
Generate the glossary or list of acronyms
Probably the trickiest part comes next. The formatted glossary or list of acronyms needs to be generated from the list of glossary entries or acronyms using makeindex
. Your editor might have a button, but in general the files are generated in the terminal/command-line. The package author provides a Perl script makeglossaries
that greatly simplifies this step. However, it requires Perl to be installed on your computer.
After typesetting the document once (latex/pdflatex), go to the terminal, navigate to the project folder and try the following:
makeglossaries filename
Replace filename with the name of your tex document.
If this doesn’t work, you probably don’t have Perl installed and need to use makeindex
instead (see below). If you manage to run the Perl script but some entries are rejected, the problem is in the LaTeX code.
Here is my makeglossaries
output for glossary and list of acronyms:
Using makeindex to generate the glossary or list of acronyms
Again, replace “filename” with your the name of your tex document.
# Glossary makeindex -s filename.ist -t filename.glg -o filename.gls filename.glo # List of acronyms makeindex -s filename.ist -t filename.alg -o filename.acr filename.acn
About these files:
- *.ist : an input style file, generated by LaTeX.
- *.glo, *.acn : definition files containing the glossary terms, acronyms respectively, generated by LaTeX
- *.glg, *.alg : log files
- *.gls, *.acr : makeindex outputs containing the formatted glossary, list of acronyms respectively.
Produce the glossary or list of acronyms in the document
If this worked, you’re almost done. All you need to do now is go back to the LaTeX document and typeset it again. The glossary or list of acronyms should show up in the document now. Typeset again to make sure the table of contents is updated.
This concludes the basics on glossaries. I might write more about this package later. If you have questions, see the package documentation on CTAN or drop me a comment below. Thanks.
theliberalengineer
Thanks for the good write up this is a very useful tool for any type of technical document writing which relies heavily on acronyms and other jargin.
Mustakeem Mustakeem
Hi, anybody can tell why my list of glossaries and acronyms not generated, although they appear in the text.
tom
Do you do this:
Please provide a minimal working example and I’ll see what I can do…
Marco
Hi! I have copied the example above about Acronyms but even using \printglossaries the list doesn’t appear
tom
Hi Marco,
Thanks for your comment. Did you run
makeglossaries
in the command line as explained towards the end of the article?Best, Tom
joe
Hi, great entry, really helped me!
On addition for people with similar problems;
in Texmaker you can’t define the three commands for makeindex in the makeindex-field.
You have to either specify it as custom command or enter it manually into your compile-line like this:
With this your acronyms and glossary will shop up correctly.
tom
Thanks, good to know! Tom
Arslane Hamza Cherif
Thank you very much, I was stuck and your solution worked like a charm. However, I have just one more question: “Am i obliged to execute all these commands each time I update my list of acronyms ?
Thanks,
Best Regards,
Arslane
tom
Hi there,
That’s right. If you update the list of acronyms, you would have to rerun the command. What I usually do is write a shell/batch script that contains all the commands (latex, bibtex, glossaries, etc.) and then just run the script or use latexmk.
Best, Tom
Tester
Thanks for this post. How can I add some space between the Abbreviation and its full form. They are very close to each other, I need some space between them.
tom
Hi,
You can add more space between the abbreviation and the full name by redefining
\glsnamefont
:Nav
makeindex procedure worked for me on Windows through command prompt. Thanks.
Dim.
Hello,
Thanks for the post.
There is an issue when the acronym is firstly defined in plural: No gap between the expanded version and the acronym in parenthesis
tom
Did you try the glossaries package which supports singular and plural forms of acronyms (
\gls{abc}
and\glspl{abc}
)?Cheers, Tom
Dim.
Yes I am using this package. The problem I am having it the following:
Assume I have the acronym ACR. Then if the expanded version appears in text for the first time in plural, I get ”…Acronyms(ACRs)…”
Currently I have identified the following problem in the filename.glsdefs file:
firstplural={Acrpnyms(ACNs)},%
To solve it, I manually enter a gap in the file.
Perhaps there is a smarter way to solve the issue.
Cheers,
Dim.
tom
According to the bug tracker here, moving the definition of the acronym to the preamble solves the issue.
Personally, I have all acronyms in a file called ‘acronyms.tex’. I load the file in the preamble using:
HTH, Tom
Snakesneaks
Hi, can you fix the unavailable images especially for the part of “Make glossaries output ?
Thank you.
tom
Hi there, thanks for telling me. I’m working on the issue. It should be fixed for this particular article now. Best, Tom.
audric
And about the first methode, i have these messages :
audric-jan:~ audricjan$ makeglossaries rapport
makeglossaries version 2.14 (2014-03-06)
Auxiliary file ‘rapport.aux’ doesn’t exist. Have you run LaTeX?
or
audric-jan:~ audricjan$ makeglossaries /Users/audricjan/Desktop/rapport\ tex/rapport.aux
makeglossaries version 2.14 (2014-03-06)
added glossary type ‘main’ (glg,gls,glo)
added glossary type ‘acronym’ (alg,acr,acn)
The file extension ‘aux’ doesn’t correspond to any
known glossary extension. Try running makeglossaries
without an extension, e.g. makeglossaries “/Users/audricjan/Desktop/rapport tex/rapport”.
tom
Hi Audric,
The second methods should work if you do what it says in the last line. Try running
makeglossaries
without an extension (remove .aux).Let me know if you run into more issues.
Tom
audric
Sorry, i made a mistek in my precedent message, you can forget it..
The message i have is :
audric-jan:~ audricjan$ makeglossaries /Users/audricjan/Desktop/rapport\ tex/rapport
makeglossaries version 2.14 (2014-03-06)
added glossary type ‘main’ (glg,gls,glo)
makeindex -s “rapport.ist” -t “/Users/audricjan/Desktop/rapport tex/rapport.glg” -o “/Users/audricjan/Desktop/rapport tex/rapport.gls” “/Users/audricjan/Desktop/rapport tex/rapport.glo”
Index style file rapport.ist not found.
Usage: makeindex [-ilqrcgLT] [-s sty] [-o ind] [-t log] [-p num] [idx0 idx1 …]
***Call to makeindex failed***
Possible cause of problem:
Style name indicates makeindex, but may be in xindy format.
Remember to use \setStyleFile to specify the name
of the style file rather than redefining \istfilename
explicitly.
Check ‘/Users/audricjan/Desktop/rapport tex/rapport.glg’ for details
audric-jan:~ audricjan$
tom
Hi Audric,
Please remove the white space in your document folder, e.g. rename “rapport tex” to “rapport_tex”. Then delete meta files such as .aux, .glg, .gls, .glo, .ist and rerun LaTeX and makeglossaries. If that doesn’t help, post a minimal example here. That is, a LaTeX document with just one glossary entry and no or little content. I will then run it on my computer and try to advise.
Cheers, Tom
audric
Thank you for your help. I tried with deleting the space, but it still doesn’t work and i have the same message..
Here is my program :
tom
Hi Audric,
Your code is absolutely fine. All you have to do is change directory and run
makeglossaries
from within the project folder, rather than using the path to the file.Also, to change the heading use the following line rather than
\chapter
:audric
hi! it’s ok now! shame on me..i didn’t know i have to write “sudo” before “makeglossaries”….
tom
Please see my response. On my computer, using
sudo
doesn’t fix the problem…audric
It’s strange, all it’s ok for me, only chen “sudo”.. maybe it’s better that i let it like this! In all the cases, thank you very much for you time tom!
Just a last question, do you know how i can delete the number page that is written after each word in the glossary?
tom
Hi Audric,
This should help you Remove page number in glossary.
Cheers, Tom
philmikejones
Thanks. I was using ‘makeglossaries’ with the name of my glossaries file and couldn’t for the life of me figure out why it wasn’t working! Thanks for pointing me in the right direction
tom
Glad you found the information here useful. Thanks for your comment. Best, Tom
Bobie
Please help !!! I didn’t understand this error even though I have already installed perl
” makeglossaries : The script interpreter could not be found.
makeglossaries: Data: scriptInterpreter=”perl.exe”
Process exited with error(s) ”
thnks 🙂
tom
Hi Bobie,
As I won’t be able to reproduce the problem, I can’t offer you any specific help. What comes to my mind is that either Perl was not properly installed or makeglossaries cannot find the software. You can find some suggestions on the former here and on the latter here. Alternatively, you could try to generate the glossaries using makeindex (see here).
Best wishes,
Tom
Sien Van Loo
Hi
I’m using Papeeria to create an Latex-file. I like to create a list of acronyms but I don’t have Perl on my computer. Now I have followed to procedure with makeindex but it still doesn’t work. So I wondered if it was possible to perhaps give me a extensive example or are there other methods to create a list of acronyms?
Kind regards
tom
Hi there,
The alternative would be to use the acronym package, but there is no difference. You would still have to use
makeindex
.I’m not familiar with Papeeria, but maybe they can help you. If you’d like to run it on your computer, you’ll have to open the command line, navigate to the project directory and then use the
makeindex
command to create a list of acronyms. You might have to first typeset the document using(pdf)latex
.I might be able to help if you send me the error you get from makeindex or describe the problem.
Best, Tom
Marco Pizzolato
Hi,
thank you very much for this helpful guide!!
I have a quaestion: when I use tableofcontents the Glossary section (which is correctly generated) is not taken into account in the table of content..
Can you help me?
Thanks in advance,
Marco
tom
Hi Marco,
Thanks for your question. Try loading the package with these options:
Let me know if it worked.
Best, Tom
Sheela
I have used the following code to for list of abbreviations. abbreviations are creating but i am not able to generate the list. please anybody help me to print the list after table of contents
tom
Hi Sheela,
You’ll have to create the list using
makeglossaries
ormakeindex
, either in your editor or in the terminal/commandline. This is explained towards the end of the article. Let me know if you have further questions.Best,
Tom
MWP
Thanks for this useful entry. Users might like to know that updating of the glossary items is effected if you put the \newglossaryentry commands before \begin{document}. (Sorry if this is already commented on — I didn’t read the entire chain.) Check this entry for details: https://tex.stackexchange.com/questions/270098/glossary-entry-not-updated