1

I am using the nomencl groups as described in the manual:

\documentclass{article}
\usepackage{nomencl}
\makenomenclature

\RequirePackage{ifthen}
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{R}}{\item[\textbf{Variables}]}{%
\ifthenelse{\equal{#1}{G}}{\item[\textbf{Constants}]}{}}}

\begin{document}
\nomenclature[ga ]{$\alpha$}{Constant}
\nomenclature[rx ]{$x$}{Variable}
\printnomenclature
\end{document}

enter image description here

Now, after I finished my document, I see that if I could print the Variables groups first and the Constants group afterwards it would perfectly align with the pagebreak I have in my nomenclature.

How can I customize the sort order of groups? Note that it is not an option to change the prefix of the groups, as I have more than 100 nomenclature entries in my text, and I would like to avoid going through all of them.

  • How difficult is it to make the global change \nomenclature[rx ] to \nomenclature[bx ] through your document? If it was my document, it would have taken me less time that typing this comment, I guess. – Piet van Oostrum Dec 7 '16 at 9:34
1

You should fix how you input the nomenclature entries.

Here's an example for getting constants before variables:

\documentclass{article}
\usepackage{nomencl}
\makenomenclature

\usepackage{ifthen}

% The order will be 1. constants, 2. variables
% because C comes before V
\renewcommand{\nomgroup}[1]{%
  \ifthenelse{\equal{#1}{V}}{\item[\textbf{Variables}]}{%
  \ifthenelse{\equal{#1}{C}}{\item[\textbf{Constants}]}{}}%
}

\newcommand{\nomconst}[1][]{\nomenclature[C#1]}
\newcommand{\nomvar}[1][]{\nomenclature[V#1]}

\begin{document}
Some text
\nomconst[a]{$\alpha$}{Constant}
\nomvar[x]{$x$}{Variable}
\printnomenclature
\end{document}

enter image description here

With just a few changes in the preamble and none in the document, we can get the reverse order:

\documentclass{article}
\usepackage{nomencl}
\makenomenclature

\usepackage{ifthen}

% The order will be 1. variables, 2. constants
% because A comes before B
\renewcommand{\nomgroup}[1]{%
  \ifthenelse{\equal{#1}{A}}{\item[\textbf{Variables}]}{%
  \ifthenelse{\equal{#1}{B}}{\item[\textbf{Constants}]}{}}%
}

\newcommand{\nomconst}[1][]{\nomenclature[B#1]}
\newcommand{\nomvar}[1][]{\nomenclature[A#1]}

\begin{document}
Some text
\nomconst[a]{$\alpha$}{Constant}
\nomvar[x]{$x$}{Variable}
\printnomenclature
\end{document}

enter image description here

The optional argument to \nomconst and \nomvar are the sorting hints for MakeIndex which you're already using.

  • I ignored the rule "make custom commands for everything" as I started with this project, – Manuel Schmidt Dec 7 '16 at 10:32
  • @ManuelSchmidt It should not be so difficult making a “search and replace” from \nomenclature[g to \nomconst[ and from \nomenclature[r to \nomvar[ – egreg Dec 7 '16 at 10:41

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.