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).
Post Reply
mexiscool
Posts: 2
Joined: Wed Feb 20, 2019 10:02 pm

Moving page number to top center

Post by mexiscool »

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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Moving page number to top center

Post by Stefan Kottwitz »

Welcome to the forum!

This is a common way with fancyhdr:

Code: Select all

\usepackage{fancyhdr}
\fancyhf{}
\fancyhead[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
Put that code into preamble.tex. And I would remove this line in preamble.tex:

Code: Select all

\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
LaTeX.org admin
mexiscool
Posts: 2
Joined: Wed Feb 20, 2019 10:02 pm

Moving page number to top center

Post by mexiscool »

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

\tocloftpagestyle{fancy}
above the

Code: Select all

\tableofcontents
(idk if this is the correct way but it worked for me :) )
Post Reply