1

I am trying to add a header to my pages and in doing so I ran into the problem of not being able to change the default markup of fancyhdr headers. More specifically, I want the header of every page to include the subsection and section without numberings and in regular text, so no italics or capitals.

The following MWE illustrates my problem.

\documentclass[10pt]{article}

\usepackage{fancyhdr}
\pagestyle{fancy}

\begin{document}

\section{Section}

0

\subsection{Subsection}

1

\newpage

2

\end{document}

The first page's header does not show the title of the subsection,

Header of the first page

whereas the second page does.

Header of the second page

Both however have (sub)section numberings and sport markup. I would like them to look like this:

Desired format

I have tried renewing the appropriate commands which did not do me much good.

Any help is appreciated!

1

Using this answer I solved the problem in this way:

\documentclass[10pt]{article}

\usepackage{fancyhdr}
\pagestyle{fancy}

\let\Sectionmark\sectionmark
\def\sectionmark#1{\def\Sectionname{#1}\Sectionmark{#1}}
\let\Subsectionmark\subsectionmark
\def\subsectionmark#1{\def\Subsectionname{#1}\Subsectionmark{#1}}
\let\Subsubsectionmark\subsubsectionmark
\def\subsubsectionmark#1{\def\Subsubsectionname{#1}\Subsubsectionmark{#1}}

\lhead{\Subsectionname}
\rhead{\Sectionname}

\begin{document}

\section{Section}

0

\subsection{Subsection}

1

\newpage

2

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.