[Tex/LaTex] How to set margins in memoir class

double-sidedmarginsmemoir

I'm having a hard time with the memoir margins. Honestly, I don't get how it works. In principle it should be fairly easy to get what I want:
3.5cm left, 2.5cm right, 2.5cm top, 2.5cm bottom. Two-sided layout.

I tried this (it's just a simplified version of my actual document, hope that works)

\documentclass[a4paper,12pt]{memoir}

\usepackage[a4paper]{geometry}
\geometry{
left=3.5cm,  
right=2.5cm,
top=2.5cm, bottom=2.5cm,
headheight=\baselineskip,
headsep=7mm,
footskip=7mm
}

\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[LO,RE]{\sffamily\itshape \leftmark}
\fancyfoot[C]{\thepage}
\pagestyle{fancy}

\usepackage{color}
\renewcommand{\headrulewidth}{2pt}
\renewcommand{\headrule}{\hbox to\headwidth{%
\color{black}\leaders\hrule height \headrulewidth\hfill}}

\usepackage{lipsum}

\begin{document}


\tableofcontents

\section{Introduction}
\lipsum[2-4]

\subsection{Material}
\lipsum[2-8]


\end{document}

Well, that did not work. The margins are just not set correctly. Looking into the memoir documentation I found these two commands:

\setulmargins{4cm}{*}{*}
\setlrmargins{1.25in}{*}{*}
\checkandfixthelayout

I guess I should get rid of the geometry block and use this instead. However, I'm doing something wrong.

Here are two images showing the kind of layout I want.
enter image description here
enter image description here
Any help is appreciated.

Best Answer

The main issue here is that memoir has two ways of setting margins. One where iøyou set the margins and let that dictate the text block. And one where you specify the text block and then place that on the paper. Sadly you got the latter one, should have used the first one, thus use

\setlrmarginsandblock{3.5cm}{2.5cm}{*}
\setulmarginsandblock{2.5cm}{*}{1}
\checkandfixthelayout 

Note that memoir adjusts the bottom margin such that the text height matches a whole number of lines (algorithm is adjustable)

Secondly, it is a very common mistake that pdf viewers include scaling when printing, thus in many cases, if you measure the printed margins, they are wrong. Switch off the scaling in the print setting and then try again.

Related Question