[Tex/LaTex] Make nomenclature sort math correctly

nomenclaturesorting

I am sorting my nomenclature as suggested by the nomencl package documentation, but \dot{q} is being sorted before a and v, where as the desired sort is:

  • a
  • \dot{q}
  • v

The existence of a default prefix does not help, so noprefix is used. Prefixes are used to separate Roman [1] from Greek [2] variables.

\documentclass[oneside,paper=a4,fontsize=12pt,english]{scrreprt}
\usepackage[noprefix]{nomencl}
\makenomenclature
\begin{document}
\printnomenclature
\nomenclature[1]{\(a\)}{Semimajor axis}
\nomenclature[1]{\(v\)}{Velocity}
\nomenclature[1]{\(\dot{q}\)}{Heat flux}
\nomenclature[2]{\(\rho\)}{Density}
% makeindex.exe Test.nlo -s nomencl.ist -o Test.nls
Lorem ipsum.
\end{document}

Using [1q] as a prefix causes \dot{q} to be sorted at the end of the Roman variables. How can I get nomenclature to ignore \dot{}?

Best Answer

Just add to all the entries that have math an ASCII version for sorting:

% arara: pdflatex
% arara: nomencl
% arara: pdflatex

\documentclass[oneside,paper=a4,fontsize=12pt,english]{scrreprt}
\usepackage[noprefix]{nomencl}
\makenomenclature

\begin{document}

\printnomenclature
\nomenclature[1a]{\(a\)}{Semimajor axis}
\nomenclature[1v]{\(v\)}{Velocity}
\nomenclature[1q]{\(\dot{q}\)}{Heat flux}
\nomenclature[2rho]{\(\rho\)}{Density}

Lorem ipsum.
\end{document}

enter image description here

With arara you don't need to remember the command for producing the .nls file. :)