# Strange behaviour of \renewpagestyle from the titlesec package

The following code uses the pagestyles option and \renewpagestyle from the titlesec package to redefine the plain style:

\documentclass{book}
\usepackage[paperheight=12cm]{geometry}
\usepackage[pagestyles]{titlesec}

\renewpagestyle{plain}

\begin{document}

\tableofcontents

\end{document}


The expected behaviour would be to clear all fields in both the header and footer; however, the result of the above example code is the following:

Why is the word "Contents" appearing in the header and in the footer?

-
This seems to be resolved if you formally issue a \pagestyle{plain} after setting it via \renewstyle{plain}{..}. –  Werner Dec 6 '11 at 6:14
@Werner: but then all pages will have plain style, unless a manual change is done. Certainly that's not the desired behaviour. –  Gonzalo Medina Dec 6 '11 at 13:24

The documentation of titlesec warns about using \markboth along with it. The \tableofcontents issues \@mkboth (which is usually equivalent to \markboth). One can cure the problem by saying

\makeatletter
\renewcommand\@mkboth[2]{\chaptermark{#1}}
\makeatother


(which is something titlesec should do by itself).

-
What I don't understand is why the problem doesn't show up in report class, even though the code for \tableofcontents in the two classes is identical. –  Alan Munn Dec 6 '11 at 17:00
In addition to Alan's comment, in both classes \@mkboth is let exactly the same, either as \markboth or as \@gobbletwo, so yes, it's strange that the problem appears with book but not with report. –  Gonzalo Medina Dec 7 '11 at 1:51
@Alan. Because report has plain as the main page style while book has headings. If plain is used as a "subsidiary" style with \thispagestyle, the main page style has to be (re)defined with titlesec, too. See the manual for further info. BTW, \renewpagestyle{plain}{} is shorter. (I'll realease a new version with many new features for page styles in a few days.) –  Javier Bezos Dec 7 '11 at 11:37
@JavierBezos I'd say that the documentation is not very clear about that: it took me a while to understand that the explanation is in footnote 21. –  egreg Dec 7 '11 at 11:49
@JavierBezos: could you please clarify to me your last comment? According to egreg's answer it seems that the problem is \@mkboth, but you say that this is not the culprit. What is then the cause of the problem? Perhaps I am misunderstanding you previous comment?. –  Gonzalo Medina Dec 7 '11 at 17:13