# KOMA Script exclude header-footer in contents

I am using these settings:

\documentclass[12pt,a4paper,english,openany,oneside]{scrbook}
\usepackage{etoolbox}
\usepackage{calc}
\makeatletter
\pretocmd{\@part}{\gdef\parttitle{#1}}{}{}
\pretocmd{\@spart}{\gdef\parttitle{#1}}{}{}
\makeatother
\usepackage[nouppercase,headsepline,footsepline,automark]{scrpage2}
\clearscrheadfoot
\clearscrheadings
\chead{}
\cfoot{}
\ihead{HeaderLeftText}
\ohead{\parttitle}
\ifoot{\rule{0pt}{\ht\strutbox+\dp\strutbox}\leftmark}
\ofoot{\rule{0pt}{\ht\strutbox+\dp\strutbox}\thepage}
\pagestyle{scrheadings}


and

\begin{document}
% title stuff here
\thispagestyle{empty}
\newpage
\tableofcontents
\part{PartText}


The problem is that since the settings above are defined before \begin{document}, the rendering of table of contents causes error that undefined control sequence in \parttitle and \part, because the headers and footers also appear on the contents page (which I dont want). I think the error is due to the fact that no \part is defined before the TOC and hence there is no text to put in partitle, i.e. the right header.

So, how could I get rid of the header-footer in TOC, or what's another solution?

• I am not sure about your intent with the headers/footers. Remove \pagestyle{scrheadings} from the preamble and place it right after the firs \part command. This will prevent the error; I'm not sure however, if this is what you expect. – Gonzalo Medina Jun 6 '11 at 14:12

## 3 Answers

To get rid of the error initialize your command (that's a good idea anyway) in the preamble: \newcommand\parttitle{}

To get another pagestyle (e.g. empty) in the toc do

\newpage
\pagestyle{empty}
\tableofcontents
\clearpage
\pagestyle{scrheadings}
\part{blub}


The patching \@part hack does not longer work with current KOMA-Script. But it also is not needed (and was never needed), because KOMA-Script also provides automatic marks with part level:

\documentclass[12pt,a4paper,english,openany,oneside]{scrbook}
\usepackage{calc}
\usepackage[headsepline,footsepline,automark,autooneside=false]{scrlayer-scrpage}
\automark[chapter]{part}
\renewcommand*{\partmarkformat}{}
\clearpairofpagestyles
\ihead{HeaderLeftText}
\ohead{\leftmark}
\ifoot{\rule{0pt}{\ht\strutbox+\dp\strutbox}\rightmark}
\ofoot{\rule{0pt}{\ht\strutbox+\dp\strutbox}\pagemark}

\usepackage{blindtext}

\begin{document}
% title stuff here
\pagestyle{empty}
\tableofcontents
\cleardoublepage
\pagestyle{scrheadings}
\part{PartText}
\blinddocument
\end{document}


To get rid of the headers/footers in ToC, you can use:

\tableofcontents
\thispagestyle{empty}

• This give the wanted result only if the table of contents has at most 2 pages. – Ulrike Fischer Jun 6 '11 at 14:20
• @Ulrike: that's right. – ℝaphink Jun 6 '11 at 14:43