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

  • 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? – user31729 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
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 – user31729 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? ;-) – user31729 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

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.