Creating headers and footers in Latex can be done by using the package “fancyhdr”. This is a short introduction, showing the most important features of the package. If you know “fancyhdr” and are looking for something particular, refer to the fancyhdr-documentation.

First of all, you need to tell Latex to use the package:

\usepackage{fancyhdr}

and change the style from “plain” to “fancy”:

\pagestyle{fancy}

You will now the get the default fancy pagestyle which adds a line at the top of every page, except for some exceptions (title-page, abstract, new chapter in report).

Default fancyhdr page style:

Above the line, Latex will print headings:

Book/report

Left-hand side: section
Right-hand side: chapter
Note: if you use the optional documentclass argument “twoside”, Latex will alter the position of the section and chapter. (e.g. \documentclass[twoside]{report}, also introducing non-symmetric margins).

Article

For acticles, Latex will print the section only (chapters cannot be used with articles).
The footer only includes the page number which is centered by default.

Custom fancyhdr page style:

Even though fancyhdr has a default page style, you are free to define headers/footers yourself , which is not too difficult after all.

First you need to clear the default layout:

\fancyhead{}
\fancyfoot{}

There are seven letters you need to know before you can define your own header/footer:

E: Even page O: Odd page L: Left field C: Center field R: Right field H: Header F: Footer

Now it’s time to start defining your own layout. The definitions are added to the preamble:

\fancyhead[CO,CE]{---Draft---}
\fancyfoot[C]{Confidential}
\fancyfoot[RO, LE] {\thepage}

The decorative lines can be changed by increasing/decreasing their thickness (0pt means no line):

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

Note: According to the fancyhdr-documentation, the default layout is produced by the following commands:

\fancyhead[LE,RO]{\slshape \rightmark}
\fancyfoot[C]{\thepage}
\footrulewidth 0 pt

130 Responses to “Header/Footer in Latex with Fancyhdr”

• ez

Thanks, this was exactly what I was looking for. If you have time could you leave a comment explaining how to change the header font size and margins? I’d appreciate it.

• Ping

• Décio Krause

Hi
I need to add a foot text in each page of my paper.
I have typed in the preamble:

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{}
\fancyfoot[LE,LO]{MY TEXT}
\renewcommand{\footrulewidth}{0.4pt}

But it doesn’t work. Can you give me a little help please?
Cordially,
D.K.

• tom

Dear D.K.,

The sample you pasted works perfectly in my environment, so I think there’s nothing wrong with it. What you could try is if you are using different packages, change their order. Sometimes they need to be included in the correct order for them to work in combination with others.
If you post the error you get and maybe some more of your preamble, I might be able to reproduce it and help you.

Best regards,
Tom

• sarvesh

Dear tom, i have a difficulty of showing the header and footer in latex environment with copyright information on first page as shown below; please help me to sort out this problem. I want to run my header and footer information for all pages and want to display the “@copyright IEEE” content below the footer on extreme leftside at first page only as depicted below:-
……………………………………………………………………………………
2011 International Conference on ICIIP
….
….
….
….
….
….
….

Proceedings of the 2011ICIIP 2011
978-1-61284-860-0/11/$26.00 ©2011 IEEE …………………………………………………………………………………… • tom Hi Saravesh, Below is a minimal example. You should be able to customize it for your needs. Basically, I define a new page style (titlepage) for the title page and change it back to fancy for the following pages. Hope it helps. Cheers, Tom. \documentclass[11pt]{article} \usepackage[english]{babel} \usepackage{fancyhdr, blindtext} \fancypagestyle{titlepage}{ \fancyhead[L]{2011 International Conference on ICIIP} \fancyfoot[L]{Proceedings of the 2011 ICIIP 2011\\ 978-1-61284-860-0/11/\$26.00 ©2011 IEEE}}
\fancyfoot{}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
\begin{titlepage}
\thispagestyle{titlepage}
\blindtext
\end{titlepage}
\pagestyle{fancy}
\blindtext
\end{document}
• Sarvesh

Dear Tom, Thanks for the reply. I was trying my best to fix up the issue in my IEEE conf latex template But could not able to do it as you have suggested for article documents.
I want to do the same excise (as in article documents) on this code..

bare_conf.tex removed by Tom.

Thanks & Regards
Sarvesh

• tom

Hi Sarvesh,

Please don’t copy-paste hundreds of lines of code into your comment. It would have been sufficient to provide a link to where you got the code from. Michael Shell, the author of the tex-file you use provides an FAQ on his website which has the perfect solution for your question (see “Q: I need to get rid of the page numbers. How do I disable or customize the headers and footers?”).

