[Tex/LaTex] Setting different recto/verso margins size (geometry) on this example

double-sidedgeometrymargins


CONTEXT.

Because of specific University requirements (1), I had to use this nice code found on tex.stackexchange https://tex.stackexchange.com/a/96366/50507 written by David Carlisle, that was fitting perfectly with my needs so far.

(1) The requirements are listed on that question, please follow the link, I don't want to make a duplicate. It also explains the oneside document article.

Therefore, given the linked code, let's consider it as my Minimum Working Example :

\documentclass[oneside]{article}
\usepackage{caption}
\def\a{One two three four \stepcounter{enumi}\roman{enumi} five six. }
\def\b{\a\a\par\a\a\a Red green blue yellow black white. }
\def\c{\b\b\par\b\b\b\b\b\par\b\b\b\par\b\b\b\par\b}
\makeatletter
\def\@oddhead{ODD PAGE\hfill\thepage}

\long\def\grabfirst#1#2\@@{\toks@{#2}\xdef\insertlist{\the\toks@}#1}
\let\old@outputpage\@outputpage
\def\@outputpage{%
\ifx\insertlist\@empty
\shipout\vbox to\@colht {\vss}%
\else
\begingroup
\setbox\@outputbox\vbox to\@colht {%
\expandafter\grabfirst\insertlist\@@
}%
\def\@oddhead{\thepage(x)  \hfill EVEN PAGE}
\old@outputpage
\addtocounter{page}{-1}%
\endgroup
\fi
\old@outputpage}

\gdef\insertlist{}
\long\def\insertpic#1{\g@addto@macro\insertlist{{#1}}}

\makeatother
\begin{document}

\c
\insertpic{%
\rule{1cm}{2cm}
\captionof{figure}{a picture}}
\c
\begin{figure}[t]
this\\
is\\
a\\
t figure

\caption{zzz}
\end{figure}

\c
\begin{figure}[p]
this\\
is\\
a\\
p figure

\caption{zzz}
\end{figure}

\c
\insertpic{%
\rule{1cm}{1cm}
\captionof{figure}{a picture}}

\c
\end{document}

THE PROBLEM.

My aim is to set up different margins on recto pages and verso pages, for example :

  • on recto : left = 3cm, right = 3cm, top = 3cm, bottom = 3cm (let's say it's the default, given on the full report, except on verso when they occur)
  • on verso only (when they occur): left = 2cm, right = 2cm, top = 1.5cm, bottom = 1.5cm

The problem is that some of the pictures (and tables) are too wide for the global margin used for the entire code, thus for the verso as well.


MY QUESTION.

I don't see how I can modify the margins geometry of one side (verso) without modifying the other side (recto) and not breaking the given code. I would be most grateful if you could help me with that.


ADDITIONAL NOTE.

Please note that it was not the nature of my question – my first question was simply to use different geometry on recto and verso – the linked solution worked very fine for me so far except for these margins.

However if there is no way to set up different margin on recto and verso with this code, I would be most grateful if you could propose another solution with the same numbering requirements.

SUGGESTIONS regarding the question format?

As I didn't received any answers yet, should you have any suggestion to help me presenting better the issue
that I am facing, so that I could get more easily a solution, please
do not hesitate to let me know in comments. Shall I propose another bounty ? What should I do to find some hints about that topic ? Thank you again for your
attention.

Best Answer

One can do this by setting margin for (recto) odd pages using geometry, for example

\usepackage[margin={3cm,4cm}]{geometry}

or

\usepackage[margin=3cm,includeheadfoot]{geometry}

and then change localy the settings of (verso) even pages by

\def\@outputpage{%
\ifx\insertlist\@empty
\shipout\vbox to\@colht {\vss}%
\else
\begingroup
\addtolength{\oddsidemargin}{-1cm}
\addtolength{\topmargin}{-1.5cm}
\addtolength{\textwidth}{2cm}
\addtolength{\@colht}{3cm}
\setbox\@outputbox\vbox to\@colht {%
\expandafter\grabfirst\insertlist\@@
}%
\def\@oddhead{\thepage(x)  \hfill EVEN PAGE}
\old@outputpage
\addtocounter{page}{-1}%
\endgroup
\fi
\old@outputpage}