0

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} \small\bf 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} \small\bf 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

6
  • For question 1, define a new pagestyle with the command \fancypagesstyle{mypagestyle}{...} and use at the relevant place \thispagestyle{mypagestyle}. For question 2, please provide a small complete document with what you've tried. – Bernard Apr 12 '20 at 11:25
  • Hello there! This is Tom from the Overleaf Support Team. Please note that I removed the overleaf tag as this is not directly overleaf-related. – yo' Apr 12 '20 at 13:33
  • @Bernard, please look at the edited version. – begginer Apr 12 '20 at 13:42
  • @begginer, add the showframe option to geometry so you can have better idea what is going on margins. – Sigur Apr 12 '20 at 14:20
  • 1
    It should be noted that fancyhdr likes to keep the same size header for the entire document. Also, \fancypagestyle just changes the fancyhdr options and calls \pagestyle{fancy} again. – John Kormylo Apr 12 '20 at 20:41
1

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} \small\bf 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]{ \small\bf 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} \small\bf 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]{ \small\bf 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{\small\bf 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.