12

I just performed a full TL update (--all) (1 hr ago) and noticed that one of my documents which used to compile OK now gives an error.

After trial and error, found the problem shows up when including titlesec with scrbook. But this used to work just fine before the update of the TeX distribution.

MWE

\documentclass[11pt]{scrbook}%
%\documentclass[11pt]{book}%
\usepackage[raggedright]{titlesec}

\errorcontextlines=200

\begin{document}
\mainmatter
\chapter{Introduction, Summary of results and lookup table}
\section{Introduction}

stuff

\end{document}

Now lualatex index.tex gives

>lualatex index.tex
This is LuaTeX, Version 1.10.0 (TeX Live 2019)
 restricted system commands enabled.
(./index.tex
LaTeX2e <2018-12-01>

luaotfload | main : initialization completed in 0.134 seconds
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrbook.cls
Document Class: scrbook 2019/02/01 v3.26b KOMA-Script document class (book)
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrkbase.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrbase.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrlfile.sty)))
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/tocbasic.sty)
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/scrsize11pt.clo)
(/usr/local/texlive/2019/texmf-dist/tex/latex/koma-script/typearea.sty))

Class scrbook Warning: Usage of package `titlesec' together
(scrbook)              with a KOMA-Script class is not recommended.
(scrbook)              I'd suggest to use the package only
(scrbook)              if you really need it, because it breaks several
(scrbook)              KOMA-Script features, i.e., option `headings' and
(scrbook)              the extended optional argument of the section
(scrbook)              commands.
(scrbook)              Nevertheless, using requested
(scrbook)              package `titlesec' on input line 5.

(/usr/local/texlive/2019/texmf-dist/tex/latex/titlesec/titlesec.sty

Package titlesec Warning: Non standard sectioning command \section
(titlesec)                detected. Using default spacing and no format.


Package titlesec Warning: Non standard sectioning command \subsection
(titlesec)                detected. Using default spacing and no format.


Package titlesec Warning: Non standard sectioning command \subsubsection
(titlesec)                detected. Using default spacing and no format.


Package titlesec Warning: Non standard sectioning command \paragraph
(titlesec)                detected. Using default spacing and no format.


Package titlesec Warning: Non standard sectioning command \subparagraph
(titlesec)                detected. Using default spacing and no format.

) (./index.aux)
chapter 1.
! Missing number, treated as zero.
<to be read again>
}
\ttl@select ...@passexplicit \ttl@case \ttl@c {#2}
                                                  {#3}{#4}\fi \endgroup
\ttl@straight@ii ...t \ttl@select {#6}{#1}{#2}{#7}
                                                  \ttl@finmarks \@ifundefine...

l.13 \section{Introduction}

?

If I use the book class, the preceding MWE compiles with no errors.

What changed to make this fail? Can one no longer use titlesec with scrbook?

TL 2019 on Ubuntu (under windows 10 linux subsystem)

5
  • 5
    titlesec and KOMA Script don't really go together. This is what the long warning message tries to tell you. The KOMA Script author has added some compatibility code to his document class to let titlesec do some of its work even with scrbook, but the compatibility code is only executed for titlesec versions before 2016/03/22. If a newer version is detected, the workaround is inactive. You could contact the KOMA Script developer at komascript.de/forum or via email and ask for the fix to be reinstated for newer titlesec versions. ...
    – moewe
    Oct 5, 2019 at 8:06
  • 5
    ... Of course (nowadays) it would be preferable not to load titlesec with KOMA Script classes at all. Instead one should try to mirror the effects with KOMA-Script built-ins. (I appreciate that this might take some work. But it would be more future proof.)
    – moewe
    Oct 5, 2019 at 8:09
  • 2
    @moewe Markus already knows the issue, see komascript.de/release3.26b (German).
    – esdd
    Oct 5, 2019 at 10:41
  • I've taken the liberty of editing the title and body of your posting to remove the somewhat confusing (and even misleading) references to LuaLaTeX. Feel free to revert.
    – Mico
    Oct 5, 2019 at 13:39
  • 1
    You should have not used titlesec with scrbook for many years.
    – egreg
    Oct 5, 2019 at 14:14

1 Answer 1

17

titlesec does not support KOMA-Script classes. So do not combine them. To change the layout of the chapter, section etc. titles you can use KOMA-Script options and \RedeclareSectionCommand & Co and you can redefine \partlineswithprefixformat, \chapterlineswithprefixformat, \chapterlinesformat, \sectionlinesformat and \sectioncatchphraseformat.

Until version 3.26b KOMA-Script has provided a dirty internal hack to make titlesec work with these classes, when the bundle was released. But it has checked the version of titlesec and has disabled the workaround if it was newer. See also https://komascript.de/release3.26b - »Bekannte Probleme« - »scrartcl, scrbook, scrreprt:« (German).

Since KOMA-Script version 3.27 the internal titlesec workaround is removed and there will be no such internal workaround in KOMA-Script version 3.27 or later versions. But 3.27 provides a new hack with the package scrhack that can be enabled using the package option standardsections (not set by default). Then the commands for the sectioning levels are compatible with the standard classes but several KOMA-Script features regarding the sectioning commands are disabled (resulting in warnings).

Example:

\documentclass[
  %11pt% default
]{scrbook}[2019/07/29]% needs prerelease of version 3.27 or newer
\usepackage[standardsections]{scrhack}
\usepackage[raggedright]{titlesec}

\begin{document}
\mainmatter
\chapter{Introduction, Summary of results and lookup table}
\KOMAScriptVersion
\section{Introduction}
stuff
\end{document}

enter image description here


Hack with KOMA-Script version 3.26b or 3.27 (not recommended): If you really want to use titlesec in combination with scrbook, then use \RedeclareSectionCommands for all section levels lower than chapter used in the document but not redefined by \titleformat:

\documentclass[
  %11pt% default
]{scrbook}
\usepackage[raggedright]{titlesec}
\RedeclareSectionCommands{section}

\begin{document}
\mainmatter
\chapter{Introduction, Summary of results and lookup table}
\KOMAScriptVersion
\section{Introduction}
stuff
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .