2

My question

I am trying to have a precise control on the size and on the content of the header and footer of the pages, with different configurations:

  • if the page the first page
  • on odd pages
  • on even pages

What are the best ways to handle this question?

A picture

Approximately, the document I want to create will look like this

enter image description here

What I've tried

So far, I've tried to do

\documentclass{article}

\usepackage{geometry}
\usepackage{changepage}
\usepackage{bophook}

\begin{document}

\AtBeginPage{%
\strictpagecheck
\ifnum\value{page}>1
    \ifoddpage
      \newgeometry{top=0.5cm, bottom=3cm}
    \else
      \newgeometry{top=3cm, bottom=0.5cm}
    \fi
\else
\fi
}

Test \newpage
Test 2 \newpage
Test 3
\end{document}

but as said there, in the comments, this approach is doomed to fail.


Post scriptum

In case it can help, here are some pieces of code I use for my document . This is not part of my question, only if it can help!

Dimensions of the pages and of the footer

I don't really understand the following code but have tested it and it's ok for me. Any comment is welcomed!

%%%%%%%%%%
% Layout %
%%%%%%%%%%
\def\myHMargin{2cm}
\def\myVMargin{2cm}
\def\myFootskipMargin{1.5cm}
\usepackage[hmargin={\myHMargin,\myHMargin},
            vmargin={\myVMargin,\dimexpr(\myVMargin - \myFootskipMargin/2)},
            includeheadfoot,
            headsep=0pt,
            footskip=\myFootskipMargin]{geometry}

The style of footer

%%%%%%%%%%%%%%%%%%%%%
% Footer
%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{lastpage}
\RequirePackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{0cm}
\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0.4pt}%
\lhead{}
\chead{}
\rhead{}
\cfoot{}
\lfoot{{\footnotesize EXAMPLE}}
\rfoot{{\footnotesize  \mbox{}\hfill \thepage /\pageref{LastPage}}}%
  • 2
    your question isn't very clear, why can't you just use the O an dE options in fancydr ? – David Carlisle Sep 8 '18 at 14:51
  • 1
    As @DavidCarlisle said, with one caveat: It looks like you want an empty footer on even pages and an empty header on odd pages, but the fancyhdr package doesn't have any immediate way to set the values of \headrulewidth and \footrulewidth depending on whether the page number is even or odd. Section 13 (p. 15) in the documentation gives a hint, though: It seems okay to use a conditional inside the definition of these macros … So hang on, let me experiment a little … – Harald Hanche-Olsen Sep 8 '18 at 15:15
  • You could/should use the flowfram package for this. The header/footer can be implemented as a dynamic frame. – John Kormylo Sep 8 '18 at 15:27
2

Here is some proof-of-concept example. I did not try to duplicate your exact style, but I trust you may adapt these ideas to your document:

\documentclass[twoside]{article}
\usepackage{bophook,fancyhdr,lipsum}
\renewcommand\headrulewidth{\ifodd\count0 6pt \else 0pt \fi}
\renewcommand\footrulewidth{\ifodd\count0 0pt \else 6pt \fi}
\fancyhf{}
\fancyhf[ELF]{Even page}
\fancyhf[OLH]{Odd page}
\fancyhf[ERF,ORH]{Page \thepage}
\AtBeginPage{%
  \ifodd\count0 \global\voffset=0mm \else \global\voffset=25mm \fi
}

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

This solution uses the flowfram package.

It should be noted that static frames center the contents vertically, while dynamic frames align the tops.

Note: this is about the largest font you can use without \scalebox.

\documentclass[landscape]{article}
\usepackage[hmargin=2cm,vmargin=.5cm]{geometry}
\usepackage{flowfram}
\usepackage{lastpage}
\pagestyle{empty}
\usepackage{lipsum}% MWE only

\newlength{\colwidth}
\setlength{\colwidth}{\dimexpr \textwidth-2\columnsep}
\divide\colwidth by 3

\newstaticframe[1]{\textwidth}{2cm}{0pt}{\dimexpr \textheight-4.5cm}[title]
\begin{staticcontents*}{title}
\centering\Huge This is the title
\end{staticcontents*}

\newflowframe[1]{\colwidth}{\dimexpr \textheight-5cm}{0pt}{0pt}
\newflowframe[1]{\colwidth}{\dimexpr \textheight-5cm}{\dimexpr \colwidth+\columnsep}{0pt}
\newflowframe[1]{\colwidth}{\dimexpr \textheight-5cm}{\dimexpr 2\colwidth+2\columnsep}{0pt}

\newdynamicframe[even]{\textwidth}{2cm}{0pt}{\dimexpr \textheight-2cm}[header]
\begin{dynamiccontents*}{header}
\Huge\hfill\thepage/\pageref{LastPage}
\vfill\hrule height1pt
\end{dynamiccontents*}

\newflowframe[even]{\colwidth}{\dimexpr \textheight-2.5cm}{0pt}{0pt}
\newflowframe[even]{\colwidth}{\dimexpr \textheight-2.5cm}{\dimexpr \colwidth+\columnsep}{0pt}
\newflowframe[even]{\colwidth}{\dimexpr \textheight-2.5cm}{\dimexpr 2\colwidth+2\columnsep}{0pt}

\def\oddlist{3,5,7,9,11,13,15,17,19}% odd pages >1

\newdynamicframe[\oddlist]{\textwidth}{2cm}{0pt}{0pt}[footer]
\begin{dynamiccontents*}{footer}
\hrule height1pt\vfill
\Huge\hfill\thepage/\pageref{LastPage}
\end{dynamiccontents*}

\newflowframe[\oddlist]{\colwidth}{\dimexpr \textheight-2.5cm}{0pt}{2.5cm}
\newflowframe[\oddlist]{\colwidth}{\dimexpr \textheight-2.5cm}{\dimexpr \colwidth+\columnsep}{2.5cm}
\newflowframe[\oddlist]{\colwidth}{\dimexpr \textheight-2.5cm}{\dimexpr 2\colwidth+2\columnsep}{2.5cm}

\begin{document}
\sloppy% SOP for narrow columns
\lipsum[1-50]
\end{document}

four pages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.