[Tex/LaTex] Top right side page numbering

fancyhdrheader-footerpage-numbering

I want the numbers of pages to be placed at the top right side.
I try to do it like this

\documentclass[12pt]{article}

\usepackage{fancyhdr}

\begin{document}
\lhead{}
\chead{}
\rhead{\thepage}
\lfoot{}
\cfoot{}
\rfoot{}

My text.

\end{document}

Numbers still remains like default – center of bottom. What do I wrong?

Best Answer

The "fancy" settings are enforced only when \pagestyle{fancy} is issued:

\documentclass[12pt]{article}

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

\begin{document}

My text.

\end{document}

I've used the "modern" commands provided by fancyhdr, which are more flexible; with \fancyhf{} you void all fields at once and then you can fill them again as you wish.