3

I like books where the page numbers sit in the outer margins. I'm trying to reproduce this for my thesis in memoir class.

I have attempted it (see MWE) but it's a terrible approach - I used \hspace which breaks once the figure numbers go to two or three digits (see all the images of this code compiled).

Second issue: I can't get the odd numbered page numbers to sit outside the margin at all.

I want a smarter method as this manual approach will probably always fail - e.g. due to chapter or section title lengths changing and that sort of thing.

Any better ideas?

Below is MWE of what I've tried and some images.

\documentclass[12pt, openright]{memoir}

\usepackage{lipsum}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

%% Make headers what I want (don't say Chapter 1 chap 1 etc)
\createmark{chapter}{left}{nonumber}{}{\hspace{3mm}}
\createmark{section}{right}{shownumber}{}{\hspace{3mm}}

%% new page style
\makepagestyle{myvf} 
\pagestyle{myvf}

%% line to show where page actually ends
\makeheadrule{myvf}{\textwidth}{\normalrulethickness} 

%% attempt at header where page number exists in the margin - alternating left and right 
\makeevenhead{myvf}{\hspace{-27pt} \textbf{\thepage} \quad \leftmark}{}{} 
\makeoddhead{myvf}{}{}{\rightmark \hspace{18pt} \textbf{\thepage}}

\begin{document}

\chapter{Chap 1}

\section{sec 1}
\lipsum[1-150]\lipsum[1-150]\lipsum[1-150]

\section{sec 2}

\end{document}

What I want all pages to look like

Broken odd page

Broken high number page

3

Here is an easy code. All even page numbers end at the same distance from the left margin, all odd page numbers start at the same distance from the right margin.

\documentclass[12pt, openright]{memoir}

\usepackage{lipsum}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}

%% Make headers what I want (don't say Chapter 1 chap 1 etc)
\createmark{chapter}{left}{nonumber}{}{\hspace{3mm}}
\createmark{section}{right}{shownumber}{}{\hspace{3mm}}

%% new page style
\makepagestyle{myvf}
\pagestyle{myvf}

%% line to show where page actually ends
\makeheadrule{myvf}{\textwidth}{\normalrulethickness}

%% attempt at header where page number exists in the margin - alternating left and right
\makeevenhead{myvf}{\llap{\textbf{\thepage}\hspace{2\marginparsep}}\leftmark}{}{}
\makeoddhead{myvf}{}{}{\rightmark\rlap{\hspace{2\marginparsep}\textbf{\thepage}}}

\begin{document}

\chapter{Chap 1}

\section{sec 1}
\lipsum[1-150]\lipsum[1-150]\lipsum[1-150]

\section{sec 2}

\end{document} 

enter image description here

  • Why the <space> in \llap but none in \rlap? – Ruixi Zhang Aug 14 '18 at 15:55
  • It was there inadvertently. I removed it. Thanks for pointing it! – Bernard Aug 14 '18 at 16:00

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.