Saturday 16 February 2013

Simple Glossaries in LaTeX

I use LaTeX (via MikTeX) and TeXnicCenter a bit, starting from when I did my PhD. It's a great document preparation system which has some annoying sides, but I won't go down that path. I tried to set up a glossary in a document recently, and it wasn't obvious to me how to do that. I did get it working though. Here's what I did, so that others (including myself) don't have to figure it out again:
  1. Follow the steps provided at LaTeX Matters, namely:
    1.  Put two lines into your preamble (before \begin{document}):
    2. When you define or introduce certain terms, wrap them in a \glossary command like so:
      \glossary{name={entry name}, description={entry description}}
      The inside curly braces are only necessary if you have commas in the entries.
    3. Place this command where you want the glossary to appear:
    4. If you want your glossary to have an entry in the Table of Contents, then put this with the previous line:
    5. Then, instead of running a command as described in the post, follow the next step, which is equivalent, but for TeXnicCenter.
  2. Prompted by Archiddeon's comment in a LaTex forum, in TeXnicCenter, add a post-processing step to a build profile:
    1. Select the Build menu then choose Define Output Profiles...
    2. On the left, select a profile you want to start from
    3. Click the Copy button down below, enter a new name for the profile and click OK
    4. Then click on the Postprocessor tab
    5. Create a new postprocessor step by clicking the little "new folder" icon at the top right
    6. Then enter a name like "Prepare the glossary" and the following:
      Executable: makeindex
      Arguments: "%tm.glo" -s "" -t "%tm.glg" -o "%tm.gls"
  3. Click OK until you're back at the main window!
Then you should be able to select the new profile and generate the document with a glossary! I'd run it 2-3 times to let the page numbers settle. Joy!

No comments:

Post a Comment