I need to put the number for each page that is numbered at the top right hand corner of the document. Currently that condition is satisfied except for the first page of each chapter. That is, for the page that contains the title of the chapter the number is at the bottom (center) of the page. Can anyone help with this?
1 Answers
By default the first page of each \chapter is set using the plain page style under the basic book and report document classes. To see why this is the case, consider the \chapter macro:
\newcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
\thispagestyle{plain}%
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter}
Note the setting of \thispagestyle{plain}. If you wish to change that, you can either create a new page style and update plain.
Creating a new style:
Using
fancyhdryou can either use the defaultfancypage style or create your own. Here's how to create your own:\fancypagestyle{main}{ \fancyhf{}% Clear all headers/footers \fancyhead[R]{\thepage}% Page in Right header \renewcommand{\headrulewidth}{0.4pt}% Header rule \renewcommand{\footrulewidth}{0pt}% No footer rule }The usage with something like
titlepsis similar:\newpagestyle{main}{ \sethead{}% Left header {}% Centre header {\thepage}% Right header \setfoot{}{}{}% Clear footer \setheadrule{.4pt}% Header rule \setfootrule{0pt}% Not footer rule }Now you either insert this style on the chapter pages manually using
\chapter{My chapter} \thispagestyle{main}or you update this through a patch to be implemented globally. Here's a patch using
etoolbox(place this in your document preamble):\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox \patchcmd{\chapter}% <cmd> {plain}% <search> {main}% <replace> {}{}% <success><failure>Update
plain:This is similar to the above solutions. For
fancyhdr, use\fancypagestyle{plain}{% % your new plain settings }For
titlepsuse\renewpagestyle{plain}{% % your new plain settings }
The above changes slightly if you're using a two-side document setup. However, it changes drastically if you're using another document class.
- 603,163
\chaptercommand, the first page of each chapter is given page styleplainautomatically, even if a different page style is in effect for "ordinary" pages. Do you use a package such asfancyhdrto create your custom "fancy" page style? If so, you could try issuing the command\thispagestyle{fancy}immediately after each\chapterdirective. – Mico May 18 '13 at 03:47fancyhdr. – Mico May 18 '13 at 04:46fancyhdrpackage. The page stylemyheadingsis provided by the document class. Incidentally, did you try the command\thispagestyle{myheadings}on the pages with chapter headings? – Mico May 18 '13 at 05:05