Best,
Tom.

• Sarvesh

Dear Tom,
Thanks for your guidance and kind support to fix up the problem.
Thanks & Regards
Sarvesh

• tom

Dear Sarvesh,

You are welcome. I hope you were able to adapt the code for your needs.

Best, Tom.

• Helena

If you’re using the geometry package, I suggest (for testing purposes) increasing the top margin separately to a big measure (like 100pt, for instance). For me, it looked like fancyhdr wasn’t working, but actually the header was out of the page limits so I couldn’t see it. Setting a bigger top margin made the header appear and then I could adjust the said margin to a suitable measure (55pt, in my case).

• tom

@ez

First for the margins, you can access them through the following commands:

\fancyheadoffset[]{} and \fancyfootoffset[]{}

E.g. to change the width of a two-sided document’s header to the outer maximum (you need the calc-package for the addition):

\fancyheadoffset[LE,RO]{\marginparsep+\marginparwidth}

The font size can be changed directly where you define the header/footer.
E.g. to decrease the font size of the page numbering you would use:

\fancyfoot[RO, LE] {\footnotesize \thepage}

Check the fancyhdr documentation for more details on that topic:
http://www.ctan.org/tex-archive/macros/latex/contrib/fancyhdr/fancyhdr.pdf

Cu,
Tom.

• Matteo Convertino

Thanks! Fantastic tutorial!!!

• Tapani Simojoki

Great! Thank you.
Tapani

• jonas

i actually saved this to del.icio.us. thank you so much!

• iwo

I always wanted to know how to format headers/footers

Great tutorial!

• Bikash

I am writing my thesis template and would like to include image(logo) in the header. I tried several options, but none of them worked. Could anybody suggest me the way to insert image in the header section? I would be very grateful.

Another problem is the line spacing in the footer. I want to have different line spacing (less than the main text).

Thanks

• tom

Hi Bikash,

Including an image in your header is possible using the fancyhdr package.
E.g. if you’d like to have a logo in the top-right corner, you would use:

\fancyhead[RO,RE]{\includegraphics[width=3cm]{picture.jpg}}

Concerning the text spacing in the footer, the only solution I can propose, even though not very nice, is the following:

\fancyfoot[LE,RO]{1st line\vspace{-2mm}\\ 2nd line}

You can find a documentation of the fancyhdr package here.

Cheers,
Tom

• LaTeX useful Tips/Tricks | Ionut's WebSpace

[...] Header and Footer in LaTeX – Explained [...]

• Kent

I have been using fancyhdr package for a while but have knocked my head in to a problem which I can’t solve:
In a large document, using “BOOK” style, no header/footer is displayed on the chapter page it self. I have tried to redefine the “Plain” setup (which is called when chapter is included):

\fancypagestyle{plain}

BODY
\fancfoot ...
\pagestyle{plain}

The problem is that I don’t know the “BODY” formatingen of a normal CHAPTER page. I simply want the CHapter to look as a chapter but adding a centered header and footer on these pages as well.

Any simple solutions ? Have read the fancyhd doc and I have not figured out any thing yet. I find it unnecessary to add the KOMA script package simply for this. Any help would be appreciated.

K

• tom

Hi Kent,

Actually, what you did is correct, using

\fancypagestyle{plain}

Now if you want to modify the forced fancy-plain-pagestyle, you can add your own definitions as follows:

\fancypagestyle{plain}{%
\fancyfoot[C]{\thepage}
%etc.
}

Cheers,
Tom

• Kent

Tom,
I do agree with you here but then I have to dig out the formating of the Chapter page, to make the correct heading sizes and make the page look like a Chapter start page.
I did however fin something which might help others. It’s much easier, but not something I have found documenter.

It goes like this :

\usepackage{fancyhdr}
\pagestyle{fancyplain}  %Note the \fancyplain command !!!
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

Then “normal formating of \lhead,\chead but with a twis:

\lhead[\fancyplain{E}{EE}]  {\fancyplain{O}{OO}}

E:”Text”-forced into “plain” pages aka first page of Chapter etc- Even pages
EE: Text”-for all the other pages – Even pagenumber

Note the \lhead[ ] { } combination of different brackets !

O: Text”-pforced into “plain” pages aka first page of Chapter etc- Odd pages
OO: ext”-for all the other pages – Even pagenumber

\chead[\fancyhead{}{}]{\fancyplain{}{}}
\cfoot [ ] { }
.
.
\renewcommand{\footrulewidth}{0.4pt}

