TransWikia.com

Different header and footer for first page and for rest document

TeX - LaTeX Asked by begginer on August 15, 2021

I need to define a specific header and footer for the first page and modified header and footer for rest pages. I am familiar with fancyhdr package but from my understanding, I can only define not complicated headers and footers the same for all document by commands:

fancyhead[LO,RE]{}
fancyhead[RO,LE]{}
cfoot{}
fancyfoot[LO,RE]{}
fancyfoot[RO,LE]{}

I need to provide a template for the first page as follow:
enter image description here
And for the rest pages without Logo and Table.

The problems that I have:

  1. How to define different header and footer for the first page and for the rest document.
  2. How to create complex footer (table, number below, and page below the number) because when I am using commands fancyfoot and cfoot I got everything in the same line

EDIT:
Here is simple code:

documentclass[a4paper]{article}
usepackage[left=1.25cm, right=1.25cm,top=15mm,         bottom=20mm,includehead,includefoot]{geometry}

usepackage{graphicx}
usepackage{fancyhdr}           % fancy headers/footers

% Use fancyheadings stuff
pagestyle{fancyplain}{

% Definition of the header
renewcommand{headrulewidth}{0.6pt}
fancyhead[LO,RE]{bf Number}
fancyhead[RO,LE]{bf TEXT}

renewcommand{footrulewidth}{1.2pt}
fancyfoot[LO,RE]{small Title}
cfoot{vspace{0pt} smallbf Page thepage of pageref{END}}
fancyfoot[RO,LE]{Version number}
}

fancypagestyle{mypagestyle}{
% Definition of the header
renewcommand{headrulewidth}{0.6pt}
fancyhead[L]{bf Number}
fancyhead[R]{includegraphics[scale=0.2]{logo}}


renewcommand{footrulewidth}{1pt}
fancyfoot[L]{small number}
fancyfoot[C]{vspace{0pt} smallbf Page thepage of pageref{END}}
fancyfoot[R]{TEXT}
}

begin{document}
thispagestyle{mypagestyle}
setcounter{page}{1}
Title page
newpage
pagestyle{fancyplain}
section{The First Section}
Text text text text text text text text text text text text text text text         text text text text text text text text text text.
newpage
section{The Next Section}
Text text text text text text text text text text text text text text text text text text text text text text text text text.

label{END}
end{document} 

Problems:

  1. Text on the first page doesn’t start after the header.
  2. The header and footer for the second and first page are moved more than margins defined in geometry page (the footer is cut).

enter image description here

enter image description here

Based on geometry package the footer and header should “start” after margins:
enter image description here

One Answer

first change --- icon in header tool large reduce size to 0.1 scale

second change -- vspace in the foote not required since its 0pt and gives white space on top

Now have alook at first page

enter image description here

documentclass[a4paper]{article}
usepackage{geometry}

usepackage{graphicx}
usepackage{fancyhdr}           % fancy headers/footers

% Use fancyheadings stuff
pagestyle{fancyplain}{

% Definition of the header
%renewcommand{headrulewidth}{0.6pt}
%fancyhead[LO,RE]{bf Number}
%fancyhead[RO,LE]{bf TEXT}
%
%renewcommand{footrulewidth}{1.2pt}
%fancyfoot[LO,RE]{small Title}
%cfoot{vspace{0pt} smallbf Page thepage of pageref{END}}
%fancyfoot[RO,LE]{Version number}
%}

fancypagestyle{mypagestyle}{
% Definition of the header
renewcommand{headrulewidth}{0.6pt}
fancyhead[L]{bf Number}
fancyhead[R]{includegraphics[scale=0.1]{example-image-a}}


renewcommand{footrulewidth}{1pt}
fancyfoot[L]{small number}
fancyfoot[C]{ smallbf Page thepage of pageref{END}}
fancyfoot[R]{TEXT}
}

begin{document}
thispagestyle{mypagestyle}
setcounter{page}{1}
Title page
newpage
pagestyle{fancyplain}
section{The First Section}
Text text text text text text text text text text text text text text text         text text text text text text text text text text.
newpage
section{The Next Section}
Text text text text text text text text text text text text text text text text text text text text text text text text text.

label{END}
end{document} 

For the second page

Redefine pagestyle as mypagestylea rather than interfere with pagestyle fancy which is the default

now have alook at second page

documentclass[a4paper]{article}
usepackage{geometry}

usepackage{graphicx}
usepackage{fancyhdr}           % fancy headers/footers

% Use fancyheadings stuff
%pagestyle{fancyplain}{

% Definition of the header
%renewcommand{headrulewidth}{0.6pt}
%fancyhead[LO,RE]{bf Number}
%fancyhead[RO,LE]{bf TEXT}
%
%renewcommand{footrulewidth}{1.2pt}
%fancyfoot[LO,RE]{small Title}
%cfoot{vspace{0pt} smallbf Page thepage of pageref{END}}
%fancyfoot[RO,LE]{Version number}
%}

fancypagestyle{mypagestyle}{
% Definition of the header
renewcommand{headrulewidth}{0.6pt}
fancyhead[L]{bf Number}
fancyhead[R]{includegraphics[scale=0.1]{example-image-a}}

%defn of footer
renewcommand{footrulewidth}{1pt}
fancyfoot[L]{small number}
fancyfoot[C]{ smallbf Page thepage of pageref{END}}
fancyfoot[R]{TEXT}
}

fancypagestyle{mypagestylea}{
    % Definition of the header
    renewcommand{headrulewidth}{0.6pt}
    fancyhead[LO,RE]{bf Number}
    fancyhead[RO,LE]{bf TEXT}
    %
    renewcommand{footrulewidth}{1.2pt}
    fancyfoot[LO,RE]{small Title}
    cfoot{smallbf Page thepage of pageref{END}}
    fancyfoot[RO,LE]{Version number}
    }

begin{document}
thispagestyle{mypagestyle}
setcounter{page}{1}
Title page
newpage
pagestyle{mypagestylea}
section{The First Section}
Text text text text text text text text text text text text text text text         text text text text text text text text text text.
newpage
section{The Next Section}
Text text text text text text text text text text text text text text text text text text text text text text text text text.

label{END}
end{document} 

enter image description here

Answered by js bibra on August 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP