[Tex/LaTex] How to make the first page of a latex document like other pages

fancyhdrheader-footerspacing

I am writing a paper with the article document class. The first page contains a large footer than other pages. I want to make it filled with text like the other pages and contains the same footer. a minimal working code is:

\documentclass[11pt]{article}
%\usepackage[width=5cm,height=20cm]{geometry}
\usepackage[b5paper,lmargin=2cm,rmargin=2cm,tmargin=2.5cm,bmargin=4.3cm]{geometry}
\usepackage{graphicx} % for pdf, bitmapped graphics files
%\usepackage{indentfirst}
\usepackage{amsmath} % assumes amsmath package installed
\usepackage{amssymb}  % assumes amsmath package installed
%\usepackage{deleq} % to divide on equation
%\usepackage{bbm} % to represent the space dimension
%\usepackage{bbding} % to represent the space dimension
\usepackage{dsfont} %to represent the space dimension
\usepackage{color}
\usepackage{algorithm}
\setcounter{secnumdepth}{3}
\usepackage{multicol}%%%%%%%%%%%%
%\usepackage{lipsum}%%%%%%%%%%%%%%%%%%%
\usepackage{theorem}
\newtheorem{theorem}{Theorem}
\newcounter{tempcount}
\graphicspath{{figures/}}

\usepackage[T1]{fontenc}
\usepackage{mathptmx}
\usepackage{titlesec}
\titleformat{\section}[block]
  {\fontsize{12}{15}\bfseries\rmfamily}
  {\thesection}
  {1em}
  {}
\titleformat{\subsection}[hang]
  {\fontsize{12}{15}\itshape\rmfamily}
  {\thesubsection}
  {1em}
  {}
\titleformat{\subsubsection}[hang]
  {\fontsize{12}{15}\itshape\rmfamily}
  {\thesubsubsection}
  {1em}
  {}  
%\usepackage{fontspec}
%\setmainfont{Times New Roman}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot{} %\fancyfoot[LE,RO]{\thepage}
%\fancyhead[L] {\thepage\\}CO,CE
%\fancyhead[le,ro]{}
\fancyhead[le,ro]{\thepage\\ \it{LPVIOID-Toolbox .}}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
%\headsep=10pt
\footskip=13pt

\titlespacing\section{0pt}{6pt}{6pt}
\titlespacing\subsection{0pt}{6pt}{6pt}
\titlespacing\subsubsection{0pt}{6pt}{6pt}

\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
\newcommand{\ParGraph}{\\ \indent}
\usepackage[noblocks]{authblk}
\title{\bfseries \fontsize{13}{15}\selectfont
LPVIOID- toolbox}

\author[ ]{\bfseries \fontsize{11}{13}\selectfont Mustafa Rabeei}
\affil[ ]{\itshape \fontsize{10}{15}\selectfont Electrical Engineering Department.
 E-mails: {\tt eng.mustafa.rabeay@gmail. }}

\usepackage{lipsum}

\begin{document}
\date{}
\graphicspath{{figures/}}
\maketitle
\thispagestyle{fancy}
%\thispagestyle{empty}
%\pagestyle{empty}
%\pagestyle{headings}
\setcounter{page}{1}

\pagenumbering{arabic}

\section{the first section}
\lipsum
\section{the second section}
\lipsum[1-10]
\end{document}

Best Answer

The problem is a duplicate of question: fancyhdr - anomalous behaviour on first page. You customize the header so that it has two lines (by including a line-break \\).

The solution is to manually set the \headheight to be large enough with a command like

\setlength{\headheight}{25.2pt}

or, as suggested in the documentation when including a multi-line header,

\addtolength{\headheight}{\baselineskip}

If you want a more complete solution that works automatically after several runs, look at heiko-oberdiek's answer to a related question.

Details

The issue is that fancyhdr does not "look a head" to see what content will appear in the header on each page before it typesets it. This content is potentially dynamic, and can therefore have different heights, hence it simply checks to see if the current height will fit in the allocated \headheight space on each page. If not, it emits a warning with the current height of the header and suggests that you set the \headheight to a larger value.

See also the discussion in this answer.

Here is a minimal example demonstrating the problem.

\documentclass[11pt]{article}
\newcommand{\hdrparams}{%
  textheight=\the\textheight, voffset=\the\voffset,
  headheight=\the\headheight, headsep=\the\headsep}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[c]{\hdrparams}
\usepackage{lipsum}

%\setlength{\headheight}{26pt}  % Hack that fixes the problem.
\begin{document}
\thispagestyle{fancy}
\section{the first section}
\lipsum
\section{the second section}
\lipsum[1-10]
\end{document}

On the first page \headheight=12pt while on the rest \headheight=25.2842pt. This value can be deduced from the warning message from latex the compile output and log:

Package Fancyhdr Warning: \headheight is too small (12.0pt): 
 Make it at least 25.2842pt.
 We now make it that large for the rest of the document.
 This may cause the page layout to be inconsistent, however.

References

Related Question