6

The following minimal working example is not giving me the desired results. I would like to keep the chapter titles layout, but without using the titlesec package. The titlesec package is interfering with the option headings=optiontotoc. This becomes visible in the table of contents by showing empty entries instead of leaving them away.

Unfortunately my koma-script skills are strongly limited. Does anybody have an idea how to create the desired chapter titles layout with code only?

I also tried the loadonly option provided by the titlesec package, which is producing errors.

Here is the minimal working example:

\documentclass[11pt,numbers=noenddot,headings=optiontotoc]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\renewcommand{\sffamily}{\rmfamily}

\usepackage{titlesec}
\titleformat{\chapter}[display]{\usekomafont{chapter}\bfseries\raggedleft}{\vspace{-3em} \textsc{Kapitel} \thechapter \vspace{1.5em}}{.5 em}{\vspace{-1em} \titlerule  \vspace{.5em}}[\vspace{.5em} \titlerule]

\begin{document}
\tableofcontents

\chapter{Chapter}

\section{Section}  
Hier folgt dann der Text

\subsection{Subsection}  
Hier folgt dann der Text

\subsection{Subsection 2}  
Hier folgt dann der Text

\chapter[]{Nullchapter}
Und hier folgt dann der Text

\section[]{Nullsection} 
Und hier folgt dann der Text

\subsection[]{Nullsubsection} 
Und hier folgt dann der Text

\end{document}

Desired Chapter Title Layout:

chapter title

Empty Entries in TOC because of the titlesec package: toc

  • I believe, you missed \chapter*{Title}, \section*{Title} and \subsection*{Title} instead of \chapter[]{Nullchapter} etc. – user31729 Apr 25 '14 at 8:03
  • @Christian Thanks for your reply. I am aware of the starred versions, but i need numbering. – millo Apr 25 '14 at 8:36
  • The German manual of KOMA classes (4th edition, on page 110) explicitly states that the section formatting mechanism works only if there is no other package doing that. – user31729 Apr 25 '14 at 14:19
  • @ChristianHupfer Unfortunately, I don't have access to the mentioned manual. But if understand you correctly, that is part of the reason why i would like to get rid of the titlesec package and only use koma-script commands instead. Do you know a way to get the posted chapter title style with koma-script code? – millo Apr 25 '14 at 16:36
  • There is a \chapterformat command within KOMA classes, that sets up the style how the chapter title is formatted. Unfortunately, I am not an expert with KOMA :-( – user31729 Apr 26 '14 at 5:57
5

I found a working solution through: http://www.latex-community.org/forum/viewtopic.php?f=5&p=53313. The command @makechapterhead is used for all numbered titles and @makeschapterhead for all unnumbered titles.

A full working minimal example looks like this:

\documentclass[11pt,numbers=noenddot,headings=optiontotoc,chapterprefix]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\renewcommand{\sffamily}{\rmfamily}

\makeatletter

\def\@makechapterhead#1{%
    \vspace*{10\p@}%
    {\parindent \z@ \raggedleft \reset@font
        \huge \scshape \@chapapp{}  \thechapter\vspace*{-15\p@}
        \par\nobreak
        \interlinepenalty\@M\hrulefill\newline\vspace*{-5\p@}
        \huge \bfseries #1\par\nobreak
        \vspace*{-8\p@}%
        \hrulefill
        \par\nobreak
        \vskip 30\p@
}}

\def\@makeschapterhead#1{%
    \vspace*{4\p@}%
    {\parindent \z@ \raggedleft \reset@font
        \scshape
        \interlinepenalty\@M\hrulefill\newline\vspace*{-5\p@}
        \huge \bfseries #1\par\nobreak
        \vspace*{-8\p@}%
        \hrulefill
        \par\nobreak
        \vskip 30\p@
}}

\makeatother

\begin{document}

\tableofcontents
\listoffigures
\listoftables

\chapter{Chapter}

\section{Section}  
Hier folgt dann der Text

\subsection{Subsection}  
Hier folgt dann der Text

\subsection{Subsection 2}  
Hier folgt dann der Text

\chapter[]{Nullchapter}
Und hier folgt dann der Text

\section[]{Nullsection 2} 
Und hier folgt dann der Text

\subsection[]{Nullsubsection} 
Und hier folgt dann der Text

\end{document}

Thank you @ChristianHupfer for all your suggestions and patience.

2

If you want to omit the entry into \tableofcontents, you should use the starred versions of the sectioning commands, such as \chapter*, \section* etc. This however prevents numbering of the sections.

\documentclass[11pt,numbers=noenddot,headings=optiontotoc]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\renewcommand{\sffamily}{\rmfamily}



