Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the fancyhdr package and I have defined headers & footers for the fancy page style using the fancypagestyle command. I have also defined a new page style, tocstyle, using the same command.

Defined in this order:

\pagestyle{fancy}{%
    \def\footnotelayout{\color{darkgrey}}
    \renewcommand{\chaptermark}[1]{\markboth{#1}{}} % To change from all CAPS 
    \renewcommand{\sectionmark}[1]{\markright{#1}{}} % to normal case
    \fancyhf{}
    \fancyhead[RO]{\thechapter\ | \leftmark}
    \fancyhead[RE]{\textcolor{darkgrey}{Group 7}}
    \fancyhead[LO]{\textcolor{darkgrey}{P2 Report - CPR Teacher}}
    \fancyhead[LE]{\thesection\ | \rightmark}
    \fancyfoot[RE]{\footnotesize{\thepage\ \textsl{of} \pageref{LastPage}}}
    \fancyfoot[LO]{\footnotesize{\thepage\ \textsl{of} \pageref{LastPage}}}
}

\fancypagestyle{tocstyle}{%
    \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}
    \fancyfoot[RE]{\footnotesize{\thepage}}
    \fancyfoot[LO]{\footnotesize{\thepage}}
}

In the main .tex file I use the tocstyle for the ToC and then I change to fancy, but instead of applying the fancy style it looks like it has the empty style, the pages are completely empty.

\documentclass[a4paper,11pt,titlepage,twoside,parskip=half-,bibliography=totoc]{scrreprt}
    \begin{document}
        \pagestyle{tocstyle}
        \tableofcontents
        \clearpage
        \pagestyle{fancy}

        \include{baForeword}
        \include{bIntroduction}
        ...
    \end{document}
share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

The error is in

\pagestyle{fancy}{<your settings>}

The \pagestyle command requires only one argument, so the following text in braces is actually executed in a group and everything disappears after the closing brace.

\def\footnotelayout{\color{darkgrey}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}} % To change from all CAPS 
\renewcommand{\sectionmark}[1]{\markright{#1}{}} % to normal case

\fancypagestyle{bookstyle}{
\fancyhf{}
\fancyhead[RO]{\thechapter\ | \leftmark}
\fancyhead[RE]{\textcolor{darkgrey}{Group 7}}
\fancyhead[LO]{\textcolor{darkgrey}{P2 Report - CPR Teacher}}
\fancyhead[LE]{\thesection\ | \rightmark}
\fancyfoot[RE]{\footnotesize{\thepage\ \textsl{of} \pageref{LastPage}}}
\fancyfoot[LO]{\footnotesize{\thepage\ \textsl{of} \pageref{LastPage}}}
}
\fancypagestyle{tocstyle}{%
  \fancyhf{}
  \renewcommand{\headrulewidth}{0pt}
  \fancyfoot[RE]{\footnotesize{\thepage}}
  \fancyfoot[LO]{\footnotesize{\thepage}}
}

If you need to use the tocstyle page style for the table of contents, write something like

\begin{document}
\frontmatter
...
\pagestyle{tocstyle}
\tableofcontents
\listoffigures
%\cleardoublepage

\mainmatter
\pagestyle{bookstyle}

...

The \cleardoublepage should be added in order to mark precisely the transition between page styles; however, if \mainmatter immediately follows the table of contents pages, it's not necessary, because \mainmatter issues \cleardoublepage automatically.

It's better to define all the page styles necessary for the document, if one of them has to be used for more than one page (with \thispagestyle).

share|improve this answer
    
Unfortunately that didn't solve the problem. Now the tocstyle is applied to the whole document... –  benregn May 14 '11 at 13:45
    
@benregn: If you declare \pagestyle{tocstyle} somewhere, this declaration has its effect until countermanded by another \pagestyle declaration or, if given in a group, until the group ends. I'll update my answer. –  egreg May 14 '11 at 17:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.