0

A very similar issue has been asked quite a while ago. Although, my goal is not to put the page numbers in the header, but in the side margin. I am using the twoside and a5paper options in LaTeX Memoir.

Is there a similar approach to that one mentioned as an answer to the linked issue? I found a solution using TikZ here, but is there a way of achieving this directly by using Memoir?

1

I have modified the answer that you refer to.

% pagenumberprob.tex SE 561745   --- a modification of the answer to SE 446031
\documentclass[a5paper,twoside]{memoir}
\usepackage{picture}

\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}

% use a zero sized picture to place the page number
\newcommand{\shiftpage}{%
  \begin{picture}(0,0){\put(0,-2.7\baselineskip){\textbf{\thepage}}}\end{picture}%
}

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

\begin{document}

\chapter{Chap 1}

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

\section{sec 2}

\end{document} 

You may want to adjust the location of the page numbers and their font.

2
  • That worked perfectly! So I assume there is not really a good way to do it without using a picture to move the number around? Then this idea is actually quite similar to the TikZ solution linked above, right? – TiMauzi Sep 7 '20 at 20:26
  • @TiMauzi A zero sized picture is a good way to put things where you want them to be. – Peter Wilson Sep 8 '20 at 17:40

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.