\usepackage{titlesec}
\titleformat{\chapter}[display]{\usekomafont{chapter}\bfseries\raggedleft}{\vspace{-3em} \textsc{Kapitel} \thechapter \vspace{1.5em}}{.5 em}{\vspace{-1em} \titlerule  \vspace{.5em}}[\vspace{.5em} \titlerule]

\begin{document}
\tableofcontents

\chapter{Chapter}

\section{Section}  
Hier folgt dann der Text

\subsection{Subsection}  
Hier folgt dann der Text

\subsection{Subsection 2}  
Hier folgt dann der Text

\chapter*{Nullchapter}
Und hier folgt dann der Text

\section*{Nullsection} 
Und hier folgt dann der Text

\subsection*{Nullsubsection} 
Und hier folgt dann der Text

\end{document}

enter image description here

Edit

Based on millo's solution, just as an extension:

\documentclass[11pt,numbers=noenddot,headings=optiontotoc,chapterprefix]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\renewcommand{\sffamily}{\rmfamily}

\setkomafont{chapter}{\raggedleft\huge}

\let\origchapapp\chapapp
\renewcommand{\chapapp}{\textsc{\origchapapp}}  % or \scshape{\origchapapp}

\renewcommand*{\chapterheadstartvskip}{\vskip-10pt}
\renewcommand*{\chapterformat}{%
    \raggedleft
    \chapapp\enskip\thechapter\\
    \hrulefill\\[-9pt]
}
\renewcommand*{\chapterheadendvskip}{%
    \vspace{-12pt}\noindent{\setlength{\parskip}{0pt}\Huge\hrulefill\par}
    \vspace{\baselineskip}
}


\begin{document}

\tableofcontents

\chapter{Chapter}

\section{Section}  
Hier folgt dann der Text

\subsection{Subsection}  
Hier folgt dann der Text

\subsection{Subsection 2}  
Hier folgt dann der Text

\chapter[]{Nullchapter}
Und hier folgt dann der Text

\section[]{Nullsection} 
Und hier folgt dann der Text

\subsection[]{Nullsubsection} 
Und hier folgt dann der Text


\end{document}

enter image description here

  • Thank you for your suggestion. I do need the numbering though. My thesis includes two table of contents. One for the content of the main part and an additional one for the appendix. For this reason i need numbered sections and subsections without entries in the toc-file. – millo Apr 25 '14 at 8:35
  • @millo: I suspected that ;-) – user31729 Apr 25 '14 at 8:44
1

Thank you @ChristianHupfer for the hint with the \chapterformat command. I found a solution under the the link: http://www.komascript.de/chapterwithlines. With some editing i managed to come up with the following solution:

\documentclass[11pt,numbers=noenddot,headings=optiontotoc,chapterprefix]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

\renewcommand{\sffamily}{\rmfamily}

\setkomafont{chapter}{\raggedleft\huge}

\renewcommand*{\chapterheadstartvskip}{\vskip-10pt}
\renewcommand*{\chapterformat}{%
    \raggedleft
    \chapapp\enskip\thechapter\\
    \hrulefill\\[-9pt]
}
\renewcommand*{\chapterheadendvskip}{%
    \vspace{-12pt}\noindent{\setlength{\parskip}{0pt}\Huge\hrulefill\par}
    \vspace{\baselineskip}
}


\begin{document}

\tableofcontents

\chapter{Chapter}

\section{Section}  
Hier folgt dann der Text

\subsection{Subsection}  
Hier folgt dann der Text

\subsection{Subsection 2}  
Hier folgt dann der Text

\chapter[]{Nullchapter}
Und hier folgt dann der Text

\section[]{Nullsection} 
Und hier folgt dann der Text

\subsection[]{Nullsubsection} 
Und hier folgt dann der Text


\end{document}

Unfortunately I am facing still two problems:

  • The titles of the toc, list of tables, list of figures and appendix are behaving differently. It makes sense, that these titles do not recall the \chapappcommand and show "Kapitel X" above "Inhaltsverzeichnis", but I would still like the hruleabove them and similar spacing.
  • I am not able to find a command that produces small caps for \chapapp. \scshapeand \textsc{}did not work like I hoped. Can somebody come up with a workaround?

Chapter titles generated with the titlesec package: Inhaltsverzeichnis

and

Kapitel 1


Chapter titles generated with code only: Inhaltsverzeichnis

and

Kapitel 1

  • I added a suggestion about \chappapp, perhaps it works, but I have no solution about that line above Inhaltsverzeichnis. – user31729 Apr 27 '14 at 16:45
  • @ChristianHupfer Your suggestion worked just fine. I found a way to input that extra line with the following command: \BeforeTOCHead[toc]{% \cleardoublepage \let\clearpage\relax \noindent \hrulefill\\[7pt] } This is not a good solution though, because this has to be done for every unnumbered title. I found another solution which I will share as a full answer. – millo Apr 27 '14 at 22:15

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.