# Custom Page Numbering in LyX (for thesis requirement)

I would like to place the page number in the top right corner of my page (inside the margin). My margins are 1 inch from the top and 1 inch from the right. I can put page numbers in the upper right corner by using a horizontal fill, but I would like the page number to be as close to my margin as possible. When I print out the document it is over 1.5 inches from the top of the page. How can I make the number appear higher in the page?

MWE My source code for the following LyX screen and pdf is

\begin{center}
\newpage{}\hfill{}\hfill{}1\thispagestyle{empty}\vspace{1in}
\par\end{center}
\section{\noindent {\normalsize{INTRODUCTION}}}


My LyX screen is

And my PDF is

• You might want to have a look at \frontmatter, \mainmatter, and friends. – Sean Allred Apr 29 '14 at 3:55
• Pages that should have their numbers not typed (title, copyright, dedication?) would generally use \thispagestyle{empty} to remove the numbers. They would still increment the count, however, which seems to be as desired. – cslstr Apr 29 '14 at 4:34
• @cslstr if I insert that in my Latex preamble, how will it know which page numbers to hide? – The Substitute Apr 29 '14 at 4:47
• @TheSubstitute: Insert the command at the places of the corresponding pages, not in the preamble. You have to do this multiple times, at all positions/pages you don't want to have visually numbered. – user31729 Apr 29 '14 at 4:55
• thank you, this takes care of the pages that I don't want to have visible numbers. – The Substitute Apr 29 '14 at 5:05

In Page Margins set margins to 1 in. (you may need to adjust to get it exactly right). In Page Layout set headings style to default. In Preamble

\pagestyle{myheadings}
\markboth{}{}


Add a thin space and a vertical space if you want the introduction to be a little down.

Page numbers should appear at right edge, starting at 1 on first page.

After that, I believe you can put a

\pagestyle{empty}


or otherwise, to remove the page numbers...

% Preview source code

%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\markboth{}{}
\usepackage{lipsum}

\makeatother

\usepackage{babel}
\begin{document}
~ \vspace{3in}

\section{Introduction}

\lipsum

\lipsum
\pagestyle{empty}
\lipsum
\end{document}