I use two pagestyles fancy
for the default header and plain
for headers on chapter pages. These headers should have completely different heights, however, it looks like latex adjusts both header heights to the maximum and tries to keep header height constant throughout the whole document. Why is that, and how can I disable this "feature"?
\documentclass[a4paper]{book}
\usepackage[includeheadfoot,top=0cm,headheight=16pt,headsep=3cm]{geometry}
\usepackage{color}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[L]{%
\textcolor{black}{\llap{%
\colorbox{yellow}{\makebox[\textwidth][r]{\thepage}}}}}
\fancyhead[L]{%
\textcolor{black}{\rlap{%
\colorbox{yellow}{\leftmark}}}}
\fancypagestyle{plain}{%
\fancyhead{}%
\fancyhead[R]{%
\textcolor{black}{\rlap{%
\hspace{-9\marginparsep}%
\setlength{\fboxsep}{14pt}
\colorbox{yellow}{%
\makebox(23,93)[cb]{\Huge\textbf{\thechapter.}}}%
}}}}
\begin{document}
\chapter{foo}
text
\newpage
\section{bar}
text
\end{document}
Best Answer
Since pagestyle
plain
is used for more than just the first page in a chapter, you are better off overlaying a header directly. Tikz is one option. Everypage is another (\AddThispageHook
). You could create a\mychapter
macro to simplify the code.Here is a solution using everypage. The "cursor" is located at (1in,-1in) relative to the upper left corner and must not be moved.