LaTeX forum ⇒ Page LayoutMoving page number to top center

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
mexiscool
Posts: 2
Joined: Wed Feb 20, 2019 10:02 pm

Moving page number to top center

Postby mexiscool » Wed Feb 20, 2019 10:12 pm

Hi, I'm new to LaTeX and my university gave me an example latex document (https://www.overleaf.com/read/hqkwvxsvynxg). However, their guidelines state that all page numbers (Arabic and roman) should be at the top, I tried several things including fancyhdr but I was only partially successful. I would like some help.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9513
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Thu Feb 21, 2019 12:08 pm

Welcome to the forum!

This is a common way with fancyhdr:

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \usepackage{fancyhdr}
  2. \fancyhf{}
  3. \fancyhead[C]{\thepage}
  4. \renewcommand{\headrulewidth}{0pt}
  5. \pagestyle{fancy}


Put that code into preamble.tex. And I would remove this line in preamble.tex:

Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \usepackage{fullpage}


That's because that package is not recommendable and kind of clashes with geometry and would cause the header line to overlap with text or headings.

Stefan
Site admin

mexiscool
Posts: 2
Joined: Wed Feb 20, 2019 10:02 pm

Postby mexiscool » Sat Feb 23, 2019 2:37 am

Thank you it worked and it looks beautiful.
For any other that have the same issue that is new to LaTeX, I want to add that to get the table of contents page number also on top you can add
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \tocloftpagestyle{fancy}
above the
Code: [Select all] [Expand/Collapse] [Download] ({untitled.tex})
  1. \tableofcontents
(idk if this is the correct way but it worked for me :) )


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 2 guests