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


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:

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



\section{A Test Section}


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.