# Chapterformat with \chapter*

So I came across some problems with the chapter layout, which has to do with the \chapter* command. This is how I have the layout set up right now, it was done by a friend, who has more experience with LaTeX and KOMA than me:

\documentclass[11pt,
chapterprefix=true
]{scrbook}
\usepackage[]{graphicx}
\usepackage[scaled=.90]{helvet}
\usepackage[automark]{scrlayer-scrpage}
\usepackage{blindtext}
\usepackage{ragged2e}
\setkomafont{chapter}{\Huge\bfseries}
\renewcommand*{\raggedsection}{\raggedright}
\renewcommand*{\chapterformat}{%
\hrulefill\enskip\mbox{\scalebox{3}{\thechapter\autodot}}\vspace{-0.6\baselineskip}}
\newcommand{\chap}[1]{\chapter{#1}\vspace{-0.8\baselineskip}\hrule\vspace{1.5\baselineskip}}

\begin{document}
\tableofcontents
\chapter*{Introduction}
\blindtext

\chap{Theory}
\blindtext
\end{document}


now this results in the chapter layout I want for the "Theory" chapter, however it doesn't work for the "Introduction" chapter, because both bars are missing.

So would it be possible to have the layout like the following:

------------
Introduction
------------

text

----------1
Theory
-----------


the same way it was done in the minimal working example above, however, but also for the introduction chapter. Both chapters should be in the ToC and the "Introduction" should not be enumerated. I cannot get anything to do exactly that, maybe you guys have an idea, also any improvement to the layout in general would be greatly appreciated.

• Welcome to TeX.SX! – moewe Sep 14 '15 at 10:42

Update (KOMA-Script version 3.19 is now on CTAN and in TeXLive)

There is another possibility with KOMA-Script version 3.19 or newer. With that version you can simple redefine the command \chapterlinesformat. This command is explained in the KOMA-Script documentation.

\documentclass{scrbook}[2015/09/15]
\usepackage{graphicx}
\usepackage[scaled=.90]{helvet}
\usepackage[automark]{scrlayer-scrpage}
\usepackage{blindtext}
\setkomafont{chapter}{\Huge\bfseries}

\renewcommand*{\chapterformat}{%
\enskip\mbox{\scalebox{3}{\thechapter\autodot}}}
\renewcommand\chapterlinesformat[3]{%
\parbox[b]{\textwidth}{\hrulefill#2}\par%
#3\par\bigskip
\hrule}
\RedeclareSectionCommand[afterskip=1.5\baselineskip]{chapter}

\begin{document}
\tableofcontents
\blindtext
\chapter{Theory}
\blindtext
\blinddocument
\end{document}


Note that I have removed chapterprefix=true.

Result:

Here is another suggestion (for older KOMA-Script versions) also using etoolbox. The line below the chapter is inserted by \chapterheadendvskip.

\usepackage{etoolbox}


So you can use \chapter etc. in your code and it works also for the table of contents.

And with

\newcommand\chaptertopline{\smash{\raisebox{-3.5\baselineskip}{\rule{\textwidth}{.4pt}}}}
\makeatletter
\makeatother


it is also possible to use \addchap instead the combination of \chapter* and \addcontentsline.

Code:

\documentclass[
chapterprefix=true
]{scrbook}
\usepackage{graphicx}
\usepackage[scaled=.90]{helvet}
\usepackage[automark]{scrlayer-scrpage}
\usepackage{blindtext}

\setkomafont{chapter}{\Huge\bfseries}
\renewcommand*{\chapterformat}{%
\hrulefill\enskip\mbox{\scalebox{3}{\thechapter\autodot}}\vspace{-0.6\baselineskip}}

\usepackage{etoolbox}
\newcommand\chaptertopline{\smash{\raisebox{-3.5\baselineskip}{\rule{\textwidth}{.4pt}}}}
\makeatletter
\makeatother

\begin{document}
\tableofcontents
\blindtext

\chapter{Theory}
\blindtext
\end{document}


Result:

• Can this be used here, too: tex.stackexchange.com/q/266730 ? – clemens Sep 14 '15 at 14:54
• Can you elaborate on the example above? How did you manage to add the chapter number only for the "Theory" chapter when using the \chapterheadendvskip command? – Ringli Sep 14 '15 at 15:33
• @Ringli Sorry, I forgot the MWE. I have now added it. – esdd Sep 14 '15 at 20:17

Try this. I used the etoolbox package to patch \@@makeschapterhead to get the line above the heading. The \chapst command starts an unnumbered chapter and puts in the line below. Finally, \mychap works like \chapter, so you can use it without a star for a numbered section or with a star if you don't want a number.

\documentclass[11pt,
chapterprefix=true
]{scrbook}
\usepackage[]{graphicx}
\usepackage[scaled=.90]{helvet}
\usepackage[automark]{scrlayer-scrpage}
\usepackage{blindtext}
\usepackage{ragged2e}
\usepackage{etoolbox}
\setkomafont{chapter}{\Huge\bfseries}
\renewcommand*{\raggedsection}{\raggedright}
\renewcommand*{\chapterformat}{%
\hrulefill\enskip\mbox{\scalebox{3}{\thechapter\autodot}}\vspace{-0.6\baselineskip}}
\newcommand{\chap}[1]{\chapter{#1}\vspace{-0.8\baselineskip}\hrule\vspace{1.5\baselineskip}}
\newcommand\chapst[1]{\chapter*{#1}\vspace{-0.8\baselineskip}\hrule\vspace{1.5\baselineskip}}

\makeatletter

\newcommand\mychap{\@ifstar\chapst\chap}

\makeatother

\begin{document}
\tableofcontents
\mychap*{Introduction}