If you read Piet van Oostrums document there is nothing mentioned about “\fancyplain”. Nor do you find it documented in The Latex Companinon where both refers to the re-definition of the ”Plain” style.
I’m not sure if this is something which is elementary obvious for either the Authors of the “Companion” book or Mr Oostrum, but I think it would be worth a sentence or two in both documents.

Note that you need to document each of the \lhead, \chead....\rfoot to eventually “blank” each part of the header\footer positions. If not, LaTeX apply the normal fancy fields in each position, where for instance \rightmark would give you ONLY the text from the expected fields in the document (No Subsection number etc) but also all the others. So use \rfoot[\fancyplain{}{}]{\fancyplain{}{}} to blank for instance right corner.

Hope it helps for those who would like to add “something” on the first page of each Chapter,Tableofcontents,Listoftables etc
If it’s well known, OK, if not spread the word wherever you see people having these problems.

I found this out by reading the old documentation of the now not supported \fancyheader documentation – the older version of \fancyhdr.

Regards

Kent

• yusuf

I tried a lot to impletement your code but failed. I want to skip header only on the starting page of chapter. on all other pages header should be displayed.
i am using fancyhdr.
I have wasted hours together on this but badly stuck on this.

• tom

Hi Yusuf,

I would expect this to be the normal behavior. You should not get any header on the first page of every chapter by default. Please send a minimal example so I can have a look at it.

Thanks, Tom.

• tom

Hi Kent,

Tom

• Penguin Knight

Thanks for this very helpful information. I still have one technical problem and hope to share with you all:

I am trying to set up a page with left margin 1.5″, and all other margins 1.0″. I did this without problem using the geometry package like this:

\usepackage{geometry}
\geometry{hmargin={1.5in,1in},vmargin={1in,1in}}

However, for the page number, the specification requires me to put it on top right of each page, 0.75″ from the top and right margin. Using fancyhdr, I did manage to move it horizontally with \fancyheadoffset[HR]{0.25in}. However, I cannot find a way to snug it down to 0.75″ from the top while still preserving the 1″ top margin for the text.

Any insight would be appreciated.

Here is the whole format codes I used:

\usepackage{geometry}
\geometry{hmargin={1.5in,1in},vmargin={1in,1in}}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{}
\fancyheadoffset[HR]{0.25in}

Thanks a lot.

• Tessellation

Dear Penguin and respondents,

I had a problem where the header didn’t seem to be centered in line with the body text which had an extra large margin on the outer side (ie large on the right, for a right facing page, and vice versa for a left hand page.)

I had tried using \fancyheadoffset with the R or L subcommand which didn’t seem to work.

However \fancyheadoffset[HR]{0.0in} worked very well and must have reset the offset (caused indirectly by some other command?) that was causing the lack of centering…

A bit clunky but important to get the exam paper submitted in time.
Does anyone have any insight on how this margin had been set to a non-zero quantity? (ie what commands can do this?)

Cheers,
Tessellation

• tom

Hi there!

Thanks for your comment. Please provide a minimal working example and I will be very happy to take a look at what you have described above.

Best, Tom.

• tom

Hi there,

You can control the vertical space for the header using the commands below.

Space between page border and header (1in + space). You can also use someting negative if you like the space to be below 1 inch.

\setlength\voffset{-0.25in}

\setlength\headheight{12pt}

\setlength\headsep{25pt}

If you want to change other margins of the header or footer, please refer to the fancyhdr documentation on page 3.

Cheers,
Tom.

• Sami Maisniemi

Thanks for a great introduction. I have been looking for simple instructions how to modify the headers and footers.

• K

That was exactly what I needed. Thanks

• sbelian

thanks guy.. very usefull tutorial…

• vera

• Aronzak

Ah, you can do dates with \today

• Tuyen

Thank you very much for this very helpful guide.

• cheese

hmm
im quite a new user to latex, and would like to know how i would suppress headers, but not footers?

• tom

Just clear the header using \fancyhead{}. By omitting the content, you actually suppress it. You can also set the \headrulewidth to zero.

Cheers,
Tom.

• A-Oukhai

• E L R V-JAY

good very good…….we got information from this which is belongs to latex………thank u……….

• ionek

Excellent! Thanks

• Naeem

Many thanks…really very useful tutorial….

• NirS

Thank you for the great tutorial!!

• Majkel

well done! thanks!

• Data & Stuff » Blog Archive » Spotted: August 26th – October 10th

