I am editing a package (which I did not write myself) where the titlesec package was used in combination with the scrbook document class. This produces an error, as explained in this post: Conflict between titlesec package and scrbook class after most recent update of TeXLive2019. I wish to fix this error, and get rid of the error message. I realize one must use the commands in the KOMA-class, but I don't know exactly how. Here is a minimal exaple:
Package:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mypackage}
\RequirePackage[T1]{fontenc}
\RequirePackage[explicit]{titlesec}
\titleformat{\section}
{\normalfont}{\thesection}{0pt}{\phantomsection\fontsize{18pt}{20pt} \sffamily\center\MakeUppercase{#1}}
\titleformat{\subsection}
{\normalfont}{\thesubsection}{0pt}{\fontsize{14pt}{16pt} \sffamily\center\MakeUppercase{#1}}
\titleformat{\subsubsection}
{\normalfont}{\thesubsubsection}{0pt}{\scshape{\textbf{\normalsize #1}}}
% {left}{top}{below}{right}
\titlespacing*{\section}{0pt}{0pt minus 0.5em}{0pt}
\titlespacing*{\subsection}{0pt}{-2em plus 0.3em minus 0.3em}{-0.4em plus 0.2em minus 0.2em}
\titlespacing*{\subsubsection}{0pt}{-0.5em plus 0.2em}{-0.8em plus 0.5em minus 0em}
\setcounter{secnumdepth}{0}
The document:
\documentclass[fontsize=13pt,a4paper,openany,parskip=half,DIV=calc]{scrbook}
\usepackage{mypackage}
\begin{document}
\section{Section}
Some text.
\subsection{Subsection}
More text.
\subsubsection{Subsubsection}
Text.
\end{document}
So the challenge is redefining the commands section, subsection and subsubsection as intended by the author of this class without using the titlesec package.


\RedeclareSectionCommand? – Vebjorn Apr 22 '22 at 16:39\usepackage{xparse}. – egreg Apr 22 '22 at 16:42\input, it can't make a difference. You've still to tell what errors you get. – egreg Apr 24 '22 at 07:58\RedeclareSectionCommandis not defined. – Vebjorn Apr 24 '22 at 20:28\documentclass{scrbook}the command\RedeclareSectionCommandmust be known, because it is provided by the class.\RedeclareSectionCommandwas introduced inscrbooka long time ago. – esdd Apr 25 '22 at 11:22