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 would like to change the header and footer to only a group of pages in my document. I'm using the fancyhdr package with these settings:

\usepackage{fancyhdr}
\pagestyle{fancy}

\makeatletter
\DeclareRobustCommand{\format@sec@number}[2]{{\normalfont\upshape#1}#2}
\renewcommand{\chaptermark}[1]{%
  \markboth{\format@sec@number{\ifnum\c@secnumdepth>\m@ne\@chapapp\ \thechapter\, \fi}{#1}}{}}
\renewcommand{\sectionmark}[1]{%
  \markright{\format@sec@number{\ifnum\c@secnumdepth>\z@\thesection\, \fi}{#1}}}
\makeatother

\fancyhf{}
\fancyhead[L]{\itshape\nouppercase{\rightmark}}
\fancyhead[R]{\thepage}

I would likt to not use these settings for some pages. How can I accomplish this?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

This is a job for the command \fancypagestyle from the fancyhdr package. You can define two styles and alter between them at your wish.

\documentclass{article}

\usepackage{fancyhdr}

\fancypagestyle{style1}{
\fancyhf{}
\fancyhead[C]{style 1 with thin line}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
}

\fancypagestyle{style2}{
\fancyhf{}
\fancyhead[C]{STYLE 2 WITH THICK LINE}
\fancyfoot[C]{= \thepage{} =}
\renewcommand{\headrulewidth}{1pt}
}

\pagestyle{style1}

\usepackage{lipsum}

\begin{document}

\lipsum[1-20]

\pagestyle{style2}

\lipsum[1-20]

\pagestyle{style1}

\lipsum[1-20]

\end{document}
share|improve this answer

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.