4

I have a weird problem with siunitx and redefining section. Here is a screenshot of the problem:

enter image description here

As you can see, an asterisk appears in the ToC, aswell as the \section* command not working properly. The heading will be a star, and the actual heading goes into the text. It seems like the \section* command interprets the asterisk as the heading, and ignores the rest. So the asterisk in the ToC is more of a symptom...

Here is a MWE (rather MNWE):

main.tex

\documentclass{styles/diplclass1} 
\begin{document}

\tableofcontents
\section*{Starheading}
asdf

\section{Normal heading}
\end{document}

styles/diplclass1.cls

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{styles/diplclass1}
\LoadClass[a4paper,11pt,titlepage,oneside]{scrbook}

\usepackage{siunitx}

\renewcommand{\section}{%
  \@startsection{section}%
  {1}
  {0mm}
  {2ex plus 1ex minus 1ex}
  {0.5ex plus 0.5ex minus 0.5ex}
  {\Large\bfseries}
}

Please note: I need to redefine sections, because I apply some styles there. Also, I need to use siunitx. I have not found anything when searching for this problem, except some issues with bibliography which seem to be related, as well as the fact, that redefining \section is okay for \section*, because \@startsection takes care of the asterisk version.

As soon as I remove the siunitx import, or the section redefinition, it works as expected. How can I redefine the section style, and use siunitx aswell? Does anyone have an idea why this problem occurs?

CharlyDelta
  • 143
  • 6

1 Answers1

7

Don't use \@startsection in the KOMA-classes, the definition of the sectioning commands in KOMA are different. Use the tools offered by the class:

\documentclass{scrbook}

\usepackage{siunitx}

\RedeclareSectionCommand[
  beforeskip=2ex plus 1ex minus 1ex,
  afterskip=0.5ex plus 0.5ex minus 0.5ex,
  font=\Large\bfseries]{section}

\begin{document}

\tableofcontents
\section*{Starheading}
asdf

\section{Normal heading}
\end{document}

enter image description here

Addition:

Normally KOMA would warn you when you do such a redefinition and fallback to another redefition. But through siunitx you are loading the amsgen package which redefines \@ifstar and now the test of KOMA fails.

Ulrike Fischer
  • 327,261
  • Thanks for your answer, I didn't know about that. But when I replace my previous renewcommand with the KOMA RedeclareSectionCommand, I get the error: Undefined control sequence: \RedeclareSectonCommand. I guess it means, that my srcbook package is outdated, doesn't it? – CharlyDelta Apr 11 '16 at 07:54
  • @ChristianDreher: Yes. – Ulrike Fischer Apr 11 '16 at 07:57
  • After updating koma-script it worked like a charm. Thank you very much for your qualified help :)) – CharlyDelta Apr 11 '16 at 08:36