[Tex/LaTex] Understanding headers in scrartcl

fancyhdrheader-footerkoma-script

I would like to get a better understanding, why using fancyhdr is not recommended using scrartcl. So far I haven't had any problems using them together but the output is always complaining that I shouldn't use fancyhdr with scrartcl. Instead I should use scrlayer-scrpage. Can somebody please explain the reason why I shouldn't use fancyhdr?

\documentclass[a4paper,pagesize ,landscape, fontsize=6pt]{scrartcl}

\usepackage[left=0.75cm,right=0.75cm, top=1cm, bottom=0.75cm]{geometry}
\usepackage{multicol}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{fancyhdr}

%\usepackage{scrlayer-scrpage}

\setlength{\columnsep}{25pt}
\setlength{\columnseprule}{0.4pt}

\pagestyle{fancy}
\fancyhf{}
\rhead{Name}
\chead{Page \thepage}
\lhead{Title description}

\begin{document}

    \begin{multicols*}{3}
        Some entries here 

        \columnbreak

        and some entries there

        \columnbreak

        and the list goes on 
    \end{multicols*}
\end{document}

Best Answer

You can only use one of the packages scrlayer-scrpage, scrpage2 (predecessor of scrlayer-scrpage), fancyhdr, ...

The recommended package for use with a KOMA-Script class is scrlayer-scrpagebecause it is part of the KOMA-Script bundle and you can set and change options in the same way as for the class, see the KOMA-Script documentation. I really suggest to use scrlayer-scrpage.

Your header with scrlayer-scrpage:

\documentclass[
  %a4paper,% default
  %pagesize,% default since version 3.17
  landscape,
  fontsize=6pt,
]{scrartcl}
\usepackage[left=0.75cm,right=0.75cm, top=1cm, bottom=0.75cm]{geometry}
\usepackage{multicol}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage[headsepline]{scrlayer-scrpage}
\clearpairofpagestyles
\ohead{Name}
\chead{\pagemark}
\ihead{Title description}

\renewcommand*\pagemark{{\usekomafont{pagenumber}Page\nobreakspace\thepage}}
\addtokomafont{pageheadfoot}{\upshape}

\setlength{\columnsep}{25pt}
\setlength{\columnseprule}{0.4pt}

\usepackage{blindtext}% dummy text
\begin{document}

\begin{multicols*}{3}
\Blinddocument
\end{multicols*}
\end{document}

But using fancyhdr is also possible if really want to use this package:

\documentclass[
  %a4paper,% default
  %pagesize,% default since version 3.17
  landscape,
  fontsize=6pt
]{scrartcl}
\usepackage[left=0.75cm,right=0.75cm, top=1cm, bottom=0.75cm]{geometry}
\usepackage{multicol}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\usekomafont{pageheadfoot}Name}
\fancyhead[C]{\usekomafont{pageheadfoot}\pagemark}
\fancyhead[L]{\usekomafont{pageheadfoot}Title description}

\renewcommand*\pagemark{{\usekomafont{pagenumber}Page\nobreakspace\thepage}}
\addtokomafont{pageheadfoot}{\upshape}

\setlength{\columnsep}{25pt}
\setlength{\columnseprule}{0.4pt}

\usepackage{blindtext}
\begin{document}

\begin{multicols*}{3}
\Blinddocument
\end{multicols*}
\end{document}

Note that with fancyhdr a small number of options regarding page header and footer will not work. An example is the KOMA option footsepline.

So if you really want to use fancyhdr and there is only the warning that the usage of fancyhdr together with a KOMA-Script class is not recommended you can ignore it.


But do not ignore any additional warning regarding the old font commands like \rm, \sl. Note that fancyhdr uses this commands in its default header and footer definitions.

Starting with the current prerelease of the next KOMA-Script Version (3.20) KOMA Script does not define this old commands. So

\documentclass{scrartcl}[2015/11/06]
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
Text
\end{document}

will result in errors. You can avoid the errors if you either use \fancyhf{} and define your own header and footer using \fancyhead and \fancyfoot without the usage of old font commands or you use a compatibility option.

Related Question