1

fancyhdr automatically puts the section title on the right header. When I try

\begin{document}

\pagestyle{fancy}

\chead{\rightmark}
\rhead{}
\cfoot{\thepage}

\end{document}

nothing appears in the header. Help!

1
  • What class are you using? If it's article, you should say also \lhead{} to clear the left field and use \chead{\leftmark}.
    – egreg
    May 11, 2013 at 22:34

1 Answer 1

5

Please always post complete documents that show the problem.enter image description here

LaTeX only distinguishes left and right marks when it is using a twoside setting:

Furthermore \rightmark is by default the set by subsection at the top of the current page.

\documentclass[twoside]{article}

\usepackage{fancyhdr}

\pagestyle{fancy}

\lhead{}
\chead{\rightmark}
\rhead{}
\cfoot{\thepage}

\begin{document}

\section{aaaa}
\subsection{bbb}
ccc

\clearpage
bbb
\end{document}
3
  • That's the \leftmark and it's not centered.
    – egreg
    May 11, 2013 at 22:35
  • @egreg sorry You just got your comment in before I deleted the answer, undeleted it with a revised image:-) May 11, 2013 at 22:45
  • I realized that \rightmark returns subsection title and \leftmark returns section title. I somehow thought that \leftmark returns chapter title and therefore irrelevant. Thanks for your help!
    – ashpool
    May 12, 2013 at 0:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .