Page LayoutUnexpected result of redefining plain style

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
ariel67
Posts: 4
Joined: Wed Nov 30, 2016 1:43 pm

Unexpected result of redefining plain style

Post by ariel67 »

I'm writing a book, sectioned in several chapters. I'm using the fancyhdr package. I would like the first page to each chapter looks different from others, in particular I don't want header on it. So, I've tried to redefine the "plain" style, but it seems to be ignored. Here a compilable exemple:

Code: Select all

\documentclass[12pt, openright, twoside, a4paper]{report}
\usepackage{subfiles}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}     % supprime les en-têtes et pieds de page
\renewcommand{\chaptermark}[1]{\markboth{\thechapter. \ #1}{}}   % Ceci permet d'avoir les noms de chapitre et de section
\renewcommand{\sectionmark}[1]{\markright{\thesection. \ #1}{}}    % en minuscules :
\fancyhead[RO,LE]{{\bfseries \leftmark} \\ \rightmark}
\renewcommand{\headrulewidth}{0.5pt}% filet en haut de page
\renewcommand{\footrulewidth}{0.5pt} % filet en bas
\fancyfoot[RO,LE]{\thepage}
\fancypagestyle{plain}{%
    \fancyfoot[RO,LE]{\thepage}
%\addtolength{\headheight}{0.5pt}    % espace pour le filet
\renewcommand{\footrulewidth}{0.5pt} % filet en bas
}
\begin{document}
\chapter{First}
\thispagestyle{plain}
\lipsum[1]
\lipsum[2]
\lipsum[3]
\lipsum[2]
\chapter{Second}
\lipsum[1]
\lipsum[2]
\lipsum[3]
\lipsum[2]

\end{document}
There is no difference between the layout of the first pages of the two chapters: both have an header. Where am I wrong? Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Unexpected result of redefining plain style

Post by Johannes_B »

Those pages don't have a header by default, so the reason is within your code.

I am my phone right now, so i cannot test.

Edit: add \fancyhf{} to the plain definition.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
ariel67
Posts: 4
Joined: Wed Nov 30, 2016 1:43 pm

Unexpected result of redefining plain style

Post by ariel67 »

Yes, right! Thank you!!
Post Reply