[...] Headers & Footers in LaTeX – How to define headers within a LaTeX document by using Fancyhdr [...]

• James

Does anyone know how to get fancyhdr to do some special magic only on the first and/or last header / footer of the document? I’d like to add some information only on the first header and (something different) on the last footer.

• Marta

Hi!

Thanks for the tutorial I need to add a note at the end of my document that is not part of my document itself. It should be a page without header and footer… is it possible to do it?

Thanks!

• tom

Hello!

Try to add the following command after your section command to omit page style for your notes page:

\thispagestyle{empty}

Cheers,
Tom.

• sama

Hello
i need to have just chapters in header , and none section.
thanks

• tom

Hi Sama,

I suggest you use fancyhdr, making it easily to define what you need. Let me give you a code example that goes into the preamble:

\usepackage{fancyhdr}
\pagestyle{fancy}
\rhead{\fancyplain{}{\textit{\leftmark}}}

I took this from the Wikibooks LaTeX Page Layout website.

Cheers, Tom

• Alem

Hi all
I got this strange looking problem. My tex files do not compile in one of my pc’s where i have installed all the necessary packages. They are ok when i remove the bibliography part and compile them. The strange thing is that they do compile with another pc which has just the same compiler, editor and the likes with the bibliography command included . Any help please?

• tom

Hmmm, honestly, I don’t know. Hard to say without seeing the code. Have you tried deleting all the files except the source files and rerun latex. Also, if you are using bibitems within you Latex document, you may want to try using a bibtex file.

Tom.

• gda

Hi! very useful information, congratulations Tom. I have a problem: I’m using “book ” and i wrote this custom:

\fancyhf{}
\fancyhead[RE]{\bfseries\leftmark}

so, everytime a chapter ends on an odd page, a new even page (blank of course) is added. I dont want this to happens of course. What can i do?

thank you

pf: by the way, if i put “oneside” in documentclass, the above commands dont work for Odd pages (the Odd pages act as if they were even)

• tom

Hi!

I suggest you use either of the following:

\let\cleardoublepage\clearpage

\documentclass[openany]{book}

Either should work, but it’s always good to have a backup :-).

Cheers, Tom.

• gda

thank you tom!! it works perfectly. Do you why it happens?

cheers, gda

• Robin

What if I dont want to use fancyhdr? I want to write a custom class. I want define the footer style there. How can I do that without using any package?

• tom

Hi Robin,

Hmmm, why would you not want to use any package? You can still use packages in your custom class (I found this custom class example with fancyhdr on Ankur’s blog).
However, if you really don’t want to use packages, you can use the page counter, the chapter/section reference and commands like \hrule in your custom class to define whatever header/footer you like to have.

Let me know if you have more specific questions.

Thanks, Tom.

• raja

Hi Tom,

I am using Fancy header. Is it possible to get chapter name and section name in even and odd pages using onesided page format.

I have created a document in one side format. To create header, I changed the document format from onesided to twosided. Format of the document changed but with problems(i.e. In onesided page it is good but in twosided page it was not good.)

• Prakash

Hello!
Will any body tell me how to write chapter information on right hand and section in formation on left hand on even page and reverse on the odd page.

Thank You.
Prakash

• tom

That should be the default behavior using:

\usepackage{fancyhdr}
\pagestyle{fancy}

If you need to define it yourself, use:

\fancyhead{}
\fancyhead[LO, RE]{\leftmark}

Cheers, Tom.

• Prakash

Thank you

• Benoit

Hi,
I wanted to know if it was possible to frame the headers and the footers with the fancyhdr package. I have looked and looked but I didn’t find.
I have tried
but it frames the different parts of the header separately… Should I use an other package ?

Thank you,
Benoit

• tom

Hi Benoit,

It’s not great, but it’s a start. Hope it helps. Cheers, Tom.

\documentclass[a4paper]{report}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fbox{\parbox[t][\headheight]{\textwidth}{$\;$}}}
\fancyfoot{%
\vspace{-15pt}
\fbox{\parbox[t][\footskip]{\textwidth}{$\;$}}}
\fancyfoot[C]{\thepage}
\begin{document}
bla
\end{document}
• Benoit

Hi Tom,

Thanks for your answer, however it seems there is a problem with this code because the header keeps growing in height, finally eating irrevocably the totality of the page… but I may have found a solution using the tikz package ! I find it’s not very elegant but in the end I get what I wanted which is already a good thing. I put it so that it may help someone else :

