# Mimicking the style of a KOMA script section heading inside a nomenclature

I have a document using the scrreprt class which contains a nomenclature. The nomenclature uses subgroups with headings. I'd like to format the headings like the section headings of the document, i.e. font family and size should be the same. Ideally, the vertical space between a subgroup, the subgroup heading and the next subgroup is also the same as between a paragraph, a section heading and the next paragraph.

This MWE shows what I have achieved so far

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

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

% Divide nomenclature into subgroups
\newlength\preGroupSkip
\setlength{\preGroupSkip}{\baselineskip}
\newlength\postGroupSkip
\setlength{\postGroupSkip}{2ex}
\newcommand\groupHeading[1]{%
\vspace{\preGroupSkip}%
\item[\hspace*{\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}%
}{}%
}
\makenomenclature

\begin{document}
% Define nomenclature entries
\nomenclature[a]{$\alpha$}{Some angle}
\nomenclature[b]{$b$}{Some variable}
\nomenclature[c]{$\mathbf c$}{Some vector}

\printnomenclature{}
dummy text
\end{document}


This is the result (green line by me):

It comes close to what I'd like to achieve except for the alignment of the subgroup headings which should align with the green line, of course. If I just use normal formatting, without \usekomafont{}, the misalignment does not occur. So it must have to do with that. Only I couldn't figure out what the relationship is. How can the subgroup headings be aligned correctly?

Additionally, how should I choose \preGroupSkip and \postGroupSkip, so that they correspond to the vertical space between a paragraph and its heading, and between a paragraph and the heading of the next paragraph, respectively?

## 1 Answer

Remove the space between \usekomafont{section} and #1:

\item[\usekomafont{sectioning}\usekomafont{section}#1]%


Code:

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

% 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\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}%
}{}%
}
\makenomenclature

\begin{document}
% Define nomenclature entries
\nomenclature[a]{$\alpha$}{Some angle}
\nomenclature[b]{$b$}{Some variable}
\nomenclature[c]{$\mathbf c$}{Some vector}

\printnomenclature{}
dummy text
\end{document}

• That was easy, thank you! Feeling dumb right now ;) Could you comment on the choice of \setlength{\preGroupSkip}{3.5ex} and \setlength{\postGroupSkip}{2.3ex}? Is there a special reason for the values you chose?
– Deve
Dec 8 '15 at 19:01
• In table 21.6 of the KOMA-Script documentation (scrguien.pdf) you can find the defaults of the headings of scrbook and scrreprt. \section uses afterskip= 2.3ex plus .2ex and beforeskip=-3.5ex plus -1ex minus -.2ex. Note that the absolute value of beforeskip is used to set the length of the vertical skip before the section heading. The minus only suppresses the indentation of the first paragraph after the heading.
– esdd
Dec 8 '15 at 19:16