Hello,
I'm typesetting a book and there's a page layout question that I'm unable to find out how to implement. I've been modifying certain commands and environments of the book class in order to set a header rule length different from the default size (which is a length equal to \textwidth and a thickness (actually named by LaTeX as "width")). I have tried almost every aspect of fancyhdr.sty (headoffset, headrule, etc.) but I cannot get what this fake images illustrate
Left-odd page:
Right-even page:
Note that I use a symmetrical (sidemargin from odd to even differs) twoside layout.
I'd appreciate some help.
Thanks ppl.
Page Layout ⇒ Modify header rule length and maintain consistency
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Modify header rule length and maintain consistency
Actually the fancyhdr package offers all the resources to get this work. The inner offset of the head rule has to be shortened by half of the text width. A possible solution is shown below.
Note that the reduction of the head width lets you no more place any contents in the inner header of the pages.
Best regards and welcome to the board
Thorsten
Code: Select all
Code, edit and compile here:
\documentclass[11pt,a4paper,english]{book}\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}\usepackage{babel}\usepackage{fancyhdr}\usepackage{blindtext}\usepackage{arev}\usepackage{microtype}\fancyhf{}\fancyhead[LE,RO]{\bfseries\thepage}\fancyhead[LE]{\small Author Name}\fancyhead[RO]{\small Compilation Title}\fancyfoot[LE,RO]{\thepage}\renewcommand{\headrulewidth}{0.5pt}\renewcommand{\footrulewidth}{0pt}\fancyheadoffset[RE,LO]{-0.5\textwidth}\pagestyle{fancy}\begin{document}\Blinddocument\end{document}
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Modify header rule length and maintain consistency
I tried different ways to use the \textwidth parameter, but not this... (imho, it is sometimes confusing to use certain parameters inside commands correctly).
Thanks localghost.
Thanks localghost.