[Tex/LaTex] How to display page numbering on top of the page


I've been searching for quite some time now, but I can't seem to find an answer to my problem. This is how my page numbering commands are:


Now, the page numbers are showing up at the bottom of the page. I want them, however, to be on top of the page, in the header. Is there any way I can get this done? Thanks!

EDIT: I'm using the documentclass article and packages as seen below.



Best Answer

You can load fancyhdr. Commands for single sided documents were usually, for example (right head, left head, right foot, and so on):


Although apparently the last three showed here are now obsolete.

There are other styles besides fancy which is used here, like plain, but you can make up your own style. \fancyhf{} empties the head and foot so you can fill them with whatever you want.

The new syntax has the following commands:


\fancyhead is for the header, \fancyfoot is for the footer, pretty simple. The various letters are: L for the left side of the page, R for the right side, C for center, E for even pages and O for odd pages.

You can also add these commands for the lines:


You can enter whatever you want in the fields above, but you have some variables at your disposal so that nothing is hard-coded:

  • \thepage
    Page number.

  • \thechapter
    Number of current chapter.

  • \thesection
    Number of current section

  • \chaptername
    Adds the word "chapter" or the corresponding word if the document is in a different language.

  • \leftmark and \rightmark These add the top level and next-to-top level structure number and name (though it can be modified) for the current document class. For example, in article it would be section and subsection.