4

I want to position page numbers in my document in top-right corner. I managed to do so using fancyhdr (see below).

\usepackage{fancyhdr}
\hypersetup{%
    pdfborder = {0 0 0}
}
\renewcommand*{\headrulewidth}{0pt}
\fancyhf{}
\rhead{\thepage}
\pagestyle{fancy}

Everything works fine, except page number on the page where I have table of contents is centered at the bottom of that page.

Does anyone know how to fix that?

  • 1
    Welcome to TeX.sx! Your post was migrated here from another Stack Exchange site. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – jub0bs May 7 '13 at 15:11
  • 1
    Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – jub0bs May 7 '13 at 15:11
3

I believe you need to edit the plain settings. For example, adding the following to the preamble may help

\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead{} % clear all header fields
\fancyfoot{} % clear all footer fields
\fancyhead[RO]{\thepage}
\fancyhead[LE]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}

Note that in the fancyhdr documentation it says that

Some LaTeX commands, like \chapter, use the \thispagestyle command to automatically switch to the plain page style, thus ignoring the page style currently in effect. To customize even such pages you must redefine the plain pagestyle.

Therefore, this includes pages like the Table of Contents.

|improve this answer|||||
  • @marmelade You are most welcome! – azetina May 9 '13 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.