2

For the following document, I am having trouble understanding why the Table of Contents is missing its title. I've also noticed that when I add \frontmatter, all chapter titles disappear and the chapter numbers become messed up (chapter one seemingly becomes chapter zero). How can I fix this so that the table of contents has a title with the same style as each of the chapters? As a side question, is there a way to alter the page headers so as to omit the chapter numbers? So for example, '1. Introduction' would simply become 'Introduction'.

\documentclass[12pt, a4paper]{scrbook}
\usepackage[left=3cm, right=3cm,top=4.15cm,bottom=4.27cm,showframe]{geometry}
\usepackage{titletoc,chngcntr}
\usepackage{lipsum}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-scrpage}
\usepackage[explicit]{titlesec}


\titleformat{\chapter}
{\normalfont\Large\bfseries}{\thechapter \quad \MakeUppercase{#1}}{.5em}{\vspace{.5ex}}[\titlerule]
\titlespacing*{\chapter}
{0pt}{-12.5pt}{19.5pt}


\titleformat{\section}[block]
{\bfseries}
{\S\ \thesection \enskip}
{\fontdimen2\font}
{#1}
\renewcommand{\thechapter}{\arabic{chapter}.}
\renewcommand{\thesection}{\thechapter\arabic{section}.}

\pagestyle{scrheadings}
\clearpairofpagestyles
\ohead[]{\pagemark}
\lohead[]{\headmark}
\rehead{Title}
\setkomafont{pageheadfoot}{\scshape\footnotesize}% or "\footnotesize" depending on fonts
\automark[chapter]{chapter}
\automark[chapter]{}

\renewcommand{\contentsname}{Whatever}
\begin{document}

\tableofcontents

\chapter{Introduction}
\section{Motivation}
\lipsum
\newpage 
More 
\end{document}
2

Your redefinition of the chapter format using \titleformat results in the issue. This also happens if you replace scrbook by the standard class book.

But it is also not recommended to use titletoc and titlesec with a KOMA-Script class. So here is a suggestion using KOMA-Script commands:

\documentclass[12pt, a4paper,numbers=enddot]{scrbook}
\usepackage[left=3cm, right=3cm,top=4.15cm,bottom=4.27cm,showframe]{geometry}
\usepackage{chngcntr}
\usepackage{lipsum}
\usepackage{microtype}
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-scrpage}

\RedeclareSectionCommand[
  beforeskip=-.25em,
  afterskip=19.5pt,
]{chapter}
\makeatletter
\renewcommand\chapterlinesformat[3]{%
  \ifstr{#1}{chapter}
    {\@hangfrom{#2}{\MakeUppercase{#3}}\vspace{-.25em}\rule{\textwidth}{.4pt}}
    {\@hangfrom{#2}{#3}}%
}
\makeatother

\setkomafont{chapter}{\rmfamily\Large}
\setkomafont{section}{\rmfamily\normalsize}
\renewcommand\sectionformat{\S\ \thesection\autodot\enskip}

\clearpairofpagestyles
\ohead{\pagemark}
\lohead{\headmark}
\rehead{Title}
\setkomafont{pageheadfoot}{\scshape\footnotesize}% or "\footnotesize" depending on fonts
\automark[chapter]{}

\renewcommand{\contentsname}{Whatever}
\begin{document}

\tableofcontents

\chapter{Introduction}
\section{Motivation}
\lipsum[1-50]
\end{document}

enter image description here

enter image description here

To remove the chapter number in page headers add

\renewcommand\chaptermarkformat{}

to the preamble.

enter image description here

0

The problem is that the chapter title is set in the “if numbered chapter” part (third mandatory argument to \titleformat, so nothing appears in unnumbered chapters such as the table of contents.

The solution is to use block format.

In the code below, I changed scrbook into book, because Komascript classes don't like titlesec.

\documentclass[12pt, a4paper]{book}
\usepackage[
  left=3cm,
  right=3cm,
  top=4.15cm,
  bottom=4.27cm,
  headheight=14.5pt,% <--- don't forget
  showframe,
]{geometry}

%\usepackage[utf8]{inputenc} % not needed with newer LaTeX
%\usepackage{chngcntr} % not needed with newer LaTeX
\usepackage{microtype}
\usepackage{scrlayer-scrpage}
\usepackage{titlesec}
\usepackage{titletoc}

\usepackage{lipsum}

\titleformat{\chapter}[block]
  {\normalfont\Large\bfseries}
  {\thechapter}
  {1em}
  {\MakeUppercase}
  [\titlerule]
\titlespacing*{\chapter}
  {0pt}
  {-12.5pt}
  {19.5pt}

\titleformat{\section}[block]
  {\bfseries}
  {\S\ \thesection}
  {\fontdimen2\font}
  {}

\renewcommand{\thechapter}{\arabic{chapter}.}
\renewcommand{\thesection}{\thechapter\arabic{section}.}

\pagestyle{scrheadings}
\clearpairofpagestyles
\ohead[]{\pagemark}
\lohead[]{\scshape\headmark}
\rehead{Title}

\renewcommand{\contentsname}{Whatever}

\begin{document}

\tableofcontents

\chapter{Introduction}
\section{Motivation}
\lipsum
\clearpage 

More 

\end{document}

enter image description here

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.