1

I have this package that removes the header from the pages

 \fancypagestyle{noheadrule}{  \fancyhf{}
    \renewcommand{\headrulewidth}{0pt}  \fancyhead[LE,RO]{\thepage} }
    \pagestyle{noheadrule}

It works like a charm but i only want to use it in one chapter but it removes all the headers from all the pages of the project

lockstep
  • 250,273
  • 1
    Welcome to TeX.SX! How about using pagestyle{fancy} or pagestyle{plain} for the other chapters? ;-) Or defining a pagestyle \fancypagestyle{headrule}, that does not set \headrulewidth to 0pt? –  May 17 '16 at 18:28
  • Please edit your question title. I think this is about how to change pagestyle (from chapter to another) – touhami May 17 '16 at 19:24

1 Answers1

5

It is not possible to include a package for one chapter and 'unload' it for another part of the document.

However, it's possible to limit the effects what a chapter does, depending on the chapter.

Explicitly define two different pagestyles, one for the particular chapter and another one, that restores the settings (or changes them to something other!)

\documentclass{book}

\usepackage{blindtext}

\usepackage{fancyhdr}



\fancypagestyle{headrule}{%
  \renewcommand{\headrulewidth}{2pt}  
  \fancyhead[CE]{foo}
  \fancyhead[LE,RO]{\thepage} 
}

\fancypagestyle{noheadrule}{%
  \fancyhf{}
  \renewcommand{\headrulewidth}{0pt}  
  \fancyhead[LE,RO]{\thepage} 
}

\begin{document}
\pagestyle{noheadrule}
\chapter{The one with no headrule}
\blindtext[15]


\clearpage
\pagestyle{headrule}
\chapter{The fancy one!}
\blindtext[15]

\end{document}
  • By the way, congrats on joining the ranks of the "Legendary"!! Just noticed that it happened a few days ago. – Mico May 17 '16 at 20:40
  • @Mico: Thanks, it was a long journey to this badge ;-) Alas, it will be the last Gold badge for a long time –  May 22 '16 at 15:14
  • 1
    You made it "legendary" status in about half as much time as it took me! Your many contributions on this site are much appreciated. – Mico May 22 '16 at 19:59
  • @Mico: Thanks again ;-) Because you gave too much lua - based answers? ;-) –  May 22 '16 at 20:02
  • Indeed, LuaLaTeX-based answers don't tend to generate a lot of upvotes... :-) I fear Lua(La)TeX is still a few -- but hopefully not many -- years away from experiencing more widespread adoption by the masses. – Mico May 22 '16 at 20:13
  • @Mico: Sounds like a world-domination plan ;-) and I always upvote them -- I don't understand them, but I upvote them (if I spot your answers ;-)) –  May 22 '16 at 20:17
  • Awwwww. :-) You're too kind! Much appreciated, for sure!! – Mico May 22 '16 at 20:22
  • I'm giving you another chance to do a good deed: See http://tex.stackexchange.com/a/311485/5001 :-) – Mico May 25 '16 at 20:43
  • @Mico: ;-) ;-) ;-) ;-) –  May 25 '16 at 20:45