Is there a way to define a page style based on the actual page number? For example, the first page is a title page, second is TOC (possibly third and fourth as well), next is executive summary, next is report, etc.

I am mainly concerned with the first few pages, noting that the page style would have to remain constant for the TOC regardless of how many pages it works out to be.

I would like to accomplish this in my preamble.tex file.

  • How do you distinguish between your ToC and what follows? Do you issue something like \mainmatter? Let us know. Also how different are the page styles relating to the ToC and what follows? – Werner Sep 13 '16 at 4:43
  • @Werner - I had not been using \mainmatter. I was instead using \newpage after \tableofcontents. I am not familiar with \mainmatter. The title page may actually need to be a separate .tex file because it would be very different than the ToC and ES. But ToC and ES could be identical in theory, but I may need to change the format slightly. – Prevost Sep 13 '16 at 4:51

In principle one can set a page style to be executed as part of another command and therefore tie the two together.

For example, let's assume you have one page style for the ToC called tocpagestyle and another for your main matter called mainmatterpagestyle. The following would ensure a different page style for the ToC and main matter from your preamble:

\let\oldtableofcontents\tableofcontents% Copy \tableofcontents
\renewcommand{\tableofcontents}{% Update \tableofcontents to...
  \pagestyle{tocpagestyle}% Set the ToC page style
  \oldtableofcontents% Set the regular ToC
  \pagestyle{mainmatterpagestyle}% Set the main matter page style

One could also tie into \mainmatter, if it is used.

| improve this answer | |
  • I will try what you have proposed. Is the \cleardoublepage clearing the pagestule for two pages? Have you assumed the ToC will be no longer than two pages? – Prevost Sep 13 '16 at 15:38
  • @Prevost: \cleardoublepage will clear to a recto page in twoside mode, or defaults to \clearpage in non-twoside mode. The above solution makes no assumption of the \tableofcontents size (page-wise), and should work for anything. If not, give some more details. – Werner Sep 13 '16 at 18:01

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.