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} \fancyhead[LO,RE]{\slshape \leftmark} \fancyfoot[C]{\thepage} \headrulewidth 0.4pt \footrulewidth 0 pt
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.
MAYAMMA JOSEPH
Very clear explanation. Thank you very much.
Ping
Good job, very helpful. Thanks.
Décio Krause
Hi
I need to add a foot text in each page of my paper.
I have typed in the preamble:
But it doesn’t work. Can you give me a little help please?
Thanks in advance.
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 tofancy
for the following pages. Hope it helps. Cheers, Tom.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.
What would be the latex command for the above code. Please help me out.
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
To answer your question:
First for the margins, you can access them through the following commands:
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):
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:
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:
Concerning the text spacing in the footer, the only solution I can propose, even though not very nice, is the following:
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):
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
Now if you want to modify the forced fancy-plain-pagestyle, you can add your own definitions as follows:
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 :
Then “normal formating of
\lhead,\chead
but with a twis: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
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.
can you please help.
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,
Thanks for your explanations, I appreciate your feedback.
Good luck with your work,
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:
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:
Thanks a lot.
Tessellation
Dear Penguin and respondents,
This was a very helpful question & set of answers.
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.
Height of the actual header.
Separation between header and text.
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
thanks for your explanations! really helpful! cheers
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
very helpful, many thanks.
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:
Cheers,
Tom.
sama
Hello
i need to have just chapters in header , and none section.
can anybody help me? please
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:
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.
Alem
It is a mysterious problem. I upgraded for Miktex 2.9 and it worked fine finally.
gda
Hi! very useful information, congratulations Tom. I have a problem: I’m using “book ” and i wrote this custom:
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:
in your preamble, or
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,
Your inputs are really helpful.
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.)
tom
Raja, please provide a minimal example to illustrate the problem. Thanks, Tom.
raja
Hi Tom,
I moved to doublepage. I used \raggedbottom to avoid extra spaces.
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:
If you need to define it yourself, use:
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
\fancyhead{\fbox}
but it frames the different parts of the header separately… Should I use an other package ?
Please help me I’m a bit desperate !
Thank you,
Benoit
tom
Hi Benoit,
It’s not great, but it’s a start. Hope it helps. Cheers, Tom.
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 :
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?
tom
Hi,
Have a look at Michael Shell’s site. It shows how to add footers to an
IEEEtran
document.Cheers, Tom.
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:
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 thepagestyle
after you set it toempty
. First I thought you could use:However, since you need a footer, you could redefine the
plain
page style, making it really plain and set the footer as needed:From Wikibooks.
Best, Tom.
Kyle
thanks for your help Tom
cheers,
Kyle
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.
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:
This does not work. I also tried to use:
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:
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.Thanks for your reply.
Esther
Esther
I have fixed this, but it is still a strange thing that the former codes did not work. I used:
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 usefancy
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?
Thanks in advance,
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.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.
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:
Solved.
tom
Thanks for posting your solution, appreciate it. Best, Tom.
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.
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.Alternatively, you can use:
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:
\fancyhead[LO,LE]{\thechapter}
Just gives me the chapter number. How can i fix this?
tom
Hi!
You could redefine \chaptermark as follows:
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
Please help!!
I am writing up my chemistry thesis in Latex using
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.
Valerie
Hi,
I have a similar problem but the other way round- the header is written in capital letters (which is good) but I have some abbreviations in the titles of my chapters and I would like that they stand out, i.e. that they are written in a larger case than the rest of the text. Is that possible ? For e.g. “AR detection”.
Thanks in advance,
Best regards,
Valerie
tom
You can use
\uppercase
to produce upper-case letters in a similar way as\lowercase
in the previous example.If this doesn’t solve your problem, please provide a minimal working example.
Cheers, Tom
Valerie
Hi,
Here is a minimal working example:
As you can see, the title of the section is too long and I use
\sectionmark
to make a shorter name. However, the\uppercase
does not work.Thanks for your help 🙂
tom
Thanks for the example. To make “AR” stand out, you could increase the font size as you already suggested or alternatively write it in bold face:
Valerie
Thanks a lot for your help! It didn’t work with
\sectionmark{{large AR} detection}
but\sectionmark{{\large{AR}}s detection}
worked fine! Have a nice day 🙂tom
It might be because of a missing backslash before
large
. It should read\large
.atefeh
great job!!! worked like a magic!!
thank you ever so much!
tom
You are very welcome. Tom.
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:
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.
Thanks in advance.
Best regards, Aida
tom
Hi Aida,
Thanks for your comment. To increase the space between header and text, use the variable
headsep
rather thanheadheight
. See the figure on wikibooks site about page layout for all variable names.rightmark
is correct, but you are redefiningsectionmark
. Just remove those lines and it works. See the minimal working example below.Cheers, Tom.
Aida Kazagic
Great! Thank you very, very much 🙂
Best regards, Aida
tom
Great, I’m glad I could help! Best, Tom.
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
Natalie Spencer
It’s ok, it was due to me trying to position my entire header in the centre of the allocated space.
tom
Thanks for following up. Cheers, Tom.
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?
tom
Hi! Please provide a minimal working example for me to see what you did. Thanks, Tom.
EmilLask
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
tom
Hi,
I assume you are talking about the page number which is in the center on page one and then moves to the side. The answers here to this question should give you a good idea on how to change the page style on page 1.
HTH, Tom.
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.
Good luck with your thesis!
Best, Tom.
S.Karim
Hi Tom,
I tried alot but in vain, actually i want
For other chapter pages:
For 1st page of each chapter i have tried following codes:
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 thechapter
command.Let me know if anything is unclear.
Cheers, Tom
S.Karim
hi tom….!
thanks alot, 🙂
this works perfectly,
cheers.
tom
Great, glad to hear! Cheers, Tom
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.
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
Your example works for me.
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:
I also tried to put the following lines after table of contents and before each chapter to reset the above three commands
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.:
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?
Thank´s a lot in advance!
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.
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
Robert
I have a few pages I have gathered several chapters (appendices) for a special purpose, suppressing their initialization of a new page by putting:
\let\clearpage\relax
. Now I have a problem of the runinng header — namely, since on almost every page there is at least one new chapter (appendix) and all of them are treated as the first page of the chapter (appendix). So all the page numbers are put in the center of the bottom line. I would like to put a running header for all this squeezed chapters to be “Squeezed chapters”. But when I interveene with\fancyfoot{}
— to clear the page number in the footer — I cannot reinstall it properly in the rest of my document (book.cls). That is, when I put:\fancyfoot[C]{\thepage}
— it does appear, but not only on the first page of chapter, but on all of them, meaning that the automatism of the plain vs. fancy headings is lost! It seems that anything I do with the commands that you suggest, I loose that automatism. I use the\begingroup
and\endgroup
to localize the settings, but it does not help. Any suggestions?tom
Hi Robert,
Take a look at my post on how to define multiple page styles with fancyhdr. If this doesn’t help to solve the problem, please create a minimal working example and post it here.
Thanks, Tom
djh
Is there a way to accomplish the following in Latex?
3
FOR OFFICIAL USE ONLY
I need this to only be on specific the pages that contain this type of information. I have not been able to get this to work.
Any help will be greatly appreciated.
tom
Hi djh,
I’m not sure I understand what you are trying to accomplish. Please clarify and provide a minimal working example. Thanks, Tom.
Abel
Dear Tom,
How do I set footer foreground and background color using fancyhdr?
Thank you!
Abel
tom
Hi Abel,
Thanks for your question. I’m not sure what exactly you have in mind. You can find a possible solution here. If this is not what you were looking for, please provide a minimal working example and/or a more concise description.
Thanks, Tom
Abel
Dear Tom,
Thank you for the link and sorry for the delay in getting back to you.
I adapted the StackExhange code to create a colored footer in a one-sided article. However, when the document is printed the location and dimensions of the footer differ from the screen view.
Here is the code:
Note, I am running MikTeX 2.9 with TeXworks front end.
Any thoughts?
Thanks, again.
Best wishes,
Abel
tom
Sounds like a hardware problem: Printers are usually not able to print at the very edge of the paper. If your printer can’t do “borderless” printing, perhaps a printing company can help you with that. Hope this helps, Tom.
Abel Wolman
Dear Tom,
Once again, sorry for not replying sooner. And thank you for your thoughts regarding my code. I can force my printer to print to the edge of the paper, but then the screen version of the PDF is clipped. Btw, my goal is to replicate an MS Word template, which displays and prints correctly.
Best wishes,
Abel
tom
Hi Abel,
It sounds like there is a difference if you print from Word or from your PDF viewer. However, as I can’t replicate the problem, I’m not sure how to help you. Sorry for that.
Best regards,
Thomas
Igor Bannicov
Hi, Tom!
First of all – thank you for your wonderful tutorials, I know, it’s a lot of work behind.
I have a small task, which seems a little bit too tricky to me, as I’m pretty new to TeX.
The problem is following: to make a backgrounded footer, with page numbers at strict position. Let me show a couple of image in order to make myself clear:
http://oi67.tinypic.com/10ptwci.jpg – left page
http://oi68.tinypic.com/157j2th.jpg – right page
As you can see, there should be an image in footer’s background and the page number should exactly match the yellow “placeholder”.
Thank you in advance for your help and I hope this would be interesting to other readers, too.
Best regards,
Igor Bannicov.
tom
Hi Igor,
That’s a cool footer. Below is the code for one side. Please try to do the other side yourself. You can use an
if...else
conditional statement, which is explained here.Best, Tom
Alexandra Luccioni
HI Tom,
Are there packages that fancyhdr clashes with? I have quite a complex setup for my thesis (i.e. many packages) and I can’t seem to set up fancyhdr in order to put my page numbers left for even pages and right for odd… are there any packages that can cause this behavior?
List of packages I use:
Thanks in advance!
tom
Hi Alexandra,
Thanks for your comment. Here’s a good list with packages that need to be loaded in a specific order. Perhaps sectsty affects the fancyhdr, since they both change headers. However, to be sure I’d have to see a minimal working example.
Best, Tom
rojas70 rojas
I am working with the IEEE Conf format. I am having trouble just showing the copyright in the first page and no other changes anywhere else.
I have been trying code like the following:
But i can’t get to see the footer on page 1.
I would be greateful for some feedback.
tom
Hi Rojas70,
See the updated code below. Does it do what you wanted?
\fancyfoot{}
creates an empty footer and overwrites any previous footer definition.Best, Tom
Ahmed
Hi.
How I can add footer and page number to the title page
tom
Hi Ahmed,
What
documentclass
do you use? Please provide a minimal working example.Thanks, Tom
Karl Tokle
Is it posible to make an foot rules in two different colors. My company want to have an foot ruler with green and red color.
Regards
Karl
tom
Hi Karl,
Can you be a bit more specific, please. Do you want two parallel lines: one green, one red. Or a line with a gradient from green to red. Or green on even pages and red on odd pages?
Best, Tom.
Karl Tokle
Hi Tom,
On all pages the line should change from green to red in the middle of the page. No paralell lines no gradient, sme on all pages in the report.
Regards
Karl
tom
Hi Karl,
Thanks for getting back to me. See below for a possible solution.
Best, Tom
Karl Tokle
Hi Tom,
This works very well. I have used laTEX many years, but not very complicated vays.
I have make my ovn heading with two lines and text. The problem is that I got an extra line in the heading which should not be there. I think this comes from the fancy package.
Is it possible to send you an pdf file which shows this.
Regards
Karl
tom
Hi Karl,
Can you prepare a minimal working example and post it here, please. That would be more useful, since I can then run the code on my system.
Thanks, Tom
Karl Tokle
Hi Tom,
If you run this you will se the problems with the heading.
Regards
Karl
tom
Hi Karl,
Thanks for the example. I am not sure which line you want to get rid of, so I’ll just tell you for both :-).
1) To remove the double line on the right, comment out this part:
\fancyhead[RO]{\rblob}
. It would make sense to move this line up to the preamble anyways. Also, \rhead{…} and \fancyhead[R]{…} are the same in aoneside
document. TheO
inRO
stands for odd, so in my opinion usingO
only makes sense with thetwoside
documentclass
option.2) To remove the ‘standard’ single line below your text in the header, use
\renewcommand{\headrulewidth}{0pt}
in the preamble.Hope this helps.
Best, Tom
Karl Tokle
Hi Tom,
The
solve my problem with the header. I can now make the report with the correct footer. I have used lot of hours to try to solve this problem with the footer.
Thanks again for your help .
Regards
Karl
tom
Great to hear my suggestions were of use. Best, Tom.
Edwige
Hi Tom,
I am writing a document and I would like the line, and both the number and the name of the section to appear at the right side of the header of each page. Also the line does not fit with the geometry. Here is the code I am using, but it does work as I want.
Please any help will be highly appreciated.
Best, Edwige.
tom
Hi Edwige,
Thanks much for the nice example, that makes it much easier for me to help. A few things that might be useful:
geometry
beforefancyhdr
. Otherwise, fancyhdr does not know the the size of the text area. This should fix the line width.\sectionmark
. Instead, use\fancyhead[R]{...}
as shown in the text. That said, the default forarticle
is number and section name on the right side, at least that’s what I get when I typeset your code.\usepackage{showframe}
to get an idea of the margins of your document. The boxes visualise the margins.Best, Tom
Edwige
Hi Tom,
Thank you for your help. In fact, I tried as you suggested and the line was fixed. Just that for now the section number and name appear, but the section name is in Upper case. Please how can I write with lower case? This is the code that I have written.
Best, Edwige.
tom
Hi Edwige,
Great to hear you fixed the issue with the line. There are two ways to suppress uppercase in the header (fancyhdr).
Edwige
Hi Tom,
Thank you very much for your help. The issue was fixed with your suggestions.
tom
Great to hear. Thanks for the feedback. Best, Tom
Edwige
Hi Tom,
Another issue is that the text at the header is in italics which I do not want to be like that. Moreover, the subsection title also appears on the left of the header, which I do not want. I want only the section title to appears in normal characters and at the right of the header. Thank you
Best, Edwige
tom
Hi Ewige,
I can’t test this now, but can you try this?
Best, Tom
Fernando
Thank you for the post. That definitely helped me out!