[Tex/LaTex] KOMA Script exclude header-footer in contents

header-footerkoma-scripttable of 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?

Best Answer

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}