[Tex/LaTex] Line under chapter name at top of the page

chapterssectioning

I am writing a thesis, under the chapter name at the top of the page I would like a line to appear, but I don't have the palest idea on how to do that, I hope you can help.

Edit: I definitely wasn't clear enough. I meant this part of the page, as shown below:

enter image description here

Best Answer

You can use the fancyhdr package to customize the headers/footers of your document; a little example:

\documentclass{book}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{fancyhdr}
\usepackage{lipsum}% just to generate text for the example

\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL]{\nouppercase\leftmark}
\fancyhead[OR]{\nouppercase\rightmark}
\fancyhead[ER,OL]{\thepage}

\begin{document}

\chapter{Introduzione}
\lipsum[4]
\section{A Test Section}
\lipsum[1-3]

\end{document}

enter image description here

E stands for "even"; O, for "odd"; L, C, R stand for "left", "center", "right", respectively. So, for example, \fancyhead[EL]{<text>} will place <text> in the header to the left on even pages. By default, calling \pagestyle{fancy} draws a horizontal rule below the header.

I used \nouppercase since uppercased headers are not pleasing, but this is optional. The package documentation explains how you can further customize the marks used in the headers.