3

I am using the latest version of the LaTeX template of Matthias Pospiech, see http://www.matthiaspospiech.de/blog/2016/05/09/latex-thesis-template-3-2-4-released/.

In my MWE I try to achieve the following: I created a chapter with \chapter[Chapter 1: Headline]{Headline} and in the ToC it is printed as 1 Chapter 1: Headline.

I want to remove the first 1, so that Chapter 1: Headline will be displayed in combination that the styling of the chapter itself on the page where the chapter begins and the styling of the header of the pages should be still the same. So only removing the chapter number 1 without changing something else in the document.

\documentclass[paper=a4,version=last,english]{scrbook}

\usepackage{templatetools}
\usepackage{lipsum}
\usepackage{babel}
\usepackage[style=apa,backend=biber]{biblatex}
\usepackage[automark,komastyle]{scrpage2}
\usepackage{pageslts}

\ifcsdef{chapter}
    {\usepackage{titlesec}}
    {\usepackage{titlesec} \csundef{chapter}}

\usepackage{titletoc}
\usepackage{pdfpages}

\IfPackageLoaded{scrpage2}{
\IfElseDefined{chapter}{
   \pagestyle{scrheadings}
}{
   \pagestyle{scrplain}
}
\IfElseDefined{chapter}{
   \ohead{\pagemark}
   \ihead{\headmark}
   \ofoot[\pagemark]{}
}{
   \cfoot[\pagemark]{\pagemark}
}
\IfElseDefined{chapter}{
   \automark[section]{chapter}
}{
   \automark[subsection]{section}
}
\IfDefined{chapter}{
   \setheadsepline{.4pt}[\color{black}]
}
}
\IfPackageLoaded{titlesec}{
\titleformat{\chapter}[display]
  {\usekomafont{chapter}\Large \color{black}}
  {\LARGE\MakeUppercase{\chaptertitlename}
   \Huge~\thechapter \filright}
  {1pt}
  {
   \titlerule \vspace{0.9pc}\vspace{-\parskip}
   \filright 
   \IfColorDefined{sectioncolor}{\color{sectioncolor}}{}   
  }
  [\color{black} \vspace{0.9pc} \filright {\titlerule}]
}

\makeatletter
\@ifundefined{frontmatter}{
   \newcommand{\frontmatter}{
      \pagenumbering{roman}
   }
}{}
\@ifundefined{mainmatter}{
   \newif\if@mainmatter\@mainmattertrue
   \newcommand{\mainmatter}{
      \pagenumbering{arabic}
      \setcounter{page}{1}
   }
}{}
\makeatother

\begin{document}
\frontmatter
\IfPackageLoaded{scrpage2}{\pagestyle{scrheadings}}
\tableofcontents

\mainmatter

\addchap{General Introduction}
\lipsum[1]

\chapter[Chapter 1: Headline]{Headline}
\lipsum[3-10]

