[Tex/LaTex] How to add the current section name to the top


I'm trying to get the current section name and to add it to the header at right.


{\parindent \z@
{\raggedright \Huge #1}%
\vskip 20\p@
\hrule height 1pt
\vskip 45\p@




How do I to get the current section name and to put it into that line without adding it to TOC, TO Tables and TO Figures, please?

Best Answer

If I understand you question correctly, you are trying to add a header on content pages without adding the same header to the TOC, LOT, LOF pages.

This is best accomplished with the fancyhdr package, which will make regular pages have a header that you define, while keeping frontmatter pages and other special pages (like first pages of Chapters, for instance) as "plain" style, which simply has a page number at the bottom.

This code gives just that:

\usepackage{blindtext} % For example

\fancyhead{} % Clear the headers
\renewcommand{\headrulewidth}{0pt} % Width of line at top of page
\fancyhead[R]{\slshape\leftmark} % Mark right [R] of page with Chapter name [\leftmark]

\pagestyle{fancy} % Set default style for all content pages (not TOC, etc)