[Tex/LaTex] KOMA-Script throws “! Extra \else” error

errorskoma-script

With a minimal document such as

\documentclass{scrartcl}
\pagestyle{headings}
\begin{document}
\section{Introduction}
\end{document}

I am getting the following error with latex filename.tex

! Extra \else.
\@sect ...sname }{\scr@ds@tocentry }\fi \fi \else 
                                              \def \@svsechd {#6{\hskip ...
l.49 \section{Introduction}

Can anyone help pinpoint where the problem might be?

  • If I change the document class to be article, it works fine
  • If I remove the \pagestyle{headings}, it works fine
  • If I change headings to empty, it works fine

Versions:

pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013/Arch Linux)
kpathsea version 6.1.1
...
Compiled with libpng 1.6.10; using libpng 1.6.10
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with poppler version 0.24.5

and KOMA-Script (scrartcl.cls)

%%% From File: $Id: scrkernel-version.dtx 1560 2013-12-19 07:13:30Z mjk $

Best Answer

Just as addition to Gonzalo’s answer. You’ve run into a known bug of KOMA-Script version 3.12.

Cf. (alas only in German) Bekannte Probleme und Änderungen in KOMA-Script 3.12:

scrartcl:
[…]
Wenn man den Seitenstil headings aktiviert, wird man mit Fehlern wegen eines \fi zu viel
bombadiert.
Workaround: Paket scrlayer-scrpage (oder notfalls scrpage2) laden und Seitenstil
scrheadings verwenden.
Hinweis: Der Fehler ist in der experimentellen Release behoben.

It means that the error you observed is removed in an experimental version you can download from a page, which is linked behind the words “experimentellen Release”, but is again in German. Fortunately Markus Kohm created for this page an English companion: Using most current KOMA-Script with TeX Live, MacTeX or MiKTeX.

Without using this experimental version you should load the (KOMA-Script) package scrlayer-scrpage and use the pagestyle scrheadings, similar like Gonzalo suggested. (In my eyes with version 3.12 there is no need anymore for using package scrpage2, because scrlayer-scrpage is downwards compatible, as long as you never have used internal commands of scrpage2.)

Related Question