- IN Packages
Create a simple nomenclature with the longtable package
- Apr 28, 2012 |
- 9 Comments
There are plenty of LaTeX packages that enable users to create a nomenclature (also called glossary or list of symbols); some make use of makeindex or xindy, others use bibtex. I think a nomenclature adds a great amount of value to theses or other large documents, but setting up a system to maintain one is a bit of a pain (especially for beginning LaTeX users). So today a post on how to create a nomenclature, simple and fast. This one is probably interesting for beginning users only, but also for TeXers that can’t be bothered to use an additional process like makeindex.
The longtable package
The longtable package provides a longtable environment that allows to create tables spanning multiple pages. This is perfect for the use of a nomenclature:
- In table environments, you can align the entries. A nomenclature mostly requires two or three columns, which should be aligned!
- For larger documents, it is likely that your nomenclature will span more than one page and the
longtablepackage handles this perfectly.
To include the longtable package in your LaTeX document, add the following line to your preamble:
\usepackage{longtable} |
Setting up the nomenclature
The nomenclature we will create here consists of three columns: the first for the symbol, the middle column for the unit and the last one for a description. Here’s how to implement it:
\begin{longtable}[l]{p{50pt} p{50pt} p{200pt}} \textbf{Symbol} & \textbf{Units} & \textbf{Description} \\ $L$ & \si{\meter} & Length\\ $Ma$ & $-$ & Mach number\\ $p$ & \si{\pascal} & Pressure %... \end{longtable} |
This piece of code shouldn’t be all to hard to understand. It’s much like a normal table environment. The arguments after \begin{longtable} contain information about the amount of columns (3) and their widths (respectively 50pt, 50pt, and 250pt). This can of course be changed to your own needs. Also, note that the siunitx package, with the \si command, is used here for the units.
Now that the table is created, let’s put it in a separated section. Assuming your working on a large document with a class like book or report (where \chapter is a valid command), add a section like this:
\chapter*{Nomenclature} |
Suppress the section numbering, just like the table of contents, with the asterix (*).
The disadvantage of managing the nomenclature in a way as described in this post is that you’ll have to sort everything manually in order to make the list in alphabetical order. Also, with the alternatives named below you will be able to add content to the nomenclature throughout the complete document (the items will then automatically be added to the nomenclature, similar to the table of contents in LaTeX). However, it does require more time to set up and that might not be worth the trouble. Plus, I find this way more flexible in terms of styling and variance.
What else?
Now that you know how to set up your own simple glossary, let’s expand it a bit. For example, you might want to have different sections for different things (symbols, acronyms, greek symbols, indices and so on). For example, if you want to create a section with acronyms, consisting of a table with two columns, you might want to add this:
\subsection*{Acronyms} \begin{longtable}[l]{p{50pt} p{200pt}} RAC & Rear axle carrier \\ FAC & Front axle carrier \\ ... & ... \\ \end{longtable} |
Alternatives
As said before, a lot of alternatives exist for creating nomenclatures. To name a few:
glossaries: a glossary package that makes use of eithermakeindexorxindy.glossmakes use of bibTeX (where\citeis replaced by\gloss).glosstex: this package also makes use ofmakeindex.listofsymbols: This package does not make use of an additional package for the creation of the glossary and is actually quite similar to the way described here. The difference here is that you can use the\newsymcommand to add items from within the document you are writing.nomenclandnomentbl: these packages are alike, both making use ofmakeindex
I used it and it was working great with the draft version of IEEE paper (i.e. \documentclass[journal,draftcls, onecolumn]{IEEEtran}).
But when I was generating the two column version, it is not working. I wonder if it is because the width of the column (I am using (\begin{longtable}[l]{p{75pt} p{200pt}})). I tried to play with these numbers but still no luck :(
Thanks in advance
Thank you for providing a simple way of creating the Nomenclature. I am using a style file for my PhD thesis writing and it does not have a simple one. Much appreciated.
In my opinion the tabbing environment is even better suited for this approach: it’s simple and you don’t even have to load another package for it.
I actually never use the
tabbingenvironment, but it does indeed the same thing as described in my post. Just a matter of preferences.Hurray! I’m finishing my thesis this week, and don’t have the time to build a “proper” nomenclature database glossaries or similar packages – your solution is perfect for my needs! :)
I’m glad to be of help to you!
I liked the simple trick.. thank you
Nice and simple, I just added it to my thesis without breaking a sweat (except for finding out what to put in the glossary, but that’s OK).
Glad to be of help!