[Tex/LaTex] Header and footer not working on class file

documentclass-writingfancyhdrheader-footer

I am trying to make header and footer using fancyhdr.

Following the manuals available in other question I have defined header and footer in my class file but they are not shown in output file. Could you please advice what am I doing wrong?

My class file looks like this:

    % Definicja klasy
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{KPSEClass}[2016/3/19 KPSE LaTeX class]

% Polskie formatowanie
\usepackage[T1]{fontenc}
\usepackage[polish]{babel}
\usepackage[utf8]{inputenc} 
\frenchspacing
\usepackage{indentfirst} 

% Nagłówek
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\rhead{Share\LaTeX}
\lhead{Guides and tutorials}
\rfoot{Page \thepage}

% Domyślny TPL
\LoadClass[twocolumn]{article}

\RequirePackage{xcolor} % Kolory
\usepackage{mdframed} % Boxy

% Formatowanie tytułu

\renewcommand\@maketitle{%

\hfill

\begin{minipage}{0.95\textwidth}
\vskip 2em
\rule{\linewidth}{0.4pt}
{\LARGE \centering \textbf \@title \par }
\rule{\linewidth}{0.4pt}
\vskip 1 em
{\large \centering \@author \par}
\end{minipage}
\vskip 1em \par
}

and document:

\documentclass{KPSEClass}

\author{Autor}
\title{Testowy artykuł}

\begin{document}
\maketitle
\section{Małe}
Małe\footnote{Nie większe niż bardzo małe} jest piekne.
\end{document}

Output:

Output

Best Answer

Here's a small fix of the .cls file by patching \maketitle to use a \titlepagestyle which is itself some wrapper command which can be redefined to use some other pagestyle. It uses fancy by default.

Now the header and footer settings are applied for the title page (if this is really needed at all...)

    % Definicja klasy
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{KPSEClass}[2016/3/19 KPSE LaTeX class]

% Polskie formatowanie
\RequirePackage[T1]{fontenc}
\RequirePackage[polish]{babel}
\RequirePackage[utf8]{inputenc} 
\frenchspacing
\RequirePackage{indentfirst} 

% Nagłówek
\RequirePackage[a4paper,width=150mm,top=25mm,bottom=25mm]{geometry}
\RequirePackage{fancyhdr}
\RequirePackage{xpatch}


\pagestyle{fancy}
\fancyhf{}
\rhead{Share\LaTeX}
\lhead{Guides and tutorials}
\rfoot{Page \thepage}

% Domyślny TPL
\LoadClass[twocolumn]{article}

\RequirePackage{xcolor} % Kolory
\RequirePackage{mdframed} % Boxy

% Formatowanie tytułu


\newcommand{\titlepagestyle}{fancy}
\xpatchcmd{\maketitle}{\thispagestyle{plain}}{\thispagestyle{\titlepagestyle}}{}{}

\renewcommand\@maketitle{%
\hfill

\begin{minipage}{0.95\textwidth}
\vskip 2em
\rule{\linewidth}{0.4pt}
{\LARGE \centering \textbf \@title \par }
\rule{\linewidth}{0.4pt}
\vskip 1 em
{\large \centering \@author \par}
\end{minipage}
\vskip 1em \par
}

Document .tex

\documentclass{KPSEClass}

\author{Autor}
\title{Testowy artykuł}

\begin{document}
\pagestyle{fancy}
\maketitle
\section{Małe}
Małe\footnote{Nie większe niż bardzo małe} jest piekne.

\end{document}

enter image description here

Related Question