[Tex/LaTex] Set different margins for even and odd pages

double-sidedmargins

I have a class file for my document where I have declared margins:

\setlrmarginsandblock{3.5cm}{2.5cm}{*}%

with the left one bigger. But I wanted odd pages to have a bigger left margin and even pages to have a bigger right margin. So I tried:

\checkoddpage 
  \ifoddpage
    \setlrmarginsandblock{3.5cm}{2.5cm}{*}%
  \else 
    \setlrmarginsandblock{2.5cm}{3.5cm}{*}%
  \fi

but it seems that it always returns true in a if statement.
How can I do it?

Best Answer

It looks as if you might be using the memoir document class, so here's an answer for that case.

\setlrmarginsandblock actually sets the margins as they would be on a recto or odd-numbered page in a document intended for two-sided printing. Thus left corresponds to the inner margin and right to the outer.

If you use the oneside class option, all pages will be laid out the same.

If you use the twoside option, then the recto pages will be laid out as you specify, and the verso (even) pages will be laid out with the margins reversed.

You should use \setlrmarginsandblock just once, in the preamble (before \begin{document}). Don't forget that you will also need to call \checkandfixthelayout to put your layout into effect.