2

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
\fancyhead{}
\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.

2

You can use something like

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

enter image description here

enter image description here

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}
1
  • Thank you very much. That was exactly what I was looking for.
    – Ito Pakito
    Jun 27 '15 at 16:59

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.