39

This is a complementary question to About memoir and titlesec incompatibility. The titlesec manual states (p. 2) that the package

[...] works with the standard classes and with many others, including the AMS ones [...] Unfortunately, it is not compatible with memoir[...]

The manual does not mention the KOMA-Script classes. So, can titlesec and KOMA-Script be used together without problems, or are there some incompatibilities (or at least situations where special care must be taken)?

25

I've never used this combination myself, but a search with your favorite engine should show you that there are some incompatibilities, e.g. (all in German):

See this answer of mine for an additional observed incompatibility: Can't shift/position \chapter with titlesec?.

Update in beginning of 2014

With recently published version 3.12 of KOMA-Script one will get a warning when compiling a document with titlesec:

Class scrartcl Warning: Usage of package `titlesec' together
(scrartcl)              with a KOMA-Script class is not recommended.
(scrartcl)              I'd suggest to use the package only
(scrartcl)              if you really need it, because it breaks several
(scrartcl)              KOMA-Script features, i.e., option `headings' and
(scrartcl)              the extended optional argument of the section
(scrartcl)              commands .
  • Months later … a short explanation: When I read lockstep’s question, I could darkly remember that there was some months ago a question in the usenet in de.comp.text.tex with an remarkable answer of Markus Kohm. By searching for that I found the linked questions and answers. – Speravir Mar 16 '12 at 21:02
18

The KOMA-Script classes provide the commands \addpart, \addchap, and \addsec which will start a new unnumbered part/chapter/section that is nevertheless added to the ToC. If you combine KOMA-Script, titlesec, and hyperref, be sure to add a \phantomsection in the after argument of a \section redefined with \titleformat -- otherwise, the ToC links of \addsec will point to the wrong page.

\documentclass{scrartcl}

\usepackage{titlesec}
% Incorrect ToC link to \addsec
% \titleformat{\section}{\Huge\sffamily}{\thesection}{0.5em}{}
% Correct ToC link to \addsec
\titleformat{\section}{\Huge\sffamily}{\thesection}{0.5em}{\phantomsection}

\usepackage{hyperref}

\begin{document}

\tableofcontents

\clearpage

\section{foo}

\clearpage

\addsec{bar}

\end{document}
  • 1
    With an uptodate KOMA-Script version the \phantomsection can be removed from the example. – esdd Oct 26 '18 at 22:59
  • @esdd I have not looked in the code, it might be rather "with an uptodate hyperref". Indeed, I think that at some point \phantomsection became superfluous when using \addcontentsline for section or chapter. I may be wrong. – user4686 Oct 27 '18 at 7:39
2

Currently, titlesec (in version 2.10.1) is fully incompatible with KOMA script. The following minimal example doesn't even compile anymore:

\documentclass{scrartcl}
\usepackage{titlesec}

\begin{document}
  \section{one}
\end{document}

My system shows the following errors:

! Missing number, treated as zero.
<to be read again> 
                   }
l.5   \section{one}

? 
! Illegal unit of measure (pt inserted).
<to be read again> 
                   }
l.5   \section{one}

? 
! Missing number, treated as zero.
<to be read again> 
                   }
l.5   \section{one}

? 
! Illegal unit of measure (pt inserted).
<to be read again> 
                   }
l.5   \section{one}

? 
  • I have the same problem. – peschü May 23 '17 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.