\documentclass[a4paper]{report}
\usepackage{tikz}
\usepackage{fancyhdr}
\usepackage{calc}
%
\begin{tikzpicture}[remember picture, overlay]
\draw (-0.25,-0.65) rectangle (\linewidth+0.25cm, 0.5cm);
\end{tikzpicture}}

% the same can be used for the footer

\pagestyle{fancyplain}
\fancyhf{}
}
}
...

The trick is to put the tikzpicture only in the left part of the header/footer. Really hope it may help someone !

• tom

Hi Benoit, thanks for posting this solution. I corrected the things you mentioned and it works fine now. Thanks again, Tom.

• Gaurang

Dear Tom
I want to put footer on title page of IEEE format in LaTeX and other different footer on other pages. What is the LaTeX command for it?

• Susanna

I want to write my text in every page without line. Help me please…
Thank you.

• tom

Hi Susanna,

Just set the width of the line to zero:

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

Best, Tom

• Kyle

Hi,

I’ve used the fancyfoot command to put a footer on a poster but was wondering how to get rid if the page number?

For my document I have used \pagestyle{empty} but when I use \fancyfoot it puts the page number back

Any help would be great

Thanks,

Kyle

• tom

Hi Kyle,

I suppose you are using maketitle. It interferes and changes the pagestyle after you set it to empty. First I thought you could use:

...
\maketitle
\thispagestyle{empty}
...

However, since you need a footer, you could redefine the plain page style, making it really plain and set the footer as needed:

\documentclass{article}
\usepackage{fancyhdr}
\fancypagestyle{plain}{ %
\fancyhf{}
\fancyfoot[C]{Draft}
\renewcommand{\footrulewidth}{0pt}}
\begin{document}
\title{Title}
\author{Article Author}
\maketitle
The article starts here
\end{document}

From Wikibooks.

Best, Tom.

• name

Hi,
I want to add footer in the first page. How can I do???
Thankyou

• tom

Hi there! I found this relatively simple piece of code that may work for you. Hope it helps, Tom.

\documentclass{article}
\usepackage{fancyhdr}
\renewcommand{\thispagestyle}[1]{} % do nothing
\begin{document}
\pagestyle{fancy}
\title{article title}
\author{article author}
\maketitle
The article starts here
\end{document}
• name

Dear Tom
Thank you so much.
^_____________^

• Esther

Dear Tom,

On my special Pages (Table of contents, begin of chapter) the page number appears centered at the bottom of the page. I want it to appear at the top right of the page and therefore use this:

\fancypagestyle{plain}{ % redefining plain pagestyle
\fancyhf % clear all headers and footers fields
\fancyfoot{}
}

This does not work. I also tried to use:

\fancyhead[R]{\thepage}

This also doesn’t work. The page number appears on the top left.
What can I do?

• tom

Dear Esther,

Try the following code and let me know if it doesn’t work:

\usepackage{fancyhdr}
...
\pagestyle{fancy}
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}

Best, Tom

• Esther

Dear Tom,

When I try this my page numbers still appear on the bottom center.

Also, now my ‘normal page’ headers change from mentioning the Chapter to mentioning the section in my chapter.
I have \pagestyle{headings} written in my file.

Esther

• Esther

I have fixed this, but it is still a strange thing that the former codes did not work. I used:

\fancypagestyle{plain}{
\fancyhf
}
• tom

Hi Esther,

Thanks for the update. I didn’t see that you are actually redefining the pagestyle plain. So after that, you would have to set it (\pagestyle{plain}), which I’m sure you do. Another possibility would be to use fancy and change it according to your needs (see my previous answer).

Best, Tom.

• Nitin

Hi Tom,

I am writing master thesis and have to place a logo in footer on all the pages except the title page. I tried with fancyhdr but it misses the logo on every chapter’s first page or content page etc. How to force the footer logo on every page except the title page?

Regards, Nitin

• tom

Hi Nitin,

Here is some code that should do what you need. It redefines the pagestyle plain, which is what LaTeX uses for the first page of a chapter. Give it a try.

\documentclass[a4paper]{report}
\usepackage{fancyhdr, graphicx, blindtext}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[C]{\thepage}%
\renewcommand{\footrulewidth}{0pt}
}
\title{This is my title}
\begin{document}
\maketitle
\tableofcontents
\pagestyle{plain}
\chapter{First chapter}
\Blindtext
\end{document}

Another possibility would be to add the logo to the background, using the eso-pic package, for example. See here for more details.

Best, Tom.

• Marcin

