Deleting header rule on the first page

fancyhdrheader-footerrules

I would like to generate myself a standard, simple report template. In the attached example I would like to have different set of headers on the first page. I'm stuck with a problem trying to remove the header line from the first page.

Code

% vim:ft=tex:
%
\documentclass[12pt]{article}

\usepackage{fontspec}
\setmainfont{Arial}

% Use if Arial font unavailable
% \usepackage{helvet}
% \renewcommand{\familydefault}{\sfdefault}

% Geometry has to be loaded before the footer
\usepackage{geometry}
 \geometry{
 a4paper,
 left=20mm,
 top=20mm,
 bottom=20mm,
 top=20mm
 }

\usepackage{lastpage} % for the last page number
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
% Add a line above footer
\renewcommand{\footrulewidth}{0.4pt}% default is 0pt
% Add line above footer
\renewcommand{\headrulewidth}{0.4pt}
\fancyfoot[OR]{\footnotesize \thepage\ /\ \pageref{LastPage}}

% Define style to be used for the first page
\fancypagestyle{firststyle}
{
   \fancyhf{}
   \renewcommand{\headrulewidth}{0.0pt} % I would hope for this to delete header rule on the first page
   \fancyfoot[OR]{\footnotesize \thepage\ /\ \pageref{LastPage}}
}

% Title page configuration
\title{\vspace{-2cm}Title of the Document\vspace{-5mm}}
\author{Author\vspace{-5mm}}
\date{\today}


\begin{document}

% Use special first page style on the first page
\thispagestyle{firststyle}

\maketitle\thispagestyle{fancy}

\section{Section}

\subsection{Section two}

Sample document

\end{document}

Best Answer

You called \thispagestyle twice on the same page, the second time again with the default style. Since \thispagestyle will only affect the style on the current page, you don't need to reset the style like this.

However, you should call \thispagestyle after \maketitle, because \maketitle internally calls \thispagestyle{plain}.

% vim:ft=tex:
%
\documentclass[12pt]{article}

\usepackage{fontspec}
\setmainfont{Arial}

% Use if Arial font unavailable
% \usepackage{helvet}
% \renewcommand{\familydefault}{\sfdefault}

% Geometry has to be loaded before the footer
\usepackage{geometry}
\geometry{
 a4paper,
 left=20mm,
 top=20mm,
 bottom=20mm,
 top=20mm
}

\usepackage{lastpage} % for the last page number
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
% Add a line above footer
\renewcommand{\footrulewidth}{0.4pt} % default is 0pt
% Add a line below header
\renewcommand{\headrulewidth}{0.4pt}
\fancyfoot[OR]{\footnotesize \thepage\ /\ \pageref{LastPage}}

% Define style to be used for the first page
\fancypagestyle{firststyle}{
  \fancyhf{}
  \renewcommand{\headrulewidth}{0.0pt} 
  \fancyfoot[OR]{\footnotesize \thepage\ /\ \pageref{LastPage}}
}

% Title page configuration
\title{\vspace{-2cm}Title of the Document\vspace{-5mm}}
\author{Author\vspace{-5mm}}
\date{\today}


\begin{document}

% Use special first page style on the first page

\maketitle
\thispagestyle{firststyle}

\section{Section}

\subsection{Section two}

Sample document

\newpage

More text

\end{document}
Related Question