[Tex/LaTex] page numbers at top right

header-footerpage-numbering

I've got a simple question, I think. But I can't seem to find the answer to it anywhere. I want page numbers at the top right of each page of my document. How do I do this?

I tried doing:

\documentclass[12pt]{article}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\thepage}

\begin{document}

My text.

\end{document}

While this did result in page numbers being at the top right, I don't like the horizontal lines across the top of each page that this produces.

Best Answer

Use \renewcommand{\headrulewidth}{0pt} for example to set the head rule with to zero -- it won't appear then. The same can be applied to \footrulewidth, if necessary.

\documentclass[12pt]{article}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyhead[R]{\thepage}

\begin{document}

My text.

\end{document}

enter image description here

Related Question