How to change the length of the decorating line in heading in LaTeX? I would like to have it as long as my text on the page? Kind wishes

• tom

Hey Marcin,

I would expect the line to have the same length as the text. This post shows how to display page margins. Does the header and text box have the same width? You can change the margins using the geometry package. In case that doesn’t solve your problem, please provide a minimal working example.

Cheers, Tom.

• Haris Ibrahim K. V.

Hi Tom,

That was a neat article. However, when I use the following in my preamble, I’m just getting a plain straight line as my header and the page number displayed at the bottom center of my page.

\documentclass{book}
\usepackage[paperwidth=5in,paperheight=7in]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}

I thought the default fanyhdr trait was to print the name of the chapter as the header. But in my case nothing is being printed.

I wanted to have the name of the corresponding chapters as the headers of each page in my book. How can I achieve that?

Thank you.

• Haris Ibrahim K. V.

Update: The titles of the chapters/sections were not coming in the header because I had starred them (/section*). In order to achieve what I wanted, I removed all the stars and added the following to the preamble:

\setcounter{secnumdepth}{0}

Solved.

• Hassan

hello Tom,
I am writing my masters thesis. I am using the fancyhdr package. Single sided report document class. I get the section name and number on the left header and the chapter number/name on the right header. I want to change the font size (and i dont want it in italics, its italics by default), because they over write each other. Please if you could help. Its urgent. Waiting. Thanks.

• tom

Hi Hassan,

Thanks for your question. The code below shows how to change the font size for your fancy header. You can play with the numbers. I used 9 with a baseline-skip of 11 (~1.2x).

You may also find this post helpful. By the way, the fancyhdr documentation is extensive and includes lots of examples.

Best, Tom.

\documentclass[11pt, oneside]{report}
\usepackage{fancyhdr, blindtext}
\fancyhf{}
\fancyfoot[C]{\thepage}
\pagestyle{fancy}
\begin{document}
\tableofcontents
\blinddocument
\end{document}
• Hassan

Thank you so much for your reply. I have another problem. I try to set the page counters but i am having problems with it. I have abstract, acknowledgements, list of figures, list of tables.. i want them to be numbered in Romans (i,ii,iii,..).. i have succeeded in doing that with this \pagenumbering{roman}
\setcounter{page}{1}

but there are two problems, I dont see the page numbers on
abstract, acknowledgements page.. and in the table of contents, it shows both abstract and acknowledgements on teh same page i.e. page number i. I have also used \newpage after abstract.. for acknowledgements i am using this..

\renewcommand{\abstractname}{Acknowledgements}
\begin{abstract}
…my text goes here…
\end{abstract}

please if you could help me with the problem. Thank you in advance.

• tom

Hi Hassan,

The code below will produce the desired result. The abstract environment internally calls \thispagestyle{empty}, which is why you have to set the page number manually.

\documentclass{report}
\usepackage{blindtext}
\title{Title}
\begin{document}
\maketitle
\pagenumbering{roman}
\begin{abstract}
\thispagestyle{plain}
\blindtext
\end{abstract}
\renewcommand{\abstractname}{Acknowledgements}
\begin{abstract}
\thispagestyle{plain}
\setcounter{page}{2}
\blindtext
\end{abstract}
\setcounter{page}{3}
\tableofcontents
\listoffigures
\listoftables
\cleardoublepage
\setcounter{page}{1}
\pagenumbering{arabic}
\chapter{Introduction}
\Blindtext
\end{document}

Alternatively, you can use:

\chapter*{Acknowledgements}
\addcontentsline{toc}{chapter}{Acknowledgements}

instead of diverting abstract from its intended use.

Cheers, Tom.

• Nir

Hey.

I’m trying to put chapter name in the format:

Chapter 1 – Introduction

or something similar in the top left corner. Writing:

Just gives me the chapter number. How can i fix this?

• tom

Hi!

You could redefine \chaptermark as follows:

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername
\ \thechapter\ -- #1}{}}

See the fancyhdr documentation for more details.

HTH, Tom.

• Hassan

Thank you Tom.. you are a life saver keep up the good work. Cheers.

• atefeh

I am writing up my chemistry thesis in Latex using

\usepackage{fancyhdr}
\pagestyle{fancy}

How can I define a fixed term for some of my sections and not all!! My exact problem is that the header is in capital letters, which is fine! but since in chemistry the formatting makes a huge impact on the meaning. I have to be consistent.

many many thanks

Hajar

• tom

Do you mean some chapter or section headings contain terms that need to be printed in small letters? Could you give me an example?

