# How to assign a word for each section that appears in the header of each page?

My request is a little bit strange but I really need your help. Basically, I want to use an equivalent of \leftmark (to put the chapter in header) for a new command.

For example, let's say I want to write the following:

\documentclass[a4paper,10pt,twoside]{article}

...
\usepackage{fancyhdr} % Needed to define custom headers/footers
\pagestyle{fancy} % Enables the custom headers/footers
\fancyfoot{}
\fancyhead[LE]{\thepage $\mid$ here the category}
\fancyhead[RO]{here the category $\mid$ \thepage}

\begin{document}

\aNewCommand{Politics}
\section{Obama...}
my text here...

\aNewCommand{Sport}
\section{The World cup...}
my text here
etc

\end{document}


I want the words Politics and Sport to be written only in header (not somewhere in the page). The categories do not need to be enumerated.

If possible, I want to avoid the use of \chapter{...}.

I hope you see what I mean. Thanks for reading.

You can use something like

\renewcommand\sectionmark[1]{}
\newcommand\Category[1]{\markboth{\MakeUppercase{#1}}{}


Code:

\documentclass[a4paper,10pt,twoside]{article}
\usepackage{fancyhdr} % Needed to define custom headers/footers
\pagestyle{fancy} % Enables the custom headers/footers
\fancyhf{}
\fancyhead[LE]{\thepage~$\mid$~\leftmark}
\fancyhead[RO]{\leftmark~$\mid$~\thepage}

\renewcommand\sectionmark[1]{}
\newcommand\Category[1]{\markboth{\MakeUppercase{#1}}{}}

\usepackage{blindtext}% for dummy text
\begin{document}

\Category{Politics}
\section{Obama...}
\subsection{Test}
\Blindtext

\Category{Sport}
\section{The World cup...}
\Blindtext
\end{document}

• Thank you very much. That was exactly what I was looking for. Jun 27 '15 at 16:59