11

I have defined a personal page style using the package titlesec. The style defined is:

\newpagestyle{myStylePage}[\large\sffamily]{\headrule
\sethead{\thechapter . \chaptertitle}{}{\thesection . \sectiontitle}
\setfoot{}{\usepage}{}
}

I want this style be applied only to all my chapters. But I don't want this style be applied to the \tableofcontents, for example. In order to solve it, I tried to define a another style:

\newpagestyle{myEmptyPage}{
\sethead{}{}{}
\setfoot{}{\usepage}{}
}

My document follows as:

\pagestyle{myEmptyPage}

\pagenumbering{roman}

\tableofcontents
\pagenumbering{arabic}
\pagestyle{myStylePage}
\include{tex/introduction}
... etc.

My problem is that the second page of the table of contents appears with the same style as defined in myStylePage. What I am doing wrong?

Stephen
  • 14,890

2 Answers2

11

You don't need to define a new style, since "empty headers, page number at footer center" is the plain page style, which is also used in the chapter starting pages.

So I believe that the following should suit your needs.

\documentclass{book}
\usepackage{titleps} % or titlesec with appropriate option

\newpagestyle{myStylePage}[\large\sffamily]{%
  \headrule
  \sethead{\thechapter. \chaptertitle}{}{\thesection. \sectiontitle}
  \setfoot{}{\usepage}{}%
}

\begin{document}
\frontmatter
\pagestyle{plain}

\tableofcontents

\mainmatter
\pagestyle{myStylePage}

My beautiful document

\end{document}

If you're using the report class for one sided printing, don't. :) But if you're required to do that, just add an option to the class:

\documentclass[oneside]{book}

Maybe you're using scrreprt; then use scrbook with the same commands.

In case you don't trust me and want to continue using report (or any class that hasn't \frontmatter and \mainmatter such as scrreprt), change the \frontmatter command into

\clearpage\pagenumbering{roman}

and \mainmatter into

\clearpage\pagenumbering{arabic}

but don't forget \clearpage.

egreg
  • 1,121,712
4

\pagenumbering and \pagestyle are applied to the whole page where they are used, i.e. this is done as if they were used at the beginning of that page. When there is no page break at the end of the Table of Contents, \pagenumbering{arabic} \pagestyle{myStylePage} is applied to the last page of the TOC as well as to the text following below the TOC (if there is any text on the same page). A \newpage after the TOC takes care of this. A \clearpage (or \cleardoublepage) would start a new page and additionally force all floating objects to be printed, but probably there are no floats in a TOC.

Stephen
  • 14,890