Thanks, Tom.

• atefeh

yes thats right! for eg.,
Synthesis of nEG Analouges, that appear in a capital letter!

many thanks for taking the time and help in advance

• tom

Hey! There is indeed a relatively simple solution. \lowercase{} forces the text to be in small letters in a capital letter environment. See below!

Best, Tom.

\documentclass[11pt]{report}
\usepackage{fancyhdr, blindtext}
\pagestyle{fancy}
\begin{document}
\tableofcontents
\chapter{Synthesis of nEG Analouges}
\Blindtext
\chapter{S\lowercase{ynthesis of n}EG A\lowercase{nalouges}}
\Blindtext
\end{document}
• atefeh

great job!!! worked like a magic!!
thank you ever so much!

• Aida Kazagic

Hi,

I would like to have larger spacing between the header and the text. I have tried various solutions but cannot make any of them work as I want. The code I am using is:

\usepackage{fancyhdr}
\pagestyle{fancyplain}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\renewcommand{\footrulewidth}{0pt}
\fancyhf{}
\rfoot{\thepage}

Also, do you know how I can get both the section nr and name printed in the header? I thought that I would get that with the command \rightmark, but only the section name appears.

Best regards, Aida

• tom

Hi Aida,

Thanks for your comment. To increase the space between header and text, use the variable headsep rather than headheight. See the figure on wikibooks site about page layout for all variable names.
rightmark is correct, but you are redefining sectionmark. Just remove those lines and it works. See the minimal working example below.

Cheers, Tom.

