[Tex/LaTex] Reduce line spacing in nomenclature

line-spacingnomenclature

I am creating a nomenclature and would like to reduce line spacing. If I use the approach found online inserting the \setlength{\nomitemstep}{-parsep} command, all line skips are removed including the ones before and after the sub-section headings of the nomenclature.
Is there a way of reducing the line space only for the individual items, however not for the headers?

Attached is an example code and a snapshot of the output:

\documentclass[authoryear, preprint]{elsarticle} 

\usepackage{nomencl}
\makenomenclature
\renewcommand{\nomgroup}[1]{%
    \ifthenelse{\equal{#1}{A}}{\item[\textbf{Greek Symbols}]}{%
    \ifthenelse{\equal{#1}{B}}{\item[\textbf{Other Variables}]}{}}} 
\setlength{\nomitemsep}{-\parsep}
\RequirePackage{ifthen}

\begin{document}
This is my text document.
\nomenclature[a]{$\sigma$}{Variable explanation}
\nomenclature[a]{$\alpha$}{Variable explanation}
\nomenclature[a]{$\beta$}{Variable explanation}
\nomenclature[b]{$A$}{Variable explanation}
\nomenclature[b]{$B$}{Variable explanation}
\nomenclature[b]{$C$}{Variable explanation}
\nomenclature[b]{$D$}{Variable explanation}
\printnomenclature[0.9in]
\end{document}

Thanks a lot for any hints!

Christian
enter image description here

Best Answer

Here's a small bypass solution: Restore the \noitemsep value temporarily in a \nomgroup and use the newer value afterwards.

\documentclass[authoryear, preprint]{elsarticle} 
\usepackage{ifthen}

\usepackage{nomencl}
\usepackage{xpatch}



\newlength{\nomitemorigsep}
\setlength{\nomitemorigsep}{\nomitemsep}
\setlength{\nomitemsep}{-\parsep}


\makenomenclature
\renewcommand{\nomgroup}[1]{%
  \itemsep\nomitemorigsep%
  \ifthenelse{%
    \equal{#1}{A}%
  }{%
  \item[\textbf{Greek Symbols}]%

  }{%
    \ifthenelse{\equal{#1}{B}}{%
    \item[\textbf{Other Variables}]%

    }{}%
  }%
  \itemsep\nomitemsep% Restore spacing
} 


\begin{document}
This is my text document.
\nomenclature[a]{$\sigma$}{Variable explanation}
\nomenclature[a]{$\alpha$}{Variable explanation}
\nomenclature[a]{$\beta$}{Variable explanation}
\nomenclature[b]{$A$}{Variable explanation}
\nomenclature[b]{$B$}{Variable explanation}
\nomenclature[b]{$C$}{Variable explanation}
\nomenclature[b]{$D$}{Variable explanation}
\printnomenclature[0.9in]
\end{document}