fancyhdr
我想在奇数页和偶数页中设置不同的包,headheight
我是否尝试过
\setlength{\headheight}{\ifthenelse{\isodd{\value{page}}}{.5cm}{3cm}}
但它不起作用。
答案1
这是一个解决方案
\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}
我认为更好的办法是:也改变文本高度
\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}