0

*enter image description here*

Please guide me, what should i used instead of this code, so that the current section name will be displayed instead of the chapter name as a left side of the header in the page. Thank you.

1
  • 3
    Welcome to TeX.SX! Instead of posting a screenshot of code it's better to show some of your code such that users can start immediately
    – user31729
    Sep 21 '15 at 16:39
1

You have to use \rightmark instead of \leftmark in your \rhead declaration. \rightmark contains the section info, while \leftmark is for the chapter:

\documentclass{book}

\usepackage{fancyhdr}

%\lhead[\normalfont\thepage]{\fancyplain{}\slshape{\rightmark}}
%\rhead[\fancyplain{}{\slshape{\rightmark}}]{\normalfont\thepage}

\fancyhead[LE,RO]{\normalfont\thepage}
\fancyhead[LO,RE]{\fancyplain{}\slshape{\rightmark}}
\fancyfoot{}

\pagestyle{fancy}

\begin{document}

\chapter{C1}

\section{S1}

\newpage
testpage 1
\newpage
testpage 2

\end{document}

Note that I used \fancyhead instead of \lhead and \rhead. It does the same, but you don't have to repeat everything.

2
  • Please, remove \rm and change it into \normalfont. Note that \rm has been deprecated for 20 years. Also \sl should be \slshape.
    – egreg
    Sep 21 '15 at 17:31
  • @egreg Done. I didn't think too much about the font style, just copied. \rm being deprecated is a good reason why I didn't know it :)
    – cauchy42
    Sep 21 '15 at 17:36

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.