# Line break in nomencl for nomgroup

I use nomencl for creating the nomenclature of my thesis.
The thesis consists of three chapters and I prefer to have a separate list for each of them.
I currently achieve this with the code in my minimal working example.
Unfortunately, the names of the chapters are quite long. Therefore they do not fit in one line.

How can I have the chapter name continue in the next line?
How can I have it aligned in such a way that the second line does not start from the beginning (below "Chapter ...") but below the name of the chapter after the dash ("A quite long title ...").

\documentclass[a4paper,12pt]{book}
\usepackage[british,ngerman]{babel}
\usepackage{longtable} % longtable lets you have tables that span multiple pages

\usepackage{nomencl}
\makenomenclature
\renewcommand{\nomname}{List of Symbols}
\renewcommand{\nompreamble}{just some symbols}

\usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
\item[\bfseries
\ifstrequal{#1}{A}{Common}{%
\ifstrequal{#1}{B}{Chapter 2 - A quite long title, a quite long title, a quite long title, a quite long title, a quite long title}{%
\ifstrequal{#1}{C}{Chapter 3 - A quite long title, a quite long title, a quite long title, a quite long title, a quite long title}{}}}%
]}

\begin{document}
\tableofcontents
\nomenclature[A,  1]{$\gamma$}{text}
\nomenclature[A,  2]{$B$}{text}
\nomenclature[B,  1]{$\beta$}{text}
\nomenclature[B,  2]{$S$}{text}
\nomenclature[C,  1]{$\alpha$}{text}
\nomenclature[C,  2]{$\beta$}{text}
\printnomenclature[2cm]
\end{document}enter code here


I was able to solve the problem with "parbox":

   \usepackage{etoolbox}
\renewcommand\nomgroup[1]{%
\item[\bfseries
\ifstrequal{#1}{A}{Common}{%
\ifstrequal{#1}{B}{{\parbox[t]{16cm}{Chapter 2 - A quite long title, a quite long title, a quite long title, a quite long title, a quite long title}}}{%
\ifstrequal{#1}{C}{{\parbox[t]{16cm}{Chapter 3 - A quite long title, a quite long title, a quite long title, a quite long title, a quite long title}}}{}}}%
]}


Your idea of \parbox is good, but I suggest several improvements, first of all to avoid guessing the width.

\documentclass[a4paper,12pt]{book}
\usepackage[british,ngerman]{babel}

\usepackage{nomencl}
\usepackage{xparse}

\makenomenclature
\renewcommand{\nomname}{List of Symbols}
\renewcommand{\nompreamble}{just some symbols}

\newcommand{\nomA}{Common}
\newcommand{\nomB}{%
\parbox[t]{\textwidth}{%
Chapter 2 - A quite long title, a quite long title, a quite long title,
a quite long title, a quite long title%
}\kern-\labelsep
}
\newcommand{\nomC}{%
\parbox[t]{\textwidth}{%
Chapter 3 - A quite long title, a quite long title, a quite long title,
a quite long title, a quite long title%
}\kern-\labelsep
}
% this is easier than a long list of nested \ifstrequal calls and more easily scalable
\ExplSyntaxOn
\NewDocumentCommand{\nomgroupmake}{m}
{
\str_case:nnF { #1 }
{
{A}{\nomA}
{B}{\nomB}
{C}{\nomC}
}
{\ERROR}
}
\ExplSyntaxOff

\renewcommand\nomgroup[1]{\item[\bfseries\nomgroupmake{#1}]}

\begin{document}

Some text to make the nomenclature appear
\nomenclature[A,1]{$\gamma$}{text}
\nomenclature[A,2]{$B$}{text}
\nomenclature[B,1]{$\beta$}{text}
\nomenclature[B,2]{$S$}{text}
\nomenclature[C,1]{$\alpha$}{text}
\nomenclature[C,2]{$\beta$}{text}

\printnomenclature[2cm]

\end{document}


• Thanks for your solution! I implemented it. However, the spacing between "Common" and the gamma entry in the list seems to be slightly larger than the spacing between the other two headers and their first entry doesn' it? It is just a minor thing but do you know why? Aug 21, 2019 at 17:15
• @green Maybe you could remove the [2cm] from the \printnomenclature command?
– Jan
Jun 13, 2021 at 15:19
• @Jan That specifies the width of the left column (the symbols), IIRC Jun 13, 2021 at 15:33