4

I am trying to use the nomencl package (CTAN link) in my document and would like to format the nomenclature entries in a table, as described in the documentation (option nomentbl).

This works fine, unless I also try to customise the subgroups as described in the documentation (via \renewcommand{\nomgroup}...). The attached MWE returns the following error in the output

./mwe.nls:7: Missing number, treated as zero.

and the headers in the PDF are all messed up (see below).

Can someone please shed light on this? Did I miss anything obvious? Any advice would be highly appreciated!

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage[per-mode=fraction]{siunitx}
\usepackage[nomentbl]{nomencl}
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{S}}{\item[\textbf{Sets}]}{%
\ifthenelse{\equal{#1}{C}}{\item[\textbf{Constants}]}{%
\ifthenelse{\equal{#1}{V}}{\item[\textbf{Variables}]}{}}}}
\makenomenclature
\begin{document}
\printnomenclature
\clearpage
The objective function minimizes total energy cost in the period under consideration.
\begin{equation}
  \label{eq:obj}
  \min_x \sum_m\sum_t C_t \cdot q_m^{p,s} \cdot r_m^{p,s} \cdot x_{m,t}^{p,s}
\end{equation}
\nomenclature[c C]{$C_t$}{Electricity price in period $t$}{}{}
\nomenclature[c q]{$q_m^{p,s}$}{Output-specific power uptake of machine $m$ when producing paper $p$ in production mode $s$}{}{}
\nomenclature[c r]{$r_m^{p,s}$}{Production rate of machine $m$ for paper $p$ when run in mode $s$}{}{}
\nomenclature[s t]{$\mathcal{T}$}{Set of points in time}{}{}
\nomenclature[s p]{$\mathcal{P}$}{Set of paper types}{}{}
\nomenclature[s m]{$\mathcal{M}$}{Set of machines}{}{}
\nomenclature[v x]{$x_{m,t}^{p,s}$}{Binary variable that equals 1 if machine $m$ produces paper $p$ in production mode $s$ in period $t$, otherwise 0}{}{}
\end{document}

Messed up nomenclature in pdf document

1

\nomgroup is not really well supported with the nomentbl option. Surely one cannot use \ifthenelse for supporting it, because we need to issue a \multicolumn command.

A workaround is to use \pdf@strcmp that does string comparison expandably.

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage[per-mode=fraction]{siunitx}
\usepackage[nomentbl]{nomencl}
\usepackage{pdftexcmds}

\makenomenclature

\makeatletter
\renewcommand{\nomgroup}[1]{%
  \ifnum\pdf@strcmp{#1}{C}=\z@
    \multicolumn{6}{l}{\textbf{Constants}}\\%
  \else
    \ifnum\pdf@strcmp{#1}{S}=\z@
      \\\\\multicolumn{6}{l}{\textbf{Sets}}%
    \else
      \ifnum\pdf@strcmp{#1}{V}=\z@
        \\\\\multicolumn{6}{l}{\textbf{Variables}}%
      \fi
    \fi
  \fi
}
\makeatother

\begin{document}

\printnomenclature
\clearpage

The objective function minimizes total energy cost in the period under consideration.
\begin{equation}
  \label{eq:obj}
  \min_x \sum_m\sum_t C_t \cdot q_m^{p,s} \cdot r_m^{p,s} \cdot x_{m,t}^{p,s}
\end{equation}
\nomenclature[c C]{$C_t$}{Electricity price in period $t$}{}{}
\nomenclature[c q]{$q_m^{p,s}$}{Output-specific power uptake of machine $m$ when producing paper $p$ in production mode $s$}{}{}
\nomenclature[c r]{$r_m^{p,s}$}{Production rate of machine $m$ for paper $p$ when run in mode $s$}{}{}
\nomenclature[s t]{$\mathcal{T}$}{Set of points in time}{}{}
\nomenclature[s p]{$\mathcal{P}$}{Set of paper types}{}{}
\nomenclature[s m]{$\mathcal{M}$}{Set of machines}{}{}
\nomenclature[v x]{$x_{m,t}^{p,s}$}{Binary variable that equals 1 if machine $m$ produces paper $p$ in production mode $s$ in period $t$, otherwise 0}{}{}
\end{document}

enter image description here

The top group has to be treated differently.

2
  • Thank you, this is exactly what I was looking for! I do have one question though: When I copied your solution, I forgot to include \usepackage{pdftexcmds} in my preamble and the document still compiles fine. Is it possible that string comparison is already part of the nomencl package? – Hermann von Westerholt Jul 11 '19 at 8:59
  • 1
    @Hermann One of the packages you have loads pdftexcmds itself. None of the packages in the example code does; I'd leave the dependency nonetheless. – egreg Jul 11 '19 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.