On normal pages I have header and no footer. On first chapter page -- I have footer (with page number) and no header. Hence I need:
\newgeometry{top=2cm, bottom=1.2cm, left=1.5cm, right=1.7cm}
for normal pages, and
\newgeometry{top=1.2cm, bottom=2cm, left=1.5cm, right=1.7cm}
for first chapter page.
In the book document class the first chapter page is of the plain page style. I thought I could do something like:
\usepackage[top=2cm, bottom=1.2cm, left=1.5cm, right=1.7cm]{geometry}
\newcommand\pagewithheader{
\newgeometry{top=2cm, bottom=1.2cm, left=1.5cm, right=1.7cm}
\renewcommand{\headrulewidth}{0.6pt}
}
\newcommand\pagewithfooter{
\newgeometry{top=1.2cm, bottom=1cm, left=1.5cm, right=1.7cm}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
\fancyfoot[C]{\thepage}
}
\usepackage{afterpage}
\fancypagestyle{plain}{
\pagewithfooter
\afterpage{\pagewithheader}
}
But I get all links messed up and floats gone mad. I tried to build an MWE:
\documentclass[a5paper,twoside]{book}
\usepackage{fontspec} % enagles loading of OpenType fonts
\usepackage{polyglossia} % support for languages
% fonts:
\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text} % without this XeLaTeX won't turn "--" into dashes
\setmainfont{Arial}
\setsansfont{Arial}
\setmonofont{DejaVu Sans Mono}
\usepackage{kantlipsum}
\usepackage[top=2cm, bottom=1.2cm, left=1.5cm, right=1.7cm]{geometry}
\newcommand\pagewithheader{
\newgeometry{top=2cm, bottom=1.2cm, left=1.5cm, right=1.7cm}
\renewcommand{\headrulewidth}{0.6pt}
}
\newcommand\pagewithfooter{
\newgeometry{top=1.2cm, bottom=1cm, left=1.5cm, right=1.7cm}
\renewcommand{\headrulewidth}{0pt}
\fancyhf{}
\fancyfoot[C]{\thepage}
}
\usepackage{fancyhdr}
% page style for a non-chapter pages:
\renewcommand{\rightmark}[1]{\markboth{#1}{}}
\renewcommand{\leftmark}[1]{\chaptername{}\thechapter}
\fancyhf{}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\rightmark}
\fancyhead[LE,RO]{\thepage}
\pagestyle{fancy}
\usepackage{afterpage}
\fancypagestyle{plain}{
\pagewithfooter
\afterpage{\pagewithheader}
}
\begin{document}
\chapter{foo}
\kant[1-12]
\chapter{bar}
\kant[1-12]
\chapter{baz}
\kant[1-12]
\end{document}
But unforunetly it works. While I have a complex document with tens of links and floats -- and it doesn't (I think because of floats).
What could it be? Perhaps somebody have a recipe to make the first chapter page to be of different geometry.