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'd like to have my header appear on every page except the first (title page). However, it's not appearing on the first page of my table of contents(regardless of where it appears in the document). The preable to my script is as follows:

\documentclass[12pt]{report}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{fancyhdr}
\usepackage{textpos}
\usepackage{datetime}
\pagestyle{fancy}
\usepackage{lastpage}

\fancypagestyle{plain}
\fancyhf{}
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\fancyhead[L]{\includegraphics[width=2cm]{../uq_logo.jpg}}
\fancyhead[R]{\includegraphics[width=2cm]{../mishc_logo.jpg}}
\fancyhead[C]{MR Framework Manual}
\fancyfoot[L]{\today, \ampmtime}
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}

\setcounter{secnumdepth}{-1} 

\begin{document}

Any help is much appreciated.

share|improve this question
    
\tableofcontents is based on \chapter, which in turn invokes \thispagestyle{plain}, so it's necessary to intervene in the basic definition of \chapter to impose your header on the first page. i'll leave the details to someone else; there's probably something in the etools package that would help, but i'm not as familiar as i should be with that package. –  barbara beeton Jul 8 '12 at 17:26

1 Answer 1

up vote 4 down vote accepted

The \fancypagestyle macro takes two arguments. First is the style to be (re)defined, while the second is the (re)definition itself:

\fancypagestyle{plain}{%
  \fancyhf{}
  \renewcommand{\headrulewidth}{0.1pt}
  \renewcommand{\footrulewidth}{0.1pt}
  \fancyhead[L]{\includegraphics[width=2cm]{../uq_logo.jpg}}
  \fancyhead[R]{\includegraphics[width=2cm]{../mishc_logo.jpg}}
  \fancyhead[C]{MR Framework Manual}
  \fancyfoot[L]{\today, \ampmtime}
  \fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}
}

You did not supply the second (or it was considered empty in this case). See the example on p 8 of the fancyhdr documentation (section 7 Redefining plain style).

Follow this (re)definition with \pagestyle{plain} to "re-initialize" it.

share|improve this answer
    
Seems like a step in the right direction, but it's inverted the problem: Now I get the correct header on the first page of the table of contents, but the wrong header on every page after that. –  Liam M Jul 8 '12 at 17:33
    
... unless I add the header twice: once inside the fancypagestyle, once outside. Is this usual? –  Liam M Jul 8 '12 at 17:40
    
@LiamM You also have to say \pagestyle{plain} after the \fancypagestyle{plain}{...} stuff, so that the style is reinitialized. –  egreg Jul 8 '12 at 17:51
    
Thanks guys, that's solved it. –  Liam M Jul 9 '12 at 4:43

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.