TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Starting from the following code:

\renewcommand{\chaptermark}[1]{\markboth{\thechapter. #1}{}}
\chapter{test chapter}
\section{test section}
\subsection{test subsection}

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

share|improve this question
novermind, found it, it's: \renewcommand{\subsectionmark}[1]{\thesubsection. \markright{#1}{}}. Still, could someone explain this code? – Michelangelo May 16 '14 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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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