I am trying to put fancyhdr custom style on all pages except first one, but it either shows up on all of them, or on none, I can't make this style to go from second page, im new to latex, so any help is welcome.
[Tex/LaTex] How to put fancy header on all pages except the first page
fancyhdr
Related Solutions
Try this code:
\documentclass{book}
\usepackage{fancyhdr}
\fancyhf{}
\lhead{\itshape BA TOPIC}
\chead{\itshape{\nouppercase{\leftmark}}}
\rhead{\thepage}
\lfoot{}
\cfoot{}
\rfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\usepackage[ocgcolorlinks]{hyperref}
\usepackage{bookmark}
\usepackage{lipsum} %% for dummy text
\begin{document}
\frontmatter
\pagestyle{plain}
%Titlepage
%\input{title.tex}
%ToC etc
\tableofcontents
\listoffigures
\listoftables
\cleardoublepage
\pagestyle{fancy}
%define header style for chapter pages and put it here
\fancypagestyle{plain}{%
\fancyhf{}
\fancyhead[L]{\itshape{BA THEMA}}
\fancyhead[C]{}
\fancyhead[R]{\thepage}
}
\mainmatter
% actual Content
\chapter{Einleitung}
\lipsum[1]
\section{Some section}
\lipsum[2-8]
\chapter{Second}
\lipsum[1]
\section{Some other section}
\lipsum
\end{document}
You can define a fancy page style like:
\fancypagestyle{myfancy}{%
\fancyhf{}
\fancyhead[L]{<your settings>}
\fancyhead[C]{<your settings>}
\fancyhead[R]{<your settings>}
\fancyfoot[L]{<your settings>}
\fancyfoot[C]{<your settings>}
\fancyfoot[R]{<your settings>}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
and use it as \pagestyle{myfancy}
. But if you want to change the page style of chapter pages, you should do it by changing the plain
style as shown above.
When you compile your code, you get this warning:
Package Fancyhdr Warning: \headheight is too small (12.0pt):
Make it at least 14.49998pt.
We now make it that large for the rest of the document.
This may cause the page layout to be inconsistent, however.
Hence you have to give proper headheight
and better way of doing this is through geometry
package:
\documentclass[12pt]{article}
\usepackage{fancyhdr}
\usepackage{geometry}
\geometry{text={7in,9.5in}
,headheight=15pt
}
%\textwidth = 7 in
%\textheight = 9.5 in
%\oddsidemargin = -0.25 in
%\evensidemargin = 0.0 in
%\topmargin = -0.25 in
%\headheight = 0.0 in
%\headsep = 0.0 in
\setlength{\parskip}{0.1in}
\setlength{\parindent}{0.0in}
\pagestyle{fancy}
\lhead{}
\rhead{my name}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\usepackage{blindtext}
\begin{document}
\Blinddocument
\end{document}
For your case, ideal will be to use
\geometry{text={7in,9.5in}
,headheight=15pt
,headsep=0.1in
,includehead
}
Best Answer
The default page style -
plain
- is used throughoutarticle
, even if\maketitle
is used. To be sure though, you could addto your preamble, which will ensure the first page uses
plain
(as a result of\thispagestyle
) and subsequent pages usefancy
(as a result of\pagestyle
;\thispagestyle
overrides\pagestyle
).Here's a complete minimal example:
Another option might be to use
afterpage
which you can use to set the page style of page following the one containing the\afterpage
command. However,\afterpage
sets its contents in a group, which doesn't allow a regular\pagestyle
to survive. For that, you could use some other trickery, as discussed in Page styles only work for\thispagestyle
underafterpage
.