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}



