Monday, April 27, 2009

Nomenclature in Latex Made Easy

As pretty as Latex documents are, for 40 years of development you'd think they'd have made all this automatic. I'm using Texmaker to generate the Latex output and a BATCH file to generate the nomenclature. The Latex syntax you'll need can be found here.

In the directory where the Latex file is located create a BATCH file (a text document with the extension changed to .bat) with the following command

makeindex.exe filename.nlo -s -o filename.nls

replace 'filename' with the name of the tex file. For example if the tex file is called 'glossary.tex' then the BATCH file command would look like

makeindex.exe glossary.nlo -s -o glossary.nls

The process is 3 steps,
1) Run Latex on the document to identify the nomenclature,
2) build the nomenclature by double clicking on the BATCH file,
3) print the nomenclature to the output file by running Latex on the document again

The process should similar for generating indexes and glossaries except the Latex syntax is a little different. They all use the makeindex.exe command so they all need different identifiers.

UPDATE:  Hello All.  This post seems to have been quite helpful to many exasperated LaTeX users.  I'm very happy to help.  I wanted to update it a bit to make it more useful.  The following is an example of the syntax you would use within the document itself

This is how we would use the nomenclature
\nomenclature{$a_0$}{speed of sound}%
\nomenclature{$b$}{chamber radius}%
\nomenclature{$c_p$}{specific heat}%

There is one problem with this:  Greek letters don't always alphabetize correctly in the nomenclature.  For instance $\eps$ is alphabetized by 'e' but $\vareps$ is alphabetized by 'v' even though they are different scripts for the same Greek letter.  Also, journals might have a bit of trouble compiling the document with nomenclature like this.  Fortunately, it's not too hard to manually generate nomenclature.  In this case, I follow the format:

$a$ & $\quad=\quad$speed of sound\\
$b$ & $\quad=\quad$chamber radius\\
$c_p$ & $\quad=\quad$specific heat\\

Good luck!


ElSrX said...

Thank you very much! I've been searching for THIS solution for ages, specially the way of executing the line "makeindex.exe glossary.nlo -s -o glossary.nls".

Thanks, greetings from Spain

Melanie said...

I am sorry but I don't know how to create this BATCH file, can someone maybe explain that? Thanks!


Josh said...

Melanie - to make a batch file right click anywhere in windows explorer and click on
New->Text Document

this makes a text doc that opens in notepad or wordpad. This file can be changed to a batch file by renaming the extension from .txt to .bat

If your computer is set up to hide known extensions (like .txt) then you have to disable that to change the extension to .bat. In windows 7 open windows explorer and click
Organize->Folder and Search Options->View and uncheck "Hide extensions for known file types"

In Vista i think the path is slightly different but the "Folder Options" window is the same

JuanConMiedo said...

This is the best explanation I have found. Thank you very much! You saved me a lot of time.

GIbran said...

Thanks a lot for this. Works well. Took me a while to figure out but was definitely worth it.

Chris Simpson said...

Thank you so much - this was causing me a massive headache.
I'm really new to using LATEX, it's a pretty steep learning curve and help like this is invaluable.

ET said...

Thank you! That was very helpful.


Riccardo said...

Thank God, finally someone who solves problems! Thanks a lot, I was going crazy, with all the UNIX-oriented guides on the internet.

Christina said...

Thank you SOOOOOOOOOO much for that :)

Christina said...

Thank you !!!!!!!!!!!