# Unique \nomlabelwidth for each \nomgroup with nomencl package

in my thesis I use the nomencl package with different groups. Since a few entries in one group are fairly long, I'd like to specifically increase the \nomlabelwidth in this \nomgroup. Globally increasing the \nomlabelwidth would result in a lot of unnecessary white space in all other groups which I'd like to avoid.

Is is possible to \setlength{\nomlabelwidth}{<value>} within a group and not just globally?

Here is a MWE

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

\setlength{\nomlabelwidth}{3em}

\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{D}}{\item[\textbf{General notation}]}{%
\ifthenelse{\equal{#1}{A}}{\item[\textbf{Acronyms}]}{}}
}

\begin{document}
Test nomenclature.
\nomenclature[D]{$\{\boldmath{e}_z,\boldmath{e}_y,\boldmath{e}_z\}$ or $\{\boldmath{e}_1,\boldmath{e}_2,\boldmath{e}_3\}$}{a long entry}
\nomenclature[D]{$\{\boldmath{E}\}$}{a short entry}

\printnomenclature

\end{document}

To get the required output you can start a new list within your \nomgroup command and set the relevant dimensions there, among which \labelwidth that controls the label width. Other relevant dimensions are \leftmargin and \itemsep. The left margin is the new label width minus the old label width. This code is largely taken from the source of the nomencl package, specifically the part where the nomenclature environment is defined (around line 250 in nomencl.sty).

Furthermore you should reverse the extra space that the new list generates using a negative \vspace. All in all it is a bit messy but it seems to work :)

MWE:

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

\setlength{\nomlabelwidth}{3em}
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{D}}{%
\endlist%
\list{}{%
\labelwidth15em
\leftmargin12em
\itemsep\nomitemsep
\let\makelabel\nomlabel}%
\vspace{-1.5em}%
\item[\textbf{General notation}]}{%
\ifthenelse{\equal{#1}{A}}{\item[\textbf{Acronyms}]}{}}
}

\begin{document}
Test nomenclature.
\nomenclature[D]{$\{\mathbf{e}_z,\mathbf{e}_y,\mathbf{e}_z\}$ or $\{\mathbf{e}_1,\mathbf{e}_2,\mathbf{e}_3\}$}{a long entry}
\nomenclature[D]{$\{\mathbf{E}\}$}{a short entry}