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.
\documentclass[paper=a4,fontsize=11pt]{scrartcl}
\usepackage[letterspace=150]{microtype}
\usepackage{sectsty}
\usepackage{parskip}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\chead{\rightmark}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
\section*{sect.name}
\subsection*{sub.sect.name.a}
\section*{sub.sect.name.b}
\end{document}
What is the correct way to do this?
Best Answer
It is not necessary to use the packages
sectsty
,parskip
andfancyhdr
together with a KOMA-Script class.This classes define the two commands
\setkomafont
andaddtokomafont
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 olderscrpage2
. 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.