Page LayoutHow to center the page header?

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
sina2010
Posts: 5
Joined: Mon Oct 25, 2010 5:35 pm

How to center the page header?

Post by sina2010 »

Hello,
could you please help me in this issue? I am trying to put the header at the center but it is located at the right side. I am using these commands:
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername
\ \thechapter.\ #1}{}}
\renewcommand{\headrulewidth}{1pt}
\fancyhead[RE,LO]{}
\fancyhfoffset[R]{0cm}

Thank you.
Last edited by sina2010 on Thu Oct 28, 2010 10:24 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

How to center the page header?

Post by frabjous »

Is this what you want:

Code: Select all

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername
\ \thechapter.\ #1}{}}
\renewcommand{\headrulewidth}{1pt}
\fancyhead[LO,RE]{}
\fancyhead[CE,CO]{\leftmark}
If not, post an actual minimal working example and not just a snippet. It would help to read the fancyhdr documentation as well.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to center the page header?

Post by localghost »

It is essential that you always provide a minimal example. This is also a point that you have been notified in the past. People are rarely motivated to build a minimal document on their own just for testing possible solutions.


Thorsten
sina2010
Posts: 5
Joined: Mon Oct 25, 2010 5:35 pm

Re: How to center the page header?

Post by sina2010 »

Thank you, it worked. also it needed one more command too: \fancyhead[LE,RO]{}.
Thank you.
Post Reply