Glossary in Latex

By thurnherr

A glossary is a nice thing to have in a report and usually very helpful. As you probably can imaging, it is very easy to create in Latex. Nevertheless, there are a few things to be done, especially generating the glossary-files.

First you have to tell Latex to use the glossary package and to create the glo-file containing all the glossar-entries in your document:

\usepackage{glossary}
\makeglossary

Next you have to add glossary entries to your document. They are of the following form:

\glossary{name={entry name}, description={entry description}}

Note: Usually, the glossary-entry should be added to keywords where they first appear.

A glossary-entry produces by default the following format:

“entry name” “entry description (on multiple lines if necessary)”, “page number”

And finally you have to tell Latex where to place you glossary inside the document which is done by the following command at the location you want to produce the glossary:

\printglossary

Optinally, you can reference to the glossary in the index (toc-file) by adding the following command after “\printglossary”:

\addcontentsline{toc}{chapter}{Glossary}

What you do first is generate your PDF once. An ist-file as well as a glossary file (*.glo) are generated. The glossary-file contains all the glossary entries found in the document in plain text. Next you type the following command in the command-line:

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

generating the two files with the extensions *.gls and *.glg. If entries are ignored or rejected, which can be seen either in the glg-file or directly in the output of the makeindex-command, you have to check your glossary entries. The important of the two files is the *.gls-file, as it is used by Latex for the actual glossary. You now need to re-generate the PDF and if everything works fine, your glossary should appear where you wanted it.

Good luck:-)

Tags: , , , , ,

14 Responses to “Glossary in Latex”

  1. aalderinkg Says:

    I think the glossary style isn’t part of the standard TeTeX distribution (At least not on the distribution I’ve running on my Solaris machine).

    This might discourage people to use it.

    If other people are in need of the package, you can find it on the CTAN repositories under tex-archive/macros/latex/contrib/glossary
    There is a manual included, explaining exactly how to get everything set up

  2. Geri Says:

    I can not thank you enough. Very simple and helpful :)

  3. Tony Ludlow Says:

    Very helpful, and brilliant timing to anticipate my problems. It worked the first time like a dream, but when I tried the second time it says (when running my new makeindex.bat) that it cannot parse output. Should I delete one or more of the files? Which?

  4. thurnherr Says:

    Hi Tony,

    If your glossary entries have changed you may want to restart the procedure again. I would suggest, you remove all the glossary-related files first.

    Tom

  5. annmucc Says:

    Hi all,

    I am trying to generate a glossray with the above insturctions. However, the .gls and .glg files are not being created. I am using LEd as an interface, if that may be the clue to my problems

    Thanks
    Ann

  6. thurnherr Says:

    Hi Ann,

    I tried it with both, Latex and PDFLatex before using “makeindex” in the command line and it worked? Make sure you have the .glo- and .ist-files. Next you have to change directory in the command line to your document directory. Does “makeindex…” produce any error in the command line?
    Alternatively to the command line procedure, you can define your own command in LEd. Go to the LEd install directory and open the “Batches”-directory. Inside you will find a file “user1.bat”, which you drag-and-drop into LEd. You simply have to replace the line saying: “@echo off” by “makeindex document.glo -s document.ist -t document.glg -o document.gls”, where document has to be replaced by the filename of your tex-file. After saving, you can execute the user command 1 (U1) in the top right corner, if you have the standard LEd layout. If you cannot see it, make sure you have the “Latex Compile – additional”-toolbar. OK?

    Cheers,
    Tom

  7. annmucc Says:

    Hi Tom

    Thanks for the tips. I managed to get the glossary :) However, I am also getting the page number written at the end of the glossray enry (as it shows in the default). Does anyone know how this can be removed in an easy way?

    Thanks
    Ann

  8. annmucc Says:

    Hey Ok – just figured out how to do it with some help from google and brother (THis is my first time using Latex, and my IT skills are nothing special, but I am enjoying it)

    You have to write [number=none] between \usepackage and {glossary}

  9. Martoni Says:

    Thanks for your usefull howto, but in my distribution (ubuntu) the makeindex command doesn’t work. Arguments order must be changed:

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

  10. zzzzz Says:

    Nice package… shame there’s not an emacs shortcut for compiling the glossary :(

  11. Victor Says:

    A tip for Kile users:
    Go to “Configure Kile” in settings, under Tools, select Build, “New Tool”
    Name: Glossary (or as you want)
    Command: makeindex
    Options: %S.glo -s %S.ist -t %S.glg -o %S.gls

    Then you can add this in the QuickBuild configuration so that the glossary is automatically generated at each build

    Cheers
    Victor

  12. Owen Says:

    Thank you! Very helpful,

    Owen

  13. josh Says:

    thank you very much, it’s unbelievable how you can explain 55 pages instructions into less than one page.

  14. anonym Says:

    very cool thx!

Leave a Reply