how to display current section title in header

You can use fancyhdr.

\documentclass{book}

\usepackage{fancyhdr}
\usepackage{lipsum}% just to generate text for the example

\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\rightmark}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}

\begin{document}
\chapter{Chapter title}
\section{section title}

\lipsum[1-20]

\end{document}
  • \pagestyle{fancy} sets the page style to the style delivered and editable with fancyhdr.
  • \fancyhf{} sets all head and foot elements empty.
  • \fancyhead[L]{\rightmark} sets the left head element to \rightmark, which contains the current section (\leftmark is the current chapter).
  • \fancyhead[R]{\thepage} sets the right head element to the page number.
  • \renewcommand{\headrulewidth}{0pt} lets the head rule disappear.

Possible selectors for the optional argument of \fancyhead/\fancyfoot are L (left), C (center) or R (right) for the position of the element and E (even) or O (odd) to distinguish even and odd pages. If you omit E/O the element is set for all pages.


Updated Answer

Please use scrlayer-scrpage instead …

\documentclass{book}

\usepackage{scrlayer-scrpage}
\usepackage{lipsum}% just to generate text for the example

\pagestyle{scrheadings}
\clearpairofpagestyles
\ohead{\rightmark}
\cfoot[\pagemark]{\pagemark}

\begin{document}
\chapter{Chapter title}
\section{section title}

\lipsum[1-20]

\end{document}

Except for \clearscrheadfoot{} which is replaced by \clearpairofpagestyles nothing has changed for the user.

You may also like to read further in my german blog: TeX-Beispiel des Monats „Layout II: Kopf- und Fußzeilen“.


Original Answer

You can use scrpage2 from KOMA-Script bundle.

\documentclass{book}

\usepackage{scrpage2}
\usepackage{lipsum}% just to generate text for the example

\pagestyle{scrheadings}
\clearscrheadfoot{}
\ohead{\rightmark}
\cfoot[\pagemark]{\pagemark}

\begin{document}
\chapter{Chapter title}
\section{section title}

\lipsum[1-20]

\end{document}
  • \pagestyle{scrheadings} sets the page style to the style delivered and editable with scrpage2.
  • \clearscrheadfoot{} sets all head and foot elements empty.
  • \ohead{\rightmark} sets the outer head element (o) to \rightmark, which contains the current section (\leftmark is the current chapter).
  • \cfoot[\pagemark]{\pagemark} sets the page number to the center foot element (c). The optimal argument defines the plain style (used on chapter starting pages).

This image shows all possible elements.

scrpage2 head/foot elements
source: scrguien.pdf, p. 198