[Tex/LaTex] how to display current section title in header

header-footer

how to display current section title in header insted of chapter title?

I'm using book and fancychap

MWE

\documentclass [11pt,oneside,final]{book}
\usepackage[nohints]{minitoc}
\usepackage[round]{natbib}
\usepackage{longtable}
\usepackage[font={footnotesize,it}]{caption}
\usepackage{bookman} 
\usepackage[T1]{fontenc} 
\usepackage{setspace}
\doublespacing
%\onehalfspacing
\usepackage{multirow}
\usepackage[left=35mm,top=30mm,right=30mm,bottom=30mm]{geometry}
\pagenumbering{Roman}
\usepackage[small,compact]{titlesec}
\usepackage[Lenny]{fncychap}
\usepackage{arabtex}
\usepackage{cp1256}
\setcode{cp1256}
\usepackage{float}
\usepackage[final]{graphicx}
\usepackage{epstopdf}
\usepackage{array}

\setarab
\raggedbottom
\begin{document}
\chapter{introduction} \thispagestyle{empty}

\section{one}
bla bla bla bla bla

\section{two}
bla bla bla bla 

\end{document}

Best Answer

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.

Related Question