I am a complete newbie with LaTeX and I couldn't find a solution to the following problem: I want the section to appear on the left hand side of the header, the subsection in the middle and the page to the left. I wanted to use the following:
\usepackage{fancyhdr}
\usepackage[a4paper,left=2.5cm,right=2.5cm,top=3.0cm,bottom=1.5cm,headsep=1cm{geometry}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\thepage}
\fancyhead[C]{\nouppercase{\rightmark}}
\fancyhead[L]{\nouppercase{\leftmark}}
\fancyheadoffset[R,L]{1cm}
\renewcommand{\headrulewidth}{0.5pt}
It works perfectly for the section and the page but the subsection doesn't appear at all. I managed to redefine \rightmark
via \renewcommand{\rightmark}{\thesubsection}
so that at least the number of the subsection appears but how do I get the title of the subsection as well into the center of the header?
Best Answer
The macro
\rightmark
is automatically update by LaTeX when it processes a\markright
instruction, so you mustn't redefine it yourself.By default, with the
article
class,\section
issues\markboth
, which sets\leftmark
(and\rightmark
, but usually sets this to empty) via the macro\sectionmark
that's automatically called by\section
.You have to redefine
\subsectionmark
that, by default, does nothing to issue\markright
:Full example:
As Gustavo Mezzetti remarks, the macro
\subsectionmark
does execute\markright
, providedtwoside
is in force and the page style is set toheadings
ormyheadings
. However, this is not relevant for the task at hand, since the pagestyle is declared to befancy
.