4

What I am looking for is to have the chapter initial page without a page number. Apparently Latex or/and \pagestyle{fancy} use \pagestyle{plain} by default on the footer.

So, I proceded to modify the footer like that: \fancyfoot{}

This working, but it is not on the chapter initial page.

The solution looks like to be:

\documentclass[twoside, 12pt]{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{}
...
\chapter{My chapter}
\thispagestyle{empty}
Chapter text here...

But this means I'll have to type \pagestyle{fancy} everytime I make a new chapter. Is there any way to optimize that?

I tried:

\let\oldchapter\chapter
\def\chapter{\oldchapter\pagestyle{empty}}

But I got the following error: ! Argument of \thispagestyle has an extra }.

I also tried:

\let\oldchapter\chapter
\def\emptypagestyle{\thispagestyle{empty}}
\def\chapter{\cleardoublepage\oldchapter\thispagestyle{empty}}

But no luck either: ! Paragraph ended before \l@chapter was complete. ! Extra }, or forgotten \endgroup. [...]

  • You can have it easily with titlesec. – Bernard Nov 16 '15 at 0:08
  • \oldchapter\pagestyle means you are passing \pagestyle as the argument to the original \chapter command, after that things go wrong. you need to declare your new command with arguments then do something like \oldchapter[#1]{#2}\pagestyle{empty} but simpler would be to use fancyhdr to redefine the plain style not to have a number – David Carlisle Nov 16 '15 at 0:11
  • Maybe try \apptocmd{\chapter]{\thispagestyle{empty}}{}{} from the etoolbox package`. – Bernard Nov 16 '15 at 0:12
  • @Bernard No, it can't work, it would be essentially the same as the \oldchapter way. The final part of \chapter is code for deciding whether the next token is *; with your patch the next token would be \thispagestyle. – egreg Nov 16 '15 at 0:53
  • I see. So if he wants to have it done automatically, a solution will be in titlesec. Not sure the ‘soft’ version will do. – Bernard Nov 16 '15 at 0:57
8

If you don't use the plain pagestyle anywhere else, just add

\fancypagestyle{plain}{%
  \renewcommand{\headrulewidth}{0pt}%
  \fancyhf{}%
}

in the preamble.

Full example:

\documentclass[twoside, 12pt]{report}
\usepackage{fancyhdr}
\pagestyle{fancy}

\fancypagestyle{plain}{%
  \renewcommand{\headrulewidth}{0pt}%
  \fancyhf{}%
}

\begin{document}

\chapter{My chapter}

Chapter text here...

\end{document}

If you need the plain page style in other places of the document, define a new one and patch \chapter to use it.

\documentclass[twoside, 12pt]{report}
\usepackage{fancyhdr}
\usepackage{etoolbox}

\patchcmd{\chapter}{plain}{chapterstart}{}{}

\pagestyle{fancy}

\fancypagestyle{chapterstart}{%
  \renewcommand{\headrulewidth}{0pt}%
  \fancyhf{}%
}

\begin{document}

\chapter{My chapter}

Chapter text here...

\end{document}

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.