跳到内容

A list of abbreviations and symbols is common in many scientific documents. These types of lists can be created with LaTeX by means on the nomencl package. This article explains how to create nomenclatures, customizing the ordering and subgrouping of the symbols.

Introduction

Nomenclature entries work pretty much like index entries.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{nomencl}
\makenomenclature

\begin{document}
\mbox{}

\nomenclature{$c$}{Speed of light in a vacuum inertial frame}
\nomenclature{$h$}{Planck constant}

\printnomenclature
\end{document}

Nomenclatures01.png


As usual the package is imported in the preamble by \usepackage{nomencl}. The three basic commands to produce the nomenclatures are:

  • \makenomenclature. Usually put right after importing the package.
  • \nomenclature. Used to define the nomenclature entries themselves. Takes two arguments, the symbol and the corresponding description.
  • \printnomenclatures. This command will print the nomenclatures list.

  Open an example of the nomencl package in Overleaf

Basic Syntax

Additional options can be used when importing the nomencl package. The next example shows how to add the nomenclature to the table of contents and how to change the default language:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}

\usepackage[intoc, spanish]{nomencl}
\makenomenclature

\begin{document}
\tableofcontents

\section{Primera Sección}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortisfacilisis sem. Nullam nec mi et neque pharetra sollicitudin. Praesent imperdie...

\clearpage
\mbox{}

\nomenclature{$c$}{Speed of light in a vacuum inertial frame}
\nomenclature{$h$}{Planck constant}

\printnomenclature
\end{document}

Nomenclatures02.png


The additional options used here in when importing the package are:

  • intoc Adds the Nomenclature to the table of contents.
  • spanish Changes the language, translating the default title Nomenclatures accordingly. The supported languages are: croatian, danish, english, french, german, italian, polish, portuguese, russian, spanish and ukranian.

Other useful features of the nomencl package are the possibility of manually setting the nomenclature title, and adding an additional annotation.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{nomencl}
\makenomenclature

\renewcommand{\nomname}{List of Symbols}

\renewcommand{\nompreamble}{The next list describes several symbols that will be later used within the body of the document}

\begin{document}
\mbox{}

\nomenclature{$c$}{Speed of light in a vacuum inertial frame}
\nomenclature{$h$}{Planck constant}

\printnomenclature
\end{document}

Nomenclatures03.png


The line

\renewcommand{\nomname}{List of Symbols}

changes the default title.

The command

\renewcommand{\nompreamble}{The next list...}

inserts some text in between the title and the list symbols.

  Open an example of the nomencl package in Overleaf

Grouping

To group the symbols depending on their type some additional work is needed. We add a prefix to each symbol and use the etoolbox package to compare the prefixes.

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amssymb}

\usepackage{nomencl}
\makenomenclature

