TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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.

share|improve this question

migrated from superuser.com Feb 1 '11 at 18:04

This question came from our site for computer enthusiasts and power users.

The first page of a chapter uses the plain pagestyle, even if some other style has been selected. You can fix this by adding \thispagestyle{fancy} after each \chapter{} command.

The blank space at the top of the first page of the chapter is part of the standard chapter style. You can use the fncychap package to create your own style (or use one of the packaged styles).

Update: For special chapters generated by command (e.g., \tableofcontents) which span more than one page, adding \thispagestyle{fancy} won't work. A more general solution is to add the following in your preamble:

share|improve this answer
Great! Using "\thispagestyle{fancy}" (not "\thispagestyle{fancyhdr}") I could indeed fix this for all normal chapters and for the special chapter title "List of Tables". 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)? – anton May 8 '10 at 5:29
Sorry. I fixed the error, and added a comment about these special chapters. – Rob Hyndman May 8 '10 at 10:07
Thank you Rob for looking into this. However 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). – anton May 9 '10 at 10:49

If I understand the question correect, the only problem is that the plain pagestyle was not defined in fancyhdr. so all you have to do is

From the manual

\fancyhf{} % clear all header and footer fields
\fancyhead[RO,RE]{\thepage} %RO=right odd, RE=right even

Note that there are three pagestyles.

empty: Is used for pages such as titlepages.

plain: Is used for chapter starts which includes the start of lists such as \tableofcontens and \listoffigures

fancy: For normal text pages

Also besides fancyhdr there are other pages such as scrpage2 that allow the manipulation of pagestyles.

share|improve this answer
It is worth noting that you can create page style with any name using syntax in this answer and then use \thispagestyle{styleforchapters} at the start of each chapter. – Rafal Nov 6 '14 at 13:55
The above code gives all the page numbers top right. Great. How if want the page numbers on bottom right? Appreciate any help. I am looking for this solution very badly now. – Vijay Sep 16 '15 at 4:03

It is easy to modify the pagestyle for regular and special chapters such as your table of contents. Chapters normally override the current pagestyle, setting it to plain. fancyhdr provides a command \fancypagestyle to redefine other pagestyles, and in this manner you can get the style you want on chapter pages by simply redefining the plain style as follows:


This is explained in section 7 of the fancyhdr documentation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.