Page Layoutfancyhdr different first page

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
nico
Posts: 20
Joined: Tue Jun 08, 2010 10:13 am

fancyhdr different first page

Post by nico »

Hi,

I want my headers and footers on the first page to have another content then the other pages. I can not use the environment titlepage, because there is content already on the first page.
Also there is no \pagebreak.

This is my approach:

Code: Select all

\documentclass[10pt,a4paper]{scrartcl}

%-----------------------------------Settings---------------------------------------------
\usepackage{fancyhdr}
\pagestyle{fancy}
%\makeatletter
\ifnum\thepage=1
	\fancyfoot[L]{first page}
\else
	\fancyfoot[L]{other pages}
\fi
%\makeatother
%-----------------------------------Ende Settings----------------------------------------

\begin{document}
\section*{Stellungnahme}
\pagebreak
\subsection*{Rettungswege}
\label{LastPage}
\end{document}
But it doesn't work. Can anybody help me with this?

Edit: Just to mention it: the pagebreak is just for testing.
Last edited by nico on Fri Jun 18, 2010 9:14 am, 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.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

fancyhdr different first page

Post by gmedina »

Hi, nico

try with something like this:

Code: Select all

\documentclass[10pt,a4paper]{scrartcl}
\usepackage{ifthen}
%-----------------------------------Settings---------------------------------------------
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot[L]{\ifthenelse{\value{page}=1}{first page}{second page}}
%-----------------------------------Ende Settings----------------------------------------

\begin{document}
\section*{Stellungnahme}
\pagebreak
\subsection*{Rettungswege}
\label{LastPage}
\end{document}
I used the \ifthenelse command (from the ifthen package) instead of the \ifnum TeX primitive (after all you are writing with LaTeX and not with plainTeX) but of course this will also work:

Code: Select all

\fancyfoot[L]{\ifnum\thepage=1 first page\else second page \fi}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
nico
Posts: 20
Joined: Tue Jun 08, 2010 10:13 am

fancyhdr different first page

Post by nico »

Thank you very much, gmedina. This works for the header and footer, but i get a problem with the following line:

Code: Select all

\renewcommand{\headrulewidth}{\ifthenelse{\value{page}=1}{0.0pt}{0.4pt}}
The errors are:

Code: Select all

! Missing number, treated as zero.
! Illegal unit of measure (pt inserted).
Please see this example:

Code: Select all

\documentclass[10pt,a4paper]{scrartcl}

%-----------------------------------Packages---------------------------------------------
\usepackage{ifthen}
%-----------------------------------Ende Packages----------------------------------------

%-----------------------------------Settings---------------------------------------------

%--- Header and Footer ---
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{\ifthenelse{\value{page}=1}{0.0pt}{0.4pt}}

%-----------------------------------Ende Settings----------------------------------------

\begin{document}
\section*{Stellungnahme}
\ifthenelse{\value{page}=1}{0.0pt}{0.4pt}
\pagebreak
\subsection*{Rettungswege}
\ifthenelse{\value{page}=1}{0.0pt}{0.4pt}
\label{LastPage}
\end{document}
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

fancyhdr different first page

Post by gmedina »

Try this:

Code: Select all

\usepackage{everypage}
\AddEverypageHook{%
  \ifthenelse{\value{page}=1}%
    {\renewcommand{\headrulewidth}{0.0pt}}%
    {\renewcommand{\headrulewidth}{0.4pt}}%
}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
nico
Posts: 20
Joined: Tue Jun 08, 2010 10:13 am

Re: fancyhdr different first page

Post by nico »

Great, thank you!!
Post Reply