0

With the fancyhdr package I would like to set different headheight in odd and even pages, do I tried with

\setlength{\headheight}{\ifthenelse{\isodd{\value{page}}}{.5cm}{3cm}}

but it didn't work.

4
  • what about textheight?
    – touhami
    Oct 2, 2016 at 13:27
  • doesn't work better
    – math45
    Oct 2, 2016 at 14:06
  • 1
    Your text has to begin at the same height on the physical page, I suppose?
    – Bernard
    Oct 2, 2016 at 14:15
  • what i mean is that the body text will be pushed down in odd pages so you need to change the text height (this is same as what Bernard points)
    – touhami
    Oct 2, 2016 at 15:53

1 Answer 1

2

Here is a solution

\documentclass{book}

%--- just for the example
\textheight=20\baselineskip
\markboth{My headings}{Bla bla}
\usepackage{mwe}
%---

\usepackage{etoolbox}
\makeatletter
\patchcmd\@outputpage{\headheight}{\ifodd\count\z@ 0.5cm\else 3cm\fi}{}{}
\makeatother

\begin{document}
\lipsum[1-20]
\end{document}

enter image description here


What i think better: change textheight too

\documentclass{book}

%--- just for the example
\textheight=20\baselineskip
\markboth{My headings}{Bla bla}
\usepackage{mwe}
%---

\usepackage{etoolbox}
\makeatletter
\patchcmd\@outputpage{\headheight}{\ifodd\count\z@ 0.5cm\else 3cm\fi}{}{}
\patchcmd\@outputpage{\global\@colht\textheight}{\global\advance\textheight by\ifodd\count\z@ -2.5cm\else 2.5cm\fi\global\@colht\textheight}{}{}
\makeatother

\begin{document}
\lipsum[1-20]
\end{document}

enter image description here

1
  • one can change \topmargin to avoid changing \textheight
    – touhami
    Oct 2, 2016 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .