Page Layoutfancyhdr| Width of the Rule in the Page Header

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Ofboir
Posts: 7
Joined: Thu Oct 06, 2011 10:41 am

fancyhdr| Width of the Rule in the Page Header

Post by Ofboir »

Hi

I am trying to customize my page layout, and I can't find how to do what I want ...

I modified the position of page number in the footer to have it on the outside of the pages. I wanted to do the same on the first pages of chapters, so I redefined the plain style. Here's an extract of my code :

Code: Select all

\fancypagestyle{plain}{
%\renewcommand{\headrulewidth}{0pt}
\fancyfoot[LE,RO]{\thepage}
}

\pagestyle{fancy}
\fancyhf{}
%\renewcommand{\headrulewidth}{0.4pt}
\fancyhead[LO]{\slshape \rightmark}
\fancyhead[RE]{\slshape \uppercase{\chaptername \xspace \thechapter}. \leftmark}
\fancyfoot[LE,RO]{\thepage}
I would like to keep an empty header in plain style (without the horizontal line) and the regular header in fancy style (with the horizontal line which looks nice).

What I don't understand, is that there seems to be an interaction between plain and fancy styles. With this code, the header in plain style is empty, but the horizontal line still present. If I uncomment the two "headrulewidth" lines, the horizontal line totally disappears (in both plain and fancy styles !).

And if I add \fancyhf{} in the plain style, it also removes the headers in fancy style ...

Anyway, I'm confused and I didn't find the solution. Any idea ?

Thank you very much !
Cheers

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Ofboir
Posts: 7
Joined: Thu Oct 06, 2011 10:41 am

fancyhdr| Width of the Rule in the Page Header

Post by Ofboir »

If anybody is interested, I found a solution. I changed the code as following :

Code: Select all

\fancypagestyle{plain}{
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[LE,RO]{\thepage}
}

\fancypagestyle{main}
\fancyhf{}
\renewcommand{\headrulewidth}{0.4pt}
\fancyhead[LO]{\slshape \rightmark}
\fancyhead[RE]{\slshape \uppercase{\chaptername \xspace \thechapter}. \leftmark}
\fancyfoot[LE,RO]{\thepage}
}
And I call \pagestyle{main} at the beginning of my text.

Now, there's no interaction between plain and customstyle, their headers look just as I wanted.

Weird effect, I had to rename the second style to "main". If I keep "fancy", the compiler gets stuck ...
Post Reply