%% This code creates the groups
% -----------------------------------------
\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
  \item[\bfseries
  \ifstrequal{#1}{P}{Physics Constants}{%
  \ifstrequal{#1}{N}{Number Sets}{%
  \ifstrequal{#1}{O}{Other Symbols}{}}}%
]}
% -----------------------------------------

\begin{document}
\mbox{}

\nomenclature[P]{$c$}{Speed of light in a vacuum inertial system}
\nomenclature[P]{$h$}{Plank Constant}
\nomenclature[P]{$g$}{Gravitational Constant}
\nomenclature[N]{$\mathbb{R}$}{Real Numbers}
\nomenclature[N]{$\mathbb{C}$}{Complex Numbers}
\nomenclature[N]{$\mathbb{H}$}{Quaternions}
\nomenclature[O]{$V$}{Constant Volume}
\nomenclature[O]{$\rho$}{Friction Index}

\printnomenclature

\end{document}

Nomenclatures04.png


Some extra groups are added. The code for this is not that simple, it uses the command ifstrequal{}{}{}{}, the first two arguments are the strings to compare, if they are equal the term is added to the group, otherwise the next nested condition is checked.

Notice that now each \nomenclture command has an additional argument, the prefix, inside brackets; which is used in the grouping code.

If etoolbox is not available one can use the ifthen package instead, which provides the conditional \ifthenelse{}{}{}, but the syntax is slightly more complex:

\usepackage{ifthen}
  \renewcommand{\nomgroup}[1]{%
  \item[\bfseries
  \ifthenelse{\equal{#1}{P}}{Physics Constants}{%
  \ifthenelse{\equal{#1}{O}}{Other Symbols}{%
  \ifthenelse{\equal{#1}{N}}{Number Sets}{}}}%
  ]}

This will produce the same nomenclature groups.

  Open an example of the nomencl package in Overleaf

Sorting the Entries

This is the default sorting order:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{nomencl}

\makenomenclature

\begin{document}
\mbox{}

\nomenclature{$+a$}{Operator}
\nomenclature{$2a$}{Number}
\nomenclature{$:a$}{Punctuation Symbol}
\nomenclature{$Aa$}{Upper Case Letter}
\nomenclature{$aa$}{Lower Case Letter}
\nomenclature{$\alpha$}{Greek Character}

\printnomenclature

\end{document}

Nomenclatures05.png


Notice that the Greek character showed up before the alphabetic characters because of the backslash \ in \alpha.

Just like for grouping, it is possible to use a prefix to manually sort the nomenclature entries:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{nomencl}

\makenomenclature

\begin{document}
\mbox{}

\nomenclature[06]{$+a$}{Operator}
\nomenclature[03]{$2a$}{Number}
\nomenclature[05]{$:a$}{Punctuation Symbol}
\nomenclature[04]{$Aa$}{Upper Case Letter}
\nomenclature[01]{$aa$}{Lower Case Letter}
\nomenclature[02]{$\alpha$}{Greek Character}

\printnomenclature

\end{document}

Nomenclatures06.png


The number inside the brackets determines the order to print the corresponding symbol. One can also combine grouping and manually sorting:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amssymb}

\usepackage{nomencl}
\makenomenclature

\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
  \item[\bfseries
  \ifstrequal{#1}{A}{Physics Constants}{%
  \ifstrequal{#1}{B}{Number Sets}{%
  \ifstrequal{#1}{C}{Other Symbols}{}}}%
]}

\begin{document}
\mbox{}

\nomenclature[A, 02]{$c$}{Speed of light in a vacuum inertial system}
\nomenclature[A, 03]{$h$}{Plank Constant}
\nomenclature[A, 01]{$g$}{Gravitational Constant}
\nomenclature[B, 03]{$\mathbb{R}$}{Real Numbers}
\nomenclature[B, 02]{$\mathbb{C}$}{Complex Numbers}
\nomenclature[B, 01]{$\mathbb{H}$}{Octonions}
\nomenclature[C]{$V$}{Constant Volume}
\nomenclature[C]{$\rho$}{Friction Index}

\printnomenclature

\end{document}

Nomenclatures07.png


Notice that the capital letters used for grouping are different from the ones used in the example at previous section, because that letter is used to sort the groups.

  Open an example of the nomencl package in Overleaf

Units

Another interesting feature is the possibility of adding units, aligned to the right of the corresponding entries. For this, one has to define the nomunit macro:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{amssymb}

\usepackage{nomencl}
\makenomenclature

\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
  \item[\bfseries
  \ifstrequal{#1}{A}{Physics Constants}{%
  \ifstrequal{#1}{B}{Number Sets}{%
  \ifstrequal{#1}{C}{Other Symbols}{}}}%
]}

% This will add the units
%----------------------------------------------
\newcommand{\nomunit}[1]{%
\renewcommand{\nomentryend}{\hspace*{\fill}#1}}
%----------------------------------------------

\begin{document}
\mbox{}

\nomenclature[A, 02]{$c$}{Speed of light in a vacuum inertial system 
  \nomunit{$299,792,458\, m/s$}}
\nomenclature[A, 03]{$h$}{Plank Constant
  \nomunit{$6.62607 \times 10^{-34}\, Js$}}
\nomenclature[A, 01]{$g$}{Gravitational Constant 
  \nomunit{$6.67384 \times 10^{-11}\, N \cdot m^2/kg^2$}}
\nomenclature[B, 03]{$\mathbb{R}$}{Real Numbers}
\nomenclature[B, 02]{$\mathbb{C}$}{Complex Numbers}
\nomenclature[B, 01]{$\mathbb{H}$}{Quaternions}
\nomenclature[C]{$V$}{Constant Volume}
\nomenclature[C]{$\rho$}{Friction Index}

\printnomenclature

\end{document}

Nomenclatures08.png


Once the macro is defined, one just have to use \nomunit{} to add the corresponding units.

  Open an example of the nomencl package in Overleaf

Further Reading

For more information see:

Overleaf guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX