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?


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

  • Many thanks for this. I'm using writelatex.com, which doesn't seem to support scrlayer-scrpage. If I use scrpage2 would the rest of the code be the same? – user2950747 Jul 23 '14 at 18:49
  • Yes, the rest would be the same. The font element pagehead is then only a synonym for the font element pageheadfoot. You will get a warning as information that the font of the pagefoot is also changed. writelatex.com doesn't know scrlayer-scrpage because they have an older version of KOMA-Script. – esdd Jul 23 '14 at 19:26
  • Thanks again. It's working fine in TeXShop on a Mac when I use \usepackage[automark]{scrlayer-scrpage}, but not if I use \usepackage[automark]{scrpage2}. I haven't made any other changes to the code. – user2950747 Jul 23 '14 at 19:41
  • Oh sorry, I forgot to activate the pagestyle explicitly. Now I have added the line \pagestyle{scrheadings}. – esdd Jul 23 '14 at 23:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.