[Tex/LaTex] Memoir Page Layout doesn’t work as expected: Text shifted right

marginsmemoir

I'm trying to setup the layout as a one-sided A4 page, with 2.5 cm equal left & right margins. Since the width of A4 is 21cm, then I'm trying to do this with the following 2 steps:

  1. Set the typeblock size to 16cm (using \settypeblocksize{20cm}{16cm}{*})
  2. Set equal L & R margins (using \setlrmargins{*}{*}{*})

I tried several other combination, but it doesn't work as expected; I'm getting very narrow right margin with most of the margin at the left.

So why doesn't the text get centered between 2 equal left & right margin?

Here is the full code, the output screenshot is attached:

% Preview source code

%% LyX 1.6.7 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[a4paper,oneside,english,oldfontcommands,article]{memoir}
\usepackage{mathptmx}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.

\newcommand{\code}[1]{\texttt{#1}}

\special{papersize=\the\paperwidth,\the\paperheight}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\settypeblocksize{20cm}{16cm}{*}
%Memoir: Set L & R margins around the type block:
%\setlrmargins{0cm}{0cm}{*}
%\settrims{0pt}{0pt}

 \setlrmargins{*}{*}{*} %equal L & R margins ( = 2.5cm)

\makeatother

\usepackage{babel}

\begin{document}

\chapter{Page Dimentions}
\begin{description}
\item [{\code{\textbackslash{}stockheight}}] \the\stockheight
\item [{\code{\textbackslash{}stockwidth}}] \the\stockwidth
\item [{\code{\textbackslash{}paperheight}}] \the\paperheight
\item [{\code{\textbackslash{}paperwidth}}] \the\paperwidth
\item [{\code{\textbackslash{}textheight}}] \the\textheight
\item [{\code{\textbackslash{}textwidth}}] \the\textwidth
\item [{\code{\textbackslash{}trimtop }}] \the\trimtop
\item [{\code{\textbackslash{}trimedge}}] \the\trimedge
\item [{\code{\textbackslash{}spinemargin}}] \the\spinemargin
\item [{\code{\textbackslash{}marginparsep}}] \the\marginparsep
\item [{\code{\textbackslash{}marginparwidth}}] \the\marginparwidth
\end{description}

\chapter{Example Paragraph}

This is an example paragraph. This is an example paragraph. This is
an example paragraph. This is an example paragraph. This is an example
paragraph. This is an example paragraph. This is an example paragraph.
This is an example paragraph. This is an example paragraph. This is
an example paragraph. This is an example paragraph. This is an example
paragraph. This is an example paragraph. This is an example paragraph.
This is an example paragraph. 
\end{document}

output page

Best Answer

You need to add

\checkandfixthelayout

after you have set all your dimensions.