1

I am formatting my nomenclature list at the moment. I matched the style of the rest of the document via this answer and then attempted to flush the units right via this answer. Details are below, thanks in advance.


MWE:


\documentclass{scrreprt}
\usepackage{nomencl}
\usepackage{ifthen}
\usepackage{siunitx}

% No extra line space between items
%\setlength{\nomitemsep}{-\parsep}

% Divide nomenclature into subgroups
\newlength\preGroupSkip
\setlength{\preGroupSkip}{3.5ex}
\newlength\postGroupSkip
\setlength{\postGroupSkip}{2.3ex}
\newcommand\groupHeading[1]{%
    \vspace{\preGroupSkip}%
    \item[\usekomafont{sectioning}\usekomafont{section}#1]%
    \hspace*{\leftmargin}\vspace{\postGroupSkip}%
}
\renewcommand{\nomgroup}[1]{%
    \ifthenelse{\equal{#1}{A}}{%
        \groupHeading{Heading of group A}%
    }{}%
    \ifthenelse{\equal{#1}{B}}{%
        \groupHeading{Heading of group B}%
    }{}%
    \ifthenelse{\equal{#1}{C}}{%
        \groupHeading{Heading of group C}%
    }{}%
}
\newcommand{\nomunit}[1]{%
  \renewcommand{\nomentryend}{\hspace*{\fill}[#1]\nolinebreak\hspace*{2cm}\mbox{}}%
}

\makenomenclature

\begin{document}
% Define nomenclature entries
\nomenclature[a]{$m$}{mass \nomunit{$\si{kg}$}}
\nomenclature[b]{$\omega_{\mathrm{m}}$}{mechanical angular frequency \nomunit{$\si{Hz}$}}
\nomenclature[C]{$\omega_{\mathrm{el}}$}{electrical angular frequency \nomunit{$\si{Hz}$}}

\printnomenclature{}
dummy text
\end{document}

Resulting in: alignment issues

2

Insert \par before \vspace{\preGroupSkip}:

\documentclass{scrreprt}
\usepackage{nomencl}
\usepackage{ifthen}
\usepackage{siunitx}

% No extra line space between items
%\setlength{\nomitemsep}{-\parsep}

% Divide nomenclature into subgroups
\newlength\preGroupSkip
\setlength{\preGroupSkip}{3.5ex}
\newlength\postGroupSkip
\setlength{\postGroupSkip}{2.3ex}
\newcommand\groupHeading[1]{%
    \par% <- added
    \vspace{\preGroupSkip}%
    \item[\usekomafont{sectioning}\usekomafont{section}#1]%
    \hspace*{\leftmargin}\vspace{\postGroupSkip}%
}
\renewcommand{\nomgroup}[1]{%
    \ifthenelse{\equal{#1}{A}}{%
        \groupHeading{Heading of group A}%
    }{}%
    \ifthenelse{\equal{#1}{B}}{%
        \groupHeading{Heading of group B}%
    }{}%
    \ifthenelse{\equal{#1}{C}}{%
        \groupHeading{Heading of group C}%
    }{}%
}
\newcommand{\nomunit}[1]{%
  \renewcommand{\nomentryend}{\hspace*{\fill}[#1]\nolinebreak\hspace*{2cm}\mbox{}}%
}

\makenomenclature

\begin{document}
% Define nomenclature entries
\nomenclature[a]{$m$}{mass \nomunit{$\si{kg}$}}
\nomenclature[b]{$\omega_{\mathrm{m}}$}{mechanical angular frequency \nomunit{$\si{Hz}$}}
\nomenclature[C]{$\omega_{\mathrm{el}}$}{electrical angular frequency \nomunit{$\si{Hz}$}}

\printnomenclature{}
dummy text
\end{document}

enter image description here


Explanation:

Content of the nls file:

\begin{thenomenclature} 
\nomgroup{A}
  \item [{$m$}]\begingroup mass \nomunit{$\si{kg}$}\nomeqref {0.0}\nompageref{1}
\nomgroup{B}
  \item [{$\omega_{\mathrm{m}}$}]\begingroup mechanical angular frequency \nomunit{$\si{Hz}$}\nomeqref {0.0}\nompageref{1}
\nomgroup{C}
  \item [{$\omega_{\mathrm{el}}$}]\begingroup electrical angular frequency \nomunit{$\si{Hz}$}\nomeqref {0.0}\nompageref{1}

\end{thenomenclature}

So the issue can be simulated by the following MWE:

\documentclass{scrreprt}
\usepackage{showframe}
\begin{document}
\begin{enumerate}
  \item an entry \hfill first\label{first}
  \item an entry \hfill foo\label{foo}
  \vspace{10pt}
  \item an entry \hfill bar\label{bar}
\end{enumerate}
\end{document}

enter image description here

\vspace inserts the vertical space after the end of the current line. So there is a spurious space before this \vspace. To remove this spurious space, you can comment the end of the previous line

\documentclass{scrreprt}
\usepackage{showframe}
\begin{document}
\begin{enumerate}
  \item an entry \hfill first\label{first}
  \item an entry \hfill foo\label{foo}% <- removes the spurious space
  \vspace{10pt}
  \item an entry \hfill bar\label{bar}
\end{enumerate}
\end{document}

or you can use \par to finish the previous paragraph:

\documentclass{scrreprt}
\usepackage{showframe}
\begin{document}
\begin{enumerate}
  \item an entry \hfill first\label{first}
  \item an entry \hfill foo\label{foo}
  \par
  \vspace{10pt}
  \item an entry \hfill bar\label{bar}
\end{enumerate}
\end{document}

enter image description here

2
  • Awesome! worked great. Thanks. Care to explain why? – headingofgroupc Feb 14 '20 at 8:21
  • See my updated answer. – esdd Feb 14 '20 at 13:03

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.