# Last Section appearing on top with usage of pagestyle fancy

I am having trouble including page numbers in my resume. I earlier used \pagestyle{empty} for non-numbered page but thought to have page numbers. So I decided to use following packages which works for numbering. however, the last section in the pages, appearing on top. If I remove these packages, it works fine.

: A Key thing to note is my sections are non-numbered for actual page display (as they should be) but on the top it appears with numbering.

Yes I am using \fancyhdr{} before \cfoot. I believe there is some incompatibility between packages, I am using since if I remove \pagestyle{fancy} and put \pagestyle{empty} it works as expected but of course pages will not be numbered.

\documentclass[a4paper,12pt]{article}

\usepackage{titlesec}

\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{lastpage}
\cfoot{\thepage\ of \pageref{LastPage}}

\titleformat{\section}{\LARGE\scshape\raggedright}{}{0em}{}[\titlerule]
\titlespacing{\section}{0pt}{2.5pt}{2.5pt}

\titleformat{\subsection}{\large\scshape\raggedright}{\hspace{0.25cm}}{0em}{}
\titlespacing{\subsection}{0pt}{2.5pt}{2.5pt}

%\pagestyle{empty} % non-numbered pages

\begin{document}

\section{One}
\section{Two}
\end{document}



Output

• Please show us a minimal working example (MWE) then we have not to guess what you are doing! – Mensch Jun 24 at 17:26
• Apologies, I might have to add little big code since I believe it is about compatibility between packages. – Joe Jun 24 at 18:50
• If you like my answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and/or marking it as the accepted answer (by clicking on the checkmark ✓). – Mensch Aug 12 at 17:28

Well, I'm not sure I understand you right:

It seems you want to get rid of the printed section name in header with style fancy ...

Style fancy is predefined and adds the section name and an headrule to the headers. To get rid of them you need to redefine style fancy like this:

\pagestyle{fancy}
\fancyhf{} % <==========================================================
\cfoot{\thepage\ of \pageref{LastPage}}


With \fancyhf{} you delete all predefined things, with \renewcommand{\headrulewidth}{0pt} you delete the headrule.

With the following complete mwe

\documentclass[a4paper,12pt]{article}

\usepackage{titlesec}

\usepackage{lastpage}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % <==========================================================
\cfoot{\thepage\ of \pageref{LastPage}}

\titleformat{\section}{\LARGE\scshape\raggedright}{}{0em}{}[\titlerule]
\titlespacing{\section}{0pt}{2.5pt}{2.5pt}

\titleformat{\subsection}{\large\scshape\raggedright}{\hspace{0.25cm}}{0em}{}
\titlespacing{\subsection}{0pt}{2.5pt}{2.5pt}

\begin{document}
\section{One}
\section{Two}

\end{document}


you get the result: