30

The title is pretty much I want to ask. More detail, the nomenclature entries should be sorted in groups like:

 Nomenclature

   Acronyms
    Symbol  Description     % no Dimensions and Units 
    ...

   Greek Symbols
    Symbol  Description             Dimensions     Units
    ...

   Roman Symbols
    Symbol  Description             Dimensions     Units
    S       Surface area vector     L^2            m^2
    ...
   Superscripts
    Symbol  Description     % no Dimensions and Units 
    ...
   Dimensionless Numbers
    Symbol  Description     Definition
    ...

e.g. expected entries like this:

enter image description here enter image description here enter image description here enter image description here

My current nomenclature settings for grouping [book class]:

%----------------------------------------------------------
%                        Nomenclature
%----------------------------------------------------------
%\renewcommand{\nomname}{List of Symbols and Abbrev.}
\renewcommand\nomgroup[1]{%
  \ifthenelse{\equal{#1}{A}}{%
   \item[\textbf{Acronyms}] }{%                  A - Acronyms
    \ifthenelse{\equal{#1}{R}}{%
     \item[\textbf{Roman Symbols}]}{%            R - Roman
      \ifthenelse{\equal{#1}{G}}{%
        \item[\textbf{•} Symbols }]}{%          G - Greek
          \ifthenelse{\equal{#1}{S}}{%
           \item[\textbf{Superscripts  }]}{{%          S - Superscripts
        \ifthenelse{\equal{#1}{U}}{%
         \item[\textbf{Subscripts }]}{{%                 U - Subscripts
        \ifthenelse{\equal{#1}{X}}{%
         \item[\textbf{Other Symbols }]}%            X - Other Symbols
                    {{}}}}}}}}}}
%\ifpdf
\renewcommand{\nomlabel}[1]{\hspace{1 em}#1}%{\hspace{1.5 em}#1}
\renewcommand*{\nompreamble}{\markboth{\nomname}{\nomname}}

But how to extend it with Dimensions and Units?

KOF
  • 5,019

1 Answers1

29

The documentation of the nomenclature package includes code to put everything in a longtable environment, but this involves some hacking of the .ist file. A simpler approach that may be sufficient is just to define some helper macros that work within in an ordinary list:

Sample output

\documentclass{article}

\usepackage{nomencl,etoolbox,ragged2e,siunitx}

\newcommand{\DimensUnits}[2]{\hfill\makebox[8em]{#1\hfill}%
\makebox[4em]{#2\hfill}\ignorespaces}
\newcommand{\insertnomheaders}{\item[\bfseries Symbol]%
\textbf{Description}\DimensUnits{\textbf{Dimensions}}{\textbf{Units}}}

\renewcommand\nomgroup[1]{%
  \item[\large\bfseries
  \ifstrequal{#1}{A}{Acronyms}{%
  \ifstrequal{#1}{R}{Roman Symbols}{%
  \ifstrequal{#1}{G}{Greek Symbols}{%
  \ifstrequal{#1}{S}{Superscripts}{% 
  \ifstrequal{#1}{U}{Subscripts}{%   
  \ifstrequal{#1}{X}{Other Symbols}{}}}}}}]
  \insertnomheaders
  }

\renewcommand*{\nompreamble}{\markboth{\nomname}{\nomname}}

\newcommand{\nomdescr}[1]{\parbox[t]{4cm}{\RaggedRight #1}}
\newcommand{\nomwithdim}[5]{\nomenclature[#1]{#2}%
{\nomdescr{#3}\DimensUnits{#4}{#5}}}

\makenomenclature

\begin{document}
\mbox{}
\nomwithdim{R}{\(a,b,c\)}{half axes of ellipsoid}{L}{\si{m}}
\nomwithdim{R}{\(C\)}{dimensionless coefficient (e.g.\ for drag model)}{--}{1}
\nomwithdim{G}{\( \varepsilon_0 \)}{vacuum permittivity}{F/L}{\si{F.m^{-1}}}

\printnomenclature[6em]
\end{document}

The optional argument to \printnomenclature sets the space available for the symbols. We then set each line as an \item whose label is the symbol, followed by a paragraph of fixed width containing the description, followed by a box for dimensions and finally a box for units. etoolbox has been loaded to avoid the deprecated ifthen package. sunitx has been loaded for printing the units.

Of course, to compile this you need to run the file through (pdf)latex, then run

makeindex file.nlo -s nomencl.ist -o file.nls

with "file" replaced (both times) by your jobname, i.e. where the main file is file.tex. You then need to run (pdf)latex again.

ADDED in response to comment Here is a version with different styling for different categories. UPDATED again Now with optional arguments to pass to the sorting keys.

Sample output

\documentclass{article}

\usepackage{nomencl,etoolbox,ragged2e,siunitx,mathtools}

\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}

\newcommand{\DimensUnits}[2]{\hfill\makebox[8em]{#1\hfill}%
\makebox[4em]{#2\hfill}\ignorespaces}
\newcommand{\DefinitionCol}[1]{\hfill\parbox[t]{12em}{#1}\ignorespaces}

\newcommand{\nomsubtitle}[1]{\item[\large\bfseries #1]}

\renewcommand\nomgroup[1]{\def\nomtemp{\csname nomstart#1\endcsname}\nomtemp}

\newcommand{\nomstartR}{\nomsubtitle{Roman Symbols}%
  \item[\bfseries Symbol]%
  \textbf{Description}\DimensUnits{\textbf{Dimensions}}{\textbf{Units}}}
\newcommand{\nomstartG}{\nomsubtitle{Greek Symbols}%
  \item[\bfseries Symbol]%
  \textbf{Description}\DimensUnits{\textbf{Dimensions}}{\textbf{Units}}}
\newcommand{\nomstartD}{\nomsubtitle{Dimensionless Numbers}%
  \item[\bfseries Symbol]\textbf{Description}\DefinitionCol{\textbf{Definition}}}

\renewcommand*{\nompreamble}{\markboth{\nomname}{\nomname}}

\newcommand{\nomdescr}[1]{\parbox[t]{4cm}{\RaggedRight #1}}
\newcommand{\nomwithdim}[5]{\nomenclature[#1]{#2}%
{\nomdescr{#3}\DimensUnits{#4}{#5}}}
\newcommand{\nomtypeR}[5][]{\nomwithdim{R#1}{#2}{#3}{#4}{#5}}
\newcommand{\nomtypeG}[5][]{\nomwithdim{G#1}{#2}{#3}{#4}{#5}}
\newcommand{\nomtypeD}[4][]{\nomenclature[D#1]{#2}{\nomdescr{#3}\DefinitionCol{#4}}}
\makenomenclature

\begin{document}
\mbox{}
\nomtypeR[abc]{\(a,b,c\)}{half axes of ellipsoid}{L}{\si{m}}
\nomtypeR[C]{\(C\)}{dimensionless coefficient (e.g.\ for drag model)}{--}{1}
\nomtypeG{\( \varepsilon_0 \)}{vacuum permittivity}{F/L}{\si{F.m^{-1}}}
\nomtypeD{\( \mathcal A_r \)}{Archimedes number}{\(\displaystyle
\frac{d^3g\rho_c\abs{\Delta\rho}}{\mu_c^2} = \sqrt{\frac{\mathcal
E_0^3}{\mathcal M_0}} \)}
\nomtypeR[CC]{\(\mathbf{C}\)}{another dimensionless coefficient}{--}{1}
\nomtypeR[A]{\(A\)}{a dimensionless coefficient}{--}{1}
\nomtypeR[Z]{\(Z\)}{a dimensionless coefficient}{--}{1}

\printnomenclature[6em]
\end{document}
Andrew Swann
  • 95,762
  • It works fine! Btw, I have updated my post: how to make different groups with different style? – KOF May 07 '13 at 13:43
  • That is not too hard a modification: (1) create a custom command for each style with the formatting and (2) change the \nomgroup code to write an appropriate \item[] followed by an appropriate header command. – Andrew Swann May 07 '13 at 13:48
  • Such a solution now added above. – Andrew Swann May 07 '13 at 14:21
  • Now it works nearly perfectly. Only remaining issue is that the order of symbols: e.g. {$S$}, {\textbf{S}}, {\(S\)}, {S} will be sorted differently. Is there a way sorting the symbols alphabetically? – KOF May 08 '13 at 00:00
  • Now added via optional arguments to specify sorting key. – Andrew Swann May 08 '13 at 08:30
  • Great, what is the parameter to control the length of Description column? – KOF May 08 '13 at 12:16
  • 1
    It is the 4cm in \nomdescr – Andrew Swann May 08 '13 at 12:17
  • I tried add some spacing before and after each Group's name, because if the last entry has two or more lines, the spacing is too narrow. \ or \vspace(1em) seems not working – KOF May 08 '13 at 12:30
  • \newcommand{\nomsubtitle}[1]{\vspace{7ex plus 2ex minus 1ex}% \item[\large\bfseries #1]\mbox{}\vspace{5ex plus 1ex minus 0.5ex}} will work. – Andrew Swann May 08 '13 at 19:18
  • If the list of symbols is large and extends on to the next page, I would want the column headings (Symbol, Description, Dimension, etc) to appear on the next page as well. How to ensure that such thing happens? – TRK Apr 07 '15 at 18:19
  • @Tarun Sounds like a new question... – Andrew Swann Apr 08 '15 at 12:20
  • @AndrewSwann: I have been looking forward to get an answer to this question for a long time. I don't know how things appeared for others, but for me headings didn't appear in the next page. I have already posted a question for that and liked with this question. http://tex.stackexchange.com/questions/197248/for-a-group-of-symbols-how-to-get-column-headingsdescription-in-the-next-page – TRK Apr 08 '15 at 14:26
  • both of the codes led to an empty page for me. any reasons why – Amarjit Dhillon May 14 '18 at 08:25
  • @AmarjitSingh Did you run makeindex - I have added instructions to the answer. If that doesn't work then post a question giving details. – Andrew Swann May 14 '18 at 14:35