[Tex/LaTex] Remove name of section from header in pagestyle{fancy} (Notice: document class=article)

fancyhdrheader-footer

I am forced to use the document class: article, because of several packages that I use and format restrictions.

I have long names for some of the sections and subsections, so there is no room to display it all in the header.

I only use: section–>subsection–>subsubsection, no "chapter".

I wish the header to display only subsection names and numbers, not sections. How do I do that?

When I use \fancyhf{} everything disappears from the header.

I also tried a solution that I found on this website

\documentclass[oneside,a4paper]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\slshape }
\fancyfoot[R]{Page \thepage\ of \pageref{LastPage}}

… but it doesn't display anything. I think the problem might be that the document class is different than what they had there, but I cannot change that.

Thanks for your help!

Best Answer

You need to redefine the commands which fills the marks:

\documentclass{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand\sectionmark[1]{} %section doesn't set a mark
\makeatletter
\renewcommand\subsectionmark[1]{% but subsection should
 \markright{\MakeUppercase{\ifnum\c@secnumdepth >\m@ne \thesubsection \quad \fi #1}}}
\makeatother 
\begin{document}
\section{abc}\subsection{subsection}
\lipsum   
\end{document}
Related Question