\documentclass[11pt]{report}
\usepackage{fancyhdr}
\usepackage{showframe}
\usepackage{blindtext}
\pagestyle{fancyplain}
%\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
%\renewcommand{\sectionmark}[1]{\markright{#1}{}}
\renewcommand{\footrulewidth}{0pt}
\fancyhf{}
\rfoot{\thepage}
\begin{document}
\blinddocument
\end{document}
• Natalie Spencer

Hiya, thanks for this! it’s fixed what I’ve been trying to do for ages, however I’m now getting a “Package fancyhdr warning” saying \headheight (12.0pt) is too small; make it at least 34.97pt……what is it that I change for this as I’ve tried changing my font size, my textheight size, the textsize in the header and I can’t get rid of the error message? Thanks for any help
Natalie

• Durlindana

Hi Tom,
I also need to display only chapters in the header, and I saw your advice for Sama. It works, but I have just one problem: the header line doesn’t finish at the beginning of the left margin of the page. How can I correct this?

Maybe that’s because I changed the default margin size of LaTex…

• tom

Hi Durlindana,

Thanks for your comment. How do you change the default margin size? Do you use the geometry package? Please give a minimal working example.

Thanks,
Tom.

• Alice

Hi, I used the command for displaying only chapters in the header, but the header line stops before the right margin. How can I correct this?

Hi,

I don’t understand why the vertical position of the footer changes from page 1 to page 2.
Can you help me?

Thanks Emil

• S.Karim

hi all……
I am writting a thesis in latex, I have almost done all the setting except one problem that I wana to remove only header not footer from only first page of each chapter, for other pages setting must remain same, how this could be done???
using:
\usepackage{titlesec}
\usepackage{fancyhdr}

• tom

Hi!

Take a look at the answers to a similar question here. If this doesn’t help, please send a minimal working example and I will be happy to propose a solution.

Best, Tom.

• S.Karim

Hi Tom,
I tried alot but in vain, actually i want

For other chapter pages:

\pagestyle{fancy}
\lfoot{Author:~\textbf{\thesisname}}
\cfoot{\thepage}
\rfoot{\thesistitle}
\renewcommand{\footrulewidth}{0.4pt}

For 1st page of each chapter i have tried following codes:

\thispagestyle{fancy}  % also \thispagestyle{plain}
\lfoot{Author:~\textbf{\thesisname}}
\cfoot{\thepage}
\rfoot{\thesistitle}
\renewcommand{\footrulewidth}{0.4pt}

But it repeats for all pages.

thanks,

• tom

Thanks for the code examples. So what I suggest is to create a special chapter-page-style. I reused your code and modified the chapter command by adding \thispagestyle after the chapter call. It’s somewhat complicated, because one has to take care of starred and non-starred version of the chapter command.

Let me know if anything is unclear.

Cheers, Tom

\documentclass[11pt]{report}

\usepackage{fancyhdr, blindtext}

\def\thesisname{Someone}
\def\thesistitle{Some thesis title}

\lfoot{Author:~\textbf{\thesisname}}
\cfoot{\thepage}
\rfoot{\thesistitle}
\renewcommand{\footrulewidth}{0.4pt}

\fancypagestyle{chapterstyle}{%
\lfoot{Author:~\textbf{\thesisname}}
\cfoot{\thepage}
\rfoot{\thesistitle}
\renewcommand{\footrulewidth}{0.4pt}
}

%Redefine chapter by adding special first chapter page page-style
\makeatletter
\let\stdchapter\chapter
\renewcommand*\chapter{%
\@ifstar{\starchapter}{\@dblarg\nostarchapter}}
\newcommand*\starchapter[1]{\stdchapter*{#1}\thispagestyle{chapterstyle}}
\def\nostarchapter[#1]#2{\stdchapter[{#1}]{#2}\thispagestyle{chapterstyle}}
\makeatother

\pagestyle{fancy}

\begin{document}
\tableofcontents
\chapter{Some chapter}
\Blindtext
\chapter*{Some non-numbered chapter}
\Blindtext
\end{document}
• S.Karim

hi tom….!
thanks alot,
this works perfectly,
cheers.

• Hugo Silva

Hello im trying to use my fancyfoot in every page, but that just not happen, just appear in the first page, fancyhead appear in all pages working fine.

\fancyhead{}
\fancyfoot{}
\fancyfoot[CO]{Confidencial}
\footskip=12pt

\pagestyle{fancy}
• tom

Hi Hugo,

Set the page style first and make the changes after. If that doesn’t solve the problem, please post a minimal working example.

Thanks, Tom.

• tom

\documentclass[11pt]{report}
\usepackage{fancyhdr,blindtext}
\fancyfoot{}
\fancyfoot[CO]{Confidencial}
\pagestyle{fancy}
\begin{document}
\blinddocument
\end{document}
• katy

Hello Guys,

I am using Bookclass and created several book chapters (each has its own author). Each book chapter need to have a heading on the first page of the chapter with the name of the book series and year. On the remaining pages of each chapter: even pages have the running title of the chapter and odd pages have authors names. So that is all fine. Now when I try to combine these in one MasterDocument things gets very messy. So far I tried the following in the preamble of the masterdocument:

\usepackage{fancyhdr}
\pagestyle{fancy}
\newcommand{\shortauthor}[1]{ Authors et al}
\newcommand{\runtitle}[1]{Running title}

\fancyhf{}

\renewcommand{\footrulewidth}{0pt}
\setlength{\footskip}{0in}
\renewcommand{\footruleskip}{0pt}
\fancypagestyle{plain}{%
}

I also tried to put the following lines after table of contents and before each chapter to reset the above three commands

\renewcommand{\firstpagehead}[1]{Book Series name 2014}
\renewcommand{\shortauthor}[1]{ new Authors et al}
\renewcommand{\runtitle}[1]{new Running title}

The above three renewed commands did not work. I am also struggiling on how to define the first page of each chapter?

Help is most appreciated.

• tom

Hi Katy,

Thanks for your question. Unless you reset the page number after every chapter, the condition on page will only work for the first page. I got a similar question, see here for how to have a different header/footer on the first page of a chapter. Furthermore, it might be a good idea to create a macro that redefines all the commands and creates a chapter, e.g.:

\newcommand{\mychapter}[3]{%
\renewcommand{\shortauthor}[1]{#3}
\chapter{#1}}
...
\mychapter{Chapter title}{First page head}{Short author}

HTH, Tom

• Fred

Dear all,

I am currently finishing my phd thesis for the publication process. Everything works out perfectly so far, but I would like to have the page numbering in the header in Italic and not in normal . Can anyone please help me?

BR
Fred

• tom

Hi Fred,

I removed your code, since it was rather long and you explained your issue well enough. By adding the line which is highlighted, the page number will appear in italics throughout the document.

Let me know if that’s not what you were looking for.

\documentclass{book}
\usepackage{fancyhdr, blindtext}
\pagestyle{fancy}
\fancyhf{}

%redefine page number
\def\thepage{\textit{\arabic{page}}}

\begin{document}
\Blinddocument
\end{document}
• Fred

Dear Tom,

thanks a lot for your response. Unfortunately your proposal does not work Do you know a second way of solving the problem?

Kind regards
Friedrich

• tom

Dear Fred,

Please provide some more details on what exactly doesn’t work with the solution. Ideally, you’d provide a minimal working example illustrating the problem.

Thanks, Tom