Saturday 23 November 2013

Using LaTeX and Kile: .gls file does not exist and how to build one

Recently while working on a LaTeX document in Kile, the KDE LaTeX environment, I found myself working on a glossary that failed on the last step. I had set up a glossary .tex file that I included, put the \usepackage[toc]{glossaries}, /makeglossary and /printglossaries lines into the file and tested one of the glossary entries.

No go.

Kile could not find the .gls file. After some navigating the internets for answers, I came upon this blog post.

http://texblog.org/2007/11/01/glossary-in-latex/

After running the command, it did indeed generate the .gls file I needed. But would it regenerate every time my glossary changed? I kept looking for an answer specific to Kile. After a while, I did find it, but it didn't seem to finish what I needed. Kile has a way for the user to create their own build commands which can be run from inside the application. I'll spare you the details, but here's how to integrate glossary building into Kile:


  1. Go to Settings -> Configure Kile ... -> Tools > Build menu (found on the left-hand side of the Settings window)
  2. Under the Select a Tool pane, click the New button to create new tool.
  3. Name the tool "MakeGlossary", click Next button and Select MakeIndex from the list.
  4. ( Here is where the original post I was looking at dropped off... )
  5. In the General tab, for Command: write "makeindex".
  6. Under Command:, type this into the options:
    '%S.glo' -s '%S.ist' -t '%S.glg' -o '%S.glx'

    - Recognize it from the blog post?
  7. Just to be sure and thorough, click on Advanced Tab. For Source extension, write "glo". For Target extension, write "gls".


I have tested the above and it works for me. It does involve two steps (running MakeGlossary and then PDFLaTeX), though it could be possible to string the two commands together somehow. For now, I have what I want and I hope this blog post helps those looking for those same answers.



Cheers.

1 comment:

  1. I think you have a typo in the commands. It should be '%S.glo' -s '%S.ist' -t '%S.glg' -o '%S.gls'

    ReplyDelete