# Subsection only in even header

Starting from the following code:

\documentclass{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\fancypagestyle{standardstyle}{%
\fancyhf{}
\fancyfoot[RE]{\thepage}
\fancyfoot[LO]{\thepage}
}
\begin{document}
\pagestyle{standardstyle}
\renewcommand{\chaptermark}[1]{\markboth{\thechapter. #1}{}}
\chapter{test chapter}
\section{test section}
\subsection{test subsection}
\lipsum\lipsum\lipsum
\end{document}

How can I put the subsection number and name into the even header instead of the section name?

-
novermind, found it, it's: \renewcommand{\subsectionmark}[1]{\thesubsection. \markright{#1}{}}. Still, could someone explain this code? –  Michelangelo May 16 at 20:27

The contents of \leftmark and \rightmark is determined by the commands \markboth and \markright, that usually are issued by sectioning commands such as \chapter or \section.

There is an additional level, though. When you do \chapter{Title}, among other things LaTeX issues \chaptermark{Title}; similarly \section{Title} and \subsectiontitle issue \sectionmark{Title} and \subsectionmark{Title}.

Usually the definition of \chaptermark contains \markboth{<code>}{} which sets the \leftmark to <code> (the second argument would set the \rightmark), while \sectionmark usually contains \markright{<code>}.

The standard definition of \subsectionmark is “do nothing”.

Thus, if you want the current subsection number and title in the header, you should define

\renewcommand{\subsectionmark}[1]{\markright{\thesubsection. #1}}

You probably should have also

\renewcommand{\sectionmark}[1]{\markright{\thesection. #1}}

in order not to have an empty header if there is no current subsection, but there is a current section.

-