# Exact positioning of page numbers at the top of each page

Good day everyone. I need some help on my report. My professor requires me to place page number on each page at exactly 1.25 inch from the top on the right side of the paper. Hope you can help me. Below is my sample code.

  \documentclass[12pt,a4paper]{report}
\usepackage{fancyhdr}
\usepackage{lipsum}

\fancyhf{}
\pagestyle{fancy}

\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
}

\begin{document}

\chapter{Introduction}
\lipsum

\chapter{Review}
\lipsum

\end{document}

-
1.25 inch is the bottom 'line' of your page number, so that the foot of the number is placed one that 'line' or is the page number top aligned to that 1.25in top margin? And I suppose that the page number should only the right side if is on a page with odd number, i.e. a recto page and on the left side, if it is a verso page? –  SoundsOfSilence Jul 9 '14 at 15:19

The \topmargin length is what you're likely looking for. See Page Layout in the LaTeX Wikibook, or the following for more options:

\documentclass[12pt,a4paper]{report}
\usepackage{fancyhdr}
\usepackage{layout}

\setlength{\topmargin}{0.25in}

\fancyhf{}
\pagestyle{fancy}
\fancypagestyle{plain}
\fancyhf{} % clear all header and footer fields

\begin{document}

\layout{}

\end{document}


-
Just too close, the page number is about 1.35 inch from the top when I tried to print it on an A4-sized paper. I changed the length of the top margin from 0.25 to 0.15, and I got the correct format. Thanks a lot buddy. –  olivarries Jul 10 '14 at 3:24

I suggest usage of the geometry package, with tmargin=1.25in option.

\documentclass[12pt,a4paper]{report}
\usepackage[showframe=true,tmargin=1.25in]{geometry}
\usepackage{fancyhdr}
\usepackage{lipsum}

\fancyhf{}

\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
}

\pagestyle{fancy}

\begin{document}

\chapter{Introduction}
\lipsum

\chapter{Review}
\lipsum

\end{document}


The lines are introduced by the showframe=true option, just for checking.

-
I used this and printed a page on an A4 paper. However, the page number is just at 0.85 from the top. –  olivarries Jul 10 '14 at 3:08
I printed it too and the bottom of the figure was about 1.14in from the top, which is not 1.25in, that is true. The top of the figure was about 1in from the top paper edge. –  SoundsOfSilence Jul 10 '14 at 4:31

This solution also uses the geometry package, but takes into account the depth of descenders in the current font. If you want the baseline of page numbers to be exactly at 1.25in from the top of the papersheet, you add these lines to your preamble:

\newlength{\adjustd}


The following snapshot shows why descenders must be taken into account (geometry loaded with option showframe):

If it's the top of page numbers that you want to be at 1.25in, you have to add two more lines:

\newlength{\adjusta}


For uppercase figures, 0 will be enough.

and replace last line above with:

\usepackage[top=\dimexpr 1.25in +\headsep + \adjustd + \adjusta \relax]{geometry}


Of course, if your page numbers use oldstyle figures, 1.25 will be the distance from highest figures (5 and 8) to the top of the sheet, and figures with descenders (3, 4, 5, 7 and 9) should be taken into account in the definition of \adjd. If you want that the top of figures without ascenders be at 1.25in, replace the definition of \adjusta with

\settoheight\adjusta{01234579}.

-
I wonder a little bit about the descenders with figures. Is it necessary for 'usual' page number figures to regard descenders (I agree with some kind of calligraphic figures, oldstyle figures, there might be descenders), but perhaps you could provide a screen shot where such descenders occur? –  SoundsOfSilence Jul 9 '14 at 18:32
@ Christian Hupfer: Actually there are two problems, and I don't know which you refer to: 1. In any case, simply choosing top=1.25in + headsep will make the baseline of ordinary figures not be at 1.25in of the top of the sheet, but a little less, because headheight takes into account descenders, hnce the 1st solution. I'll include a screenshot that shows this. 2. The case of old style figures for page numbering has been taken into account to be as complete as possible. I agree with you: usual academic work does not use them. –  Bernard Jul 9 '14 at 18:48
Thanks for the quick reply. I noted that 'slight' vertical offset in my version too, now I know why, since you explained it. And regarding the second aspect: I was just curious and did not want to criticize you. I agree with you, that style of figures other than 'usual' page number style will occure rarely in papers or in a thesis. –  SoundsOfSilence Jul 9 '14 at 19:37