[Tex/LaTex] Ways to modify chapter titles in KOMA-class

chapterskoma-scriptsectioning

I am using KOMA-class. Let's say I want my chapter titles to look like this:

enter image description here

However the closest thing I can get is this:

enter image description here

The code I used is this:

\documentclass{scrbook}

\usepackage{kantlipsum} %providing dummy text
\usepackage{adforn} %providing ornaments

\RedeclareSectionCommand[style=section,indent=0pt,beforeskip=2\baselineskip]{chapter}
\setkomafont{chapter}{\normalfont\large\scshape}
\renewcommand*{\raggedsection}{\centering}
\renewcommand*{\chapterformat}{\adforn{36}\enskip\thechapter.\ }

\begin{document}

    \kant[1]

    \chapter{An Interesting Chapter Title}

    \kant[2]

    \begin{center}
        \vspace{\baselineskip}
        \scshape\large \adforn{36}\enskip 1. An Interesting Chapter Title\enskip\adforn{36}
        \\
        \rule{2em}{1pt}
    \end{center}

    \noindent\kant[3]


\end{document}

Things I already modified:

  1. The font for the chapter title.
  2. Centering.
  3. Not starting a new page.
  4. Vertical space before the title.

But I don't know how to add characters or even a new line after the actual chapter title is printed.

I would also like to know about further ways than those I already used, KOMA-classes provide to change chapter titles (whether it makes sense to use them is another thing).

Edit: As schtandard remarked, one has to make a decision how the title should look when it takes several lines. So let's see for example if we can get the following to work:

enter image description here

My code (which is certainly terrible):

    \begin{center}
        \vspace{\baselineskip}
        \scshape\large
        \adforn{36}\hspace{-1em}
        \parbox{11cm}{\centering 1. An Interesting Chapter Title Which is Way Too Long to Fit in One Line}
        \hspace{-1em}\adforn{36}
        \\[\baselineskip]
        \rule{2em}{1pt}
    \end{center}

Note that here the box has a fixed length of 11cm which is fine for taking the picture, but in practice, one should be able to specify a maximal width so that the box becomes shorter if the title is short.

Best Answer

If you use style=section for chapters then you have to redefine \sectionlinesformat to change the layout for chapter titles:

\documentclass{scrbook}
\usepackage{kantlipsum} %providing dummy text
\usepackage{adforn} %providing ornaments

\RedeclareSectionCommand[style=section,indent=0pt,beforeskip=-2\baselineskip]{chapter}
\setkomafont{chapter}{\normalfont\large\scshape}
\renewcommand*{\raggedchapter}{\centering}

\usepackage{varwidth}
\makeatletter
\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{chapter}
    {%
      \raggedchapter
      \adforn{36}\enskip
      \begin{varwidth}{\dimexpr\textwidth-6em\relax}
        \raggedchapter#3#4%
      \end{varwidth}%
      \enskip\adforn{36}%
      \par\nobreak
      \strut\rule{2em}{1pt}%
      \par
    }
    {\@hangfrom{\hskip#2#3}{#4}}% original definition for other section levels
}
\makeatother

\begin{document}
\kant[1]
\chapter{An Interesting Chapter Title}
\kant[2]
\chapter{An Interesting Chapter Title Which is Way Too Long to Fit in One Line}
\kant[3]
\end{document}

enter image description here

Related Question