TransWikia.com

Putting page numbers in left/right margin in Memoir class

TeX - LaTeX Asked by TiMauzi on February 9, 2021

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?

One Answer

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.7baselineskip){textbf{thepage}}}end{picture}%
}

%% attempt at header where page number exists in the margin - alternating left and right
makeevenhead{myvf}{llap{shiftpagehspace{2marginparsep}}leftmark}{}{}
makeoddhead{myvf}{}{}{rightmarkrlap{hspace{2marginparsep}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.

Answered by Peter Wilson on February 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP