TransWikia.com

Pagenumber in the side margin

TeX - LaTeX Asked by jamesmaj on December 27, 2020

Trying to recreate this style in latex https://i.imgur.com/XK8iIoU.png

I want to know how/if it’s possible to put the page numbers in the side margins? I’ve looked through fancyhdr, but it seems I can’t access the margins (only the header/footer).

One Answer

You can put arbitrary code into the fancyhead definitions. Here is an example which puts page numbers approximately to the middle of outer margins (for the book document class).

documentclass[a5paper]{book}
usepackage{showframe}
usepackage{lipsum}
usepackage{fancyhdr}
fancyhead[RO]{%
  vbox to0pt{%
    vskip0.5headheight
    vskipheadsep
    vskip0.5textheight
    hbox totextwidth{%
      hskiptextwidth
      hskipmarginparsep
      thepage
      hss
    }%
  vss
  }%
}
fancyhead[LE]{%
  vbox to0pt{%
    vskip0.5headheight
    vskipheadsep
    vskip0.5textheight
    hbox totextwidth{%
      hss
      thepage
      hskiptextwidth
      hskipmarginparsep
    }%
  vss
  }%
}
fancyfoot{}
pagestyle{fancy}
begin{document}
  lipsum
end{document}

enter image description here

Correct answer by Sergei Golovan on December 27, 2020

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