I am working on a long document in LaTeX with documentclass book.
I need the page number to always be in the upper right corner of each page, even if that page is the first page of a chapter (right now on 1st pages of chapters, the page number is bottom-centered, on all other pages it's top-right).
I control the position of the page number with fancyhdr:
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{\thepage}
\lfoot{}
\cfoot{}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
Also, I don't know if the problem is related but my chapters do not start from the top of the page. There is a white area, then comes chapter X, then a newline with the chapter line. What I also want is the chapter to start from the top of the page.
The main question here is how I can get the page number to always appear in the upper right corner, I mention the thing with the chapter title position only in case that might be related.



However, for the special chapter titles "Contents", "List of Figures", "References" and "Index" it does not work, these chapters stretch over multiple pages and on the first page the page number is still positioned bottom-centered.
Do you also know how to deal with these cases? (Contents, List of Figures and so on)?
– May 08 '10 at 05:29However when I added your code (from \makeatletter until \makeatother), there is absolutely no change at all.
I am using "\usepackage{fancyhdr}" with that code, and the document compiles successfully (but no change in the layout).
– May 09 '10 at 10:49