[Tex/LaTex] How to insert the section name into the header


I'm trying to use fancyhdr to put the current section name into my header, but the below code just returns a blank header. I can display the current page number without a problem.




What is the correct way to do this?

Best Answer

It is not necessary to use the packages sectsty, parskip and fancyhdr together with a KOMA-Script class.

This classes define the two commands \setkomafont and addtokomafont to change the font of the different elements in a document.

The class option parskip can be used to get a parskip instead of a parindent.

Headers and footers can be set by the package scrlayer-scrpage or the older scrpage2. Both are part of the KOMA-Script bundle.

The KOMA-Script classes have a special command for unnumbered section headings producing an entry in the page header and an entry in the table of contents: \addsec. Use this instead of \section*.

For further Information have a look at the KOMA-Script documentation.


\usepackage[automark]{scrlayer-scrpage}% or alternativly scrpage2  

\usepackage{blindtext}% dummy text


enter image description here