\end{document}
  • 5
    It is a known fact that a KOMA class and titlesec/titletoc should not be used together – user31729 Nov 26 '17 at 14:40
  • 4
    @ChristianHupfer - You missed out on a chance to paraphrase Jane Austen. :-) How about, "It is a truth universally acknowledged, that the KOMA classes and titlesec/titletoc should not be used together." – Mico Nov 26 '17 at 14:56
  • 1
    @Mico: Having 'Persuasion' and 'Pride and Prejudice' that 'Emma' should not use KOMA and titlesec, neither in 'Mansfield Park' nor in 'Northanger Abbey' ;-) – user31729 Nov 26 '17 at 14:58
  • 1
    @ChristianHupfer - Good one! :-) – Mico Nov 26 '17 at 15:30
  • 1
    @Mico: Damn, I forgot 'Sense and Sensibility' :-( – user31729 Nov 26 '17 at 15:42
6

Note that neither package titletoc nor package titlesec should be used with a KOMA-Script class. Package scrpage2 is deprecated for years. Its successor is scrlayer-scrpage.

You could add

\DeclareTOCStyleEntry[
  numwidth=0pt,
  entrynumberformat=\noentrynumber
]{chapter}{chapter}
\newcommand*\noentrynumber[1]{}
\renewcommand*\chaptermarkformat{}

to remove the chapter numbers from TOC and page header. Note that the chapter entries in TOC then will be controlled by package tocbasic.

Remove package titletoc and use

\DeclareTOCStyleEntry[
  numwidth=0pt,
  entrynumberformat=\noentrynumber
]{chapter}{chapter}
\newcommand\noentrynumber[1]{}

enter image description here

enter image description here

But I think it would be better to remove the optional argument of the chapters (and the manuel numbering in it) and insert the chapter prefix in TOC by changing entrynumberformat for chapterentries:

\DeclareTOCStyleEntry[
  dynnumwidth,
  entrynumberformat=\chapterentrynumber
]{chapter}{chapter}
\newcommand\chapterentrynumber[1]{\def\autodot{:}\chaptername\ #1}
\renewcommand\chaptermarkformat{\chaptername\ \thechapter:\enskip}

Then you have to run the code three times to get:

enter image description here

Code:

% Disclamer:
% The following code is mainly the MWE from the question.
% Note that you should not use packages titlesec and titletoc
% together with a KOMA-Script class.
% Package `scrpage2` is deprecated. Its successor is scrlayer-scrpage.
% So I do not recommend to use the following code.
\documentclass[paper=a4,version=last,english]{scrbook}

\usepackage{templatetools}
\usepackage{lipsum}
\usepackage{babel}
\usepackage[style=apa,backend=biber]{biblatex}
\usepackage[automark,komastyle]{scrpage2}
\usepackage{pageslts}

\ifcsdef{chapter}
    {\usepackage{titlesec}}
    {\usepackage{titlesec} \csundef{chapter}}

\usepackage{titletoc}
\usepackage{pdfpages}

\IfPackageLoaded{scrpage2}{
\IfElseDefined{chapter}{
   \pagestyle{scrheadings}
}{
   \pagestyle{scrplain}
}
\IfElseDefined{chapter}{
   \ohead{\pagemark}
   \ihead{\headmark}
   \ofoot[\pagemark]{}
}{
   \cfoot[\pagemark]{\pagemark}
}
\IfElseDefined{chapter}{
   \automark[section]{chapter}
}{
   \automark[subsection]{section}
}
\IfDefined{chapter}{
   \setheadsepline{.4pt}[\color{black}]
}
}
\IfPackageLoaded{titlesec}{
\titleformat{\chapter}[display]
  {\usekomafont{chapter}\Large \color{black}}
  {\LARGE\MakeUppercase{\chaptertitlename}
   \Huge~\thechapter \filright}
  {1pt}
  {
   \titlerule \vspace{0.9pc}\vspace{-\parskip}
   \filright 
   \IfColorDefined{sectioncolor}{\color{sectioncolor}}{}
  }
  [\color{black} \vspace{0.9pc} \filright {\titlerule}]
}

\makeatletter
\@ifundefined{frontmatter}{
   \newcommand{\frontmatter}{
      \pagenumbering{roman}
   }
}{}
\@ifundefined{mainmatter}{
   \newif\if@mainmatter\@mainmattertrue
   \newcommand{\mainmatter}{
      \pagenumbering{arabic}
      \setcounter{page}{1}
   }
}{}
\makeatother

\DeclareTOCStyleEntry[% <- added
  dynnumwidth,
  entrynumberformat=\chapterentrynumber
]{chapter}{chapter}
\newcommand\chapterentrynumber[1]{\def\autodot{:}\chaptername\ #1}% <- added
\renewcommand\chaptermarkformat{\chaptername\ \thechapter:\enskip}%<- added

\begin{document}
\frontmatter
\IfPackageLoaded{scrpage2}{\pagestyle{scrheadings}}
\tableofcontents

\mainmatter

\addchap{General Introduction}
\lipsum[1]

\chapter{Headline}% <- changed
\lipsum[3-10]

\end{document}
| improve this answer | |
  • Thanks, it works! But one issue. The header of the pages, I see now "1 Headline", but I would like to have "Chapter 1: Headline", so the same text as in the ToC. – Tim Nov 26 '17 at 15:22
  • 2
    You have to redefine \chaptermarkformat. See my updated answer. – esdd Nov 26 '17 at 15:27

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.