LaTeX forum ⇒ Page Layoutfancyhdr different first page

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

fancyhdr different first page

Postby nico » Thu Jun 17, 2010 12:14 pm

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:
  1. \documentclass[10pt,a4paper]{scrartcl}
  2.  
  3. %-----------------------------------Settings---------------------------------------------
  4. \usepackage{fancyhdr}
  5. \pagestyle{fancy}
  6. %\makeatletter
  7. \ifnum\thepage=1
  8. \fancyfoot[L]{first page}
  9. \else
  10. \fancyfoot[L]{other pages}
  11. \fi
  12. %\makeatother
  13. %-----------------------------------Ende Settings----------------------------------------
  14.  
  15. \begin{document}
  16. \section*{Stellungnahme}
  17. \pagebreak
  18. \subsection*{Rettungswege}
  19. \label{LastPage}
  20. \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.

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

Postby gmedina » Thu Jun 17, 2010 2:17 pm

Hi, nico

try with something like this:

  1. \documentclass[10pt,a4paper]{scrartcl}
  2. \usepackage{ifthen}
  3. %-----------------------------------Settings---------------------------------------------
  4. \usepackage{fancyhdr}
  5. \pagestyle{fancy}
  6. \fancyfoot[L]{\ifthenelse{\value{page}=1}{first page}{second page}}
  7. %-----------------------------------Ende Settings----------------------------------------
  8.  
  9. \begin{document}
  10. \section*{Stellungnahme}
  11. \pagebreak
  12. \subsection*{Rettungswege}
  13. \label{LastPage}
  14. \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:

  1. \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

Postby nico » Thu Jun 17, 2010 8:01 pm

Thank you very much, gmedina. This works for the header and footer, but i get a problem with the following line:
  1. \renewcommand{\headrulewidth}{\ifthenelse{\value{page}=1}{0.0pt}{0.4pt}}


The errors are:
  1. ! Missing number, treated as zero.
  2. ! Illegal unit of measure (pt inserted).


Please see this example:
  1. \documentclass[10pt,a4paper]{scrartcl}
  2.  
  3. %-----------------------------------Packages---------------------------------------------
  4. \usepackage{ifthen}
  5. %-----------------------------------Ende Packages----------------------------------------
  6.  
  7. %-----------------------------------Settings---------------------------------------------
  8.  
  9. %--- Header and Footer ---
  10. \usepackage{fancyhdr}
  11. \pagestyle{fancy}
  12. \renewcommand{\headrulewidth}{\ifthenelse{\value{page}=1}{0.0pt}{0.4pt}}
  13.  
  14. %-----------------------------------Ende Settings----------------------------------------
  15.  
  16. \begin{document}
  17. \section*{Stellungnahme}
  18. \ifthenelse{\value{page}=1}{0.0pt}{0.4pt}
  19. \pagebreak
  20. \subsection*{Rettungswege}
  21. \ifthenelse{\value{page}=1}{0.0pt}{0.4pt}
  22. \label{LastPage}
  23. \end{document}

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

Postby gmedina » Thu Jun 17, 2010 11:30 pm

Try this:

  1. \usepackage{everypage}
  2. \AddEverypageHook{%
  3. \ifthenelse{\value{page}=1}%
  4. {\renewcommand{\headrulewidth}{0.0pt}}%
  5. {\renewcommand{\headrulewidth}{0.4pt}}%
  6. }
1,1,2,3,5,8,13,21,34,55,89,144,233,...

nico
Posts: 20
Joined: Tue Jun 08, 2010 10:13 am

Postby nico » Fri Jun 18, 2010 9:13 am

Great, thank you!!


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 1 guest