Page LayoutFancyhdr with a KOMA-scipt class

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Fancyhdr with a KOMA-scipt class

Post by Cham »

I'm using the fancyhdr package to modify the header and footer of several KOMA-script classes (scrbook, scrartcl, scrreprt). Everything compiles fine and the output is really nice. I'm only getting a single warning in the console (shown below).

However, I know it's not recommended to use fancyhdr with a KOMA class document since the KOMA classes already have built-in features to modify the header and footer. So I have two questions :

1. What are the wrong things that could happen or what should I expect if I still use the fancyhdr package with a KOMA class document ?

2. What should be the proper code to replace the fancyhdr code shown below, if I really have to scrap that package ?

Code: Select all

\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[11pt,twoside]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[left=1in,right=1in,top=0.5in,bottom=0.5in,includehead,includefoot]{geometry}
%%%% How to replace the following for a KOMA class document?
\usepackage[page]{totalcount}
\usepackage{fancyhdr}
\fancyhf{}
\pagestyle{fancy}
\fancyhead[LE,RO]{Fun with \LaTeX}
\fancyhead[CE,CO]{\textsf{\textbf{Bold text on top}}}
\fancyhead[RE,LO]{\textsl{Text in corner}}
\fancyfoot[CE,CO]{\textsc{SmallCaps text at bottom}}
\fancyfoot[LE,RO]{page \thepage~of \totalpages}
\fancyfoot[RE,LO]{Useless text at bottom}
\setlength{\headheight}{14pt}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.0pt}
%%%%
\begin{document}

\title{Title}
\author{Isaac Newton}
\date{}
\maketitle
\tableofcontents
\section{Introduction} Some introduction text for fun.
\newpage
\section{A title} Some lazy text.
\newpage
\section{Another title} Some annoying text.
\newpage
\section*{Thank you} Thanks all!
\newpage
\begin{thebibliography}{999}
\bibitem{bibitem1}
\uppercase{Some one}, \par \textit{Title}, \par Found.\ Phys.\  \textbf{47}, no. 6, 797 (2000).
\bibitem{bibitem2}
\uppercase{Some guy}, \par \textit{Title}, \par Phys.\ Rev.\ D \textbf{65}, 103522 (2017).
\end{thebibliography}

\end{document}
Here's the warning I get :
Class scrartcl Warning: Usage of package `fancyhdr' together
(scrartcl) with a KOMA-Script class is not recommended.
(scrartcl) I'd suggest to use
(scrartcl) package `scrlayer-scrpage'.
(scrartcl) Nevertheless, using requested
(scrartcl) package `fancyhdr' on input line 9.
So how should I replace the fancyhdr code ?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Fancyhdr with a KOMA-scipt class

Post by Johannes_B »

Just keep on. Your system is outdated anyway.

Code: Select all

\documentclass[11pt,twoside,headsepline]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[left=1in,right=1in,top=0.5in,bottom=0.5in,includehead,includefoot]{geometry}
%%%% How to replace the following for a KOMA class document?
\usepackage[page]{totalcount}
\usepackage{scrlayer-scrpage}
\ohead{Fu with LaTeX}
\chead{center}
\ihead{inner}
\cfoot{center}
\ofoot{page \thepage~of \totalpages}
\ifoot{Useless text at bottom}
\setlength{\headheight}{14pt}
%%%%
\begin{document}
 
\title{Title}
\author{Isaac Newton}
\date{}
\maketitle
\tableofcontents
\section{Introduction} Some introduction text for fun.
\newpage
\section{A title} Some lazy text.
\newpage
\section{Another title} Some annoying text.
\newpage
\section*{Thank you} Thanks all!
\newpage
\begin{thebibliography}{999}
\bibitem{bibitem1}
\uppercase{Some one}, \par \textit{Title}, \par Found.\ Phys.\  \textbf{47}, no. 6, 797 (2000).
\bibitem{bibitem2}
\uppercase{Some guy}, \par \textit{Title}, \par Phys.\ Rev.\ D \textbf{65}, 103522 (2017).
\end{thebibliography}

 \nonfrenchspacing
Compare.\ this\par
Compare. that

\end{document}
Looking at the KOMA-script manual would have helped you.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Fancyhdr with a KOMA-scipt class

Post by Cham »

What do you mean by "Your system is outdated anyway." ? Could you be more specific?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Fancyhdr with a KOMA-scipt class

Post by Johannes_B »

You have TeX Live 2015 installed. There have been many updates to LaTeX and contributed packages. The nag warning about fancyhdr is only there, because fancyhdr wasn't updated yet. scrlayer-scrpage should be in a solid state by TL 2015, but i am not sure.
LaTeX itself, the basic LEGO set, was updated in the meantime.

By the way, did this help you at all?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Fancyhdr with a KOMA-scipt class

Post by Cham »

This is why I'm changing the fancyhdr code to the KOMA version, in my KOMA-script templates. (it's all working great, by the way).

I'm now getting a last strange message in the console :
Class scrreprt Warning: \float@addtolists detected!
(scrreprt) Implementation of \float@addtolist became
(scrreprt) deprecated in KOMA-Script v3.01 2008/11/14 and
(scrreprt) has been replaced by several more flexible
(scrreprt) features of package `tocbasic`.
(scrreprt) Since Version 3.12 support for deprecated
(scrreprt) \float@addtolist interface has been
(scrreprt) restricted to only some of the KOMA-Script
(scrreprt) features and been removed from others.
(scrreprt) Loading of package `scrhack' may help to
(scrreprt) avoid this warning, if you are using a
(scrreprt) a package that still implements the
(scrreprt) deprecated \float@addtolist interface .
How should I interpret that? What is causing that, and is there something to fix? How?

EDIT :
Johannes_B wrote: By the way, did this help you at all?
Thanks for the link. Do you consider fancyhdr as an obsolete package?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Fancyhdr with a KOMA-scipt class

Post by Johannes_B »

Try loading package scrhack.

Fancyhdr is not obsolete, it is just not recommended with KOMA-script.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Fancyhdr with a KOMA-scipt class

Post by Cham »

scrhack is one such mysterious package to me ! The documentation I've found is pretty obscure/weird to me! (it's even almost insulting to some packages authors!)

It removes the curious message I've shown above from my console, and the whole compiled document stays the same. What is the purpose of that esoteric package? I'm afraid it's a kind of superfluous "hack" (scrhack = script hack) !
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Fancyhdr with a KOMA-scipt class

Post by Johannes_B »

While LaTeX evolved over the years, some packages didn't speed up. scrhack makes some extra LEGO brick sets compatible to LaTeX itself or KOMA-script.
The package exists, because some package maintainers never made an update becuase of various reasons.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Fancyhdr with a KOMA-scipt class

Post by Stefan Kottwitz »

The KOMA-Script author is often a bit harsh.

Via the scrhack package, he ensures compatibility and avoids issues with other packages. Consider it as a service for KOMA-Script users.

Stefan
LaTeX.org admin
Post Reply