5

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?

9
  • 2
    In the main LaTeX document classes that recognize a \chapter command, the first page of each chapter is given page style plain automatically, even if a different page style is in effect for "ordinary" pages. Do you use a package such as fancyhdr to create your custom "fancy" page style? If so, you could try issuing the command \thispagestyle{fancy} immediately after each \chapter directive.
    – Mico
    May 18, 2013 at 3:47
  • 1
    change the plain format May 18, 2013 at 4:40
  • 1
    In that case, please edit your posting to provide a complete MWE. In particular, please indicate which document class you use and how you set up the look of the pages using fancyhdr.
    – Mico
    May 18, 2013 at 4:46
  • 1
    Sorry for the jargon -- MWE is short for minimum working example. Please indicate how you use the machinery of the fancyhdr package. The page style myheadings is provided by the document class. Incidentally, did you try the command \thispagestyle{myheadings} on the pages with chapter headings?
    – Mico
    May 18, 2013 at 5:05
  • 2
    Related: How to remove page numbers from first page of chapters
    – Werner
    May 18, 2013 at 7:09

1 Answer 1

6

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 fancyhdr you can either use the default fancy page 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 titleps is 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 titleps use

    \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.

1
  • 2
    This is a really great answer to a frequent question. May 18, 2013 at 7:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .