1

I have a problem by redefining my chapter styles. I'm using \makechapterhead and \makeschapterhead for this, but I'm not able to make it work with \addchap. The chapter names of the upper section should look like this:

full thick line (not "chapter 0")

full thick line (correct)

thick line "chapter 1" thick line (correct)

thick line "chapter 2" thick line (correct)

full thick line (not "chapter 2" again)

full thick line (not "appendix")

how can I achieve this?

\documentclass[paper=a4, pagesize=auto, fontsize = 12pt]{scrbook}
\usepackage[T1]{fontenc}                
\usepackage[utf8]{inputenc}                         
\usepackage[lf, p, sflf, sfp]{libertine}
\usepackage{biblatex}

\KOMAoptions{%
    listof=totoc,                                       
    bibliography=totoc                                  
}
\makeatletter                               
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
    \vspace*{10\p@}%
    {\parindent \z@ \centering \reset@font
        \thickhrulefill\quad
        \scshape \@chapapp{} \thechapter
        \quad \thickhrulefill
        \par\nobreak
        \vspace*{10\p@}%
        \interlinepenalty\@M
        \hrule
        \vspace*{10\p@}%
        \Huge \bfseries #1\par\nobreak
        \par
        \vspace*{10\p@}%
        \hrule
        \vskip 100\p@
}}
    \def\@makeschapterhead#1{%
    \vspace*{10\p@}%
    {\parindent \z@ \centering \reset@font
        \thickhrulefill
        \par\nobreak
        \vspace*{10\p@}%
        \interlinepenalty\@M
        \hrule
        \vspace*{10\p@}%
        \Huge \bfseries #1\par\nobreak
        \par
        \vspace*{10\p@}%
        \hrule
        \vskip 100\p@
}}

\begin{document}
    \addchap{Abbr.}
    \tableofcontents
    \chapter{Ch 1}  
    \chapter{Ch 2}
    \printbibliography
    \begin{thebibliography}{99}
        \bibitem{mmax} Max Power: \emph{Power of Max}. Hard Power.
    \end{thebibliography}
    \appendix   
    \addchap{App}
\end{document}
0

2 Answers 2

0

With a KOMA-Script class, it is not recommended to redefine internal commands.

Here is a suggestion redefining the documented macro \chapterlinesformat:

\documentclass[
  %paper=a4, pagesize=auto,% default
  fontsize = 12pt
]{scrbook}
%\providecommand*\Ifstr{\ifstr}% needed up to and including KOMA-Script version 3.27, see https://komascript.de/faq_deprecatedif
\usepackage[T1]{fontenc}
%\usepackage[utf8]{inputenc}% needed for older TeX distributions
\usepackage[lf, p, sflf, sfp]{libertine}
%\usepackage{biblatex}

\KOMAoptions{%
    listof=totoc,
    bibliography=totoc
}

\RedeclareSectionCommand[
  beforeskip=\dimexpr10pt+\baselineskip\relax,
  afterskip=100pt,
  afterindent=false,
  font=\normalfont\normalsize,
]{chapter}
\newkomafont{chapterprefixline}{\scshape}
\newkomafont{chaptertitle}{\Huge\bfseries}
\renewcommand\raggedchapter{\centering}
\renewcommand\chapterformat{%
  \usekomafont{chapterprefixline}%
  \thickhrulefill\quad\mbox{\chapapp\nobreakspace\thechapter}\quad\thickhrulefill
}


\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\renewcommand\chapterlinesformat[3]{%
  \Ifstr{#1}{chapter}
    {%
      \IfArgIsEmpty{#2}{\thickhrulefill}{#2}%
      \par\nobreak
      \vspace*{10\p@}%
      \interlinepenalty\@M
      \hrule
      \vspace*{10\p@}%
      \usekomafont{chaptertitle}#3\par\nobreak
      \par
      \vspace*{10\p@}%
      \hrule
    }
    {#2#3}%
}

\begin{document}
\addchap{Abbr.}
\tableofcontents
\chapter{Ch 1}
\chapter{Ch 2}
%\printbibliography
\begin{thebibliography}{99}
  \bibitem{mmax} Max Power: \emph{Power of Max}. Hard Power.
\end{thebibliography}
\appendix
\addchap{App}
\end{document}

Result:

enter image description here

1
  • this is a great answer, thx! This might be the better the solution because of your named reason.
    – Bolle
    Oct 2, 2019 at 15:27
2

You can test for the current value of secnumdepth:

\documentclass[paper=a4, pagesize=auto, fontsize = 12pt]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[lf, p, sflf, sfp]{libertine}
\usepackage{biblatex}

\KOMAoptions{%
    listof=totoc,
    bibliography=totoc
}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
    \vspace*{10\p@}%
    {\parindent \z@ \centering \reset@font
        \ifnum \c@secnumdepth < \chapternumdepth\relax
         \thickhrulefill
        \else 
         \thickhrulefill\quad
         \scshape \@chapapp{} \thechapter
         \quad \thickhrulefill
        \fi
        \par\nobreak
        \vspace*{10\p@}%
        \interlinepenalty\@M
        \hrule
        \vspace*{10\p@}%
        \Huge \bfseries #1\par\nobreak
        \par
        \vspace*{10\p@}%
        \hrule
        \vskip 100\p@
}}
    \def\@makeschapterhead#1{%
    \vspace*{10\p@}%
    {\parindent \z@ \centering \reset@font
        \thickhrulefill
        \par\nobreak
        \vspace*{10\p@}%
        \interlinepenalty\@M
        \hrule
        \vspace*{10\p@}%
        \Huge \bfseries #1\par\nobreak
        \par
        \vspace*{10\p@}%
        \hrule
        \vskip 100\p@
}}

\begin{document}
    \addchap{Abbr.}
    \tableofcontents
    \chapter{Ch 1}
    \chapter{Ch 2}
    \printbibliography
    \begin{thebibliography}{99}
        \bibitem{mmax} Max Power: \emph{Power of Max}. Hard Power.
    \end{thebibliography}
    \appendix
    \addchap{App}
\end{document}
1
  • 1
    thanks Ulrike, exactly what I was looking for!
    – Bolle
    Sep 29, 2019 at 16:36

You must log in to answer this question.

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