LaTeX forum ⇒ Page LayoutFancyhdr with a KOMA-scipt class Topic is solved

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

Fancyhdr with a KOMA-scipt class

Postby Cham » Sat Dec 02, 2017 7:27 pm

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 ?

  1. \RequirePackage[l2tabu,orthodox]{nag}
  2. \documentclass[11pt,twoside]{scrartcl}
  3. \usepackage[T1]{fontenc}
  4. \usepackage{lmodern}
  5. \usepackage[left=1in,right=1in,top=0.5in,bottom=0.5in,includehead,includefoot]{geometry}
  6. %%%% How to replace the following for a KOMA class document?
  7. \usepackage[page]{totalcount}
  8. \usepackage{fancyhdr}
  9. \fancyhf{}
  10. \pagestyle{fancy}
  11. \fancyhead[LE,RO]{Fun with \LaTeX}
  12. \fancyhead[CE,CO]{\textsf{\textbf{Bold text on top}}}
  13. \fancyhead[RE,LO]{\textsl{Text in corner}}
  14. \fancyfoot[CE,CO]{\textsc{SmallCaps text at bottom}}
  15. \fancyfoot[LE,RO]{page \thepage~of \totalpages}
  16. \fancyfoot[RE,LO]{Useless text at bottom}
  17. \setlength{\headheight}{14pt}
  18. \renewcommand{\headrulewidth}{0.4pt}
  19. \renewcommand{\footrulewidth}{0.0pt}
  20. %%%%
  21. \begin{document}
  22.  
  23. \title{Title}
  24. \author{Isaac Newton}
  25. \date{}
  26. \maketitle
  27. \tableofcontents
  28. \section{Introduction} Some introduction text for fun.
  29. \newpage
  30. \section{A title} Some lazy text.
  31. \newpage
  32. \section{Another title} Some annoying text.
  33. \newpage
  34. \section*{Thank you} Thanks all!
  35. \newpage
  36. \begin{thebibliography}{999}
  37. \bibitem{bibitem1}
  38. \uppercase{Some one}, \par \textit{Title}, \par Found.\ Phys.\ \textbf{47}, no. 6, 797 (2000).
  39. \bibitem{bibitem2}
  40. \uppercase{Some guy}, \par \textit{Title}, \par Phys.\ Rev.\ D \textbf{65}, 103522 (2017).
  41. \end{thebibliography}
  42.  
  43. \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 ?

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

Postby Johannes_B » Sat Dec 02, 2017 7:35 pm

Just keep on. Your system is outdated anyway.

  1. \documentclass[11pt,twoside,headsepline]{scrartcl}
  2. \usepackage[T1]{fontenc}
  3. \usepackage{lmodern}
  4. \usepackage[left=1in,right=1in,top=0.5in,bottom=0.5in,includehead,includefoot]{geometry}
  5. %%%% How to replace the following for a KOMA class document?
  6. \usepackage[page]{totalcount}
  7. \usepackage{scrlayer-scrpage}
  8. \ohead{Fu with LaTeX}
  9. \chead{center}
  10. \ihead{inner}
  11. \cfoot{center}
  12. \ofoot{page \thepage~of \totalpages}
  13. \ifoot{Useless text at bottom}
  14. \setlength{\headheight}{14pt}
  15. %%%%
  16. \begin{document}
  17.  
  18. \title{Title}
  19. \author{Isaac Newton}
  20. \date{}
  21. \maketitle
  22. \tableofcontents
  23. \section{Introduction} Some introduction text for fun.
  24. \newpage
  25. \section{A title} Some lazy text.
  26. \newpage
  27. \section{Another title} Some annoying text.
  28. \newpage
  29. \section*{Thank you} Thanks all!
  30. \newpage
  31. \begin{thebibliography}{999}
  32. \bibitem{bibitem1}
  33. \uppercase{Some one}, \par \textit{Title}, \par Found.\ Phys.\ \textbf{47}, no. 6, 797 (2000).
  34. \bibitem{bibitem2}
  35. \uppercase{Some guy}, \par \textit{Title}, \par Phys.\ Rev.\ D \textbf{65}, 103522 (2017).
  36. \end{thebibliography}
  37.  
  38. \nonfrenchspacing
  39. Compare.\ this\par
  40. Compare. that
  41.  
  42. \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: 820
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sat Dec 02, 2017 8:02 pm

What do you mean by "Your system is outdated anyway." ? Could you be more specific?

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

Postby Johannes_B » Sat Dec 02, 2017 8:47 pm

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: 820
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sat Dec 02, 2017 8:53 pm

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: 3585
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat Dec 02, 2017 8:55 pm

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: 820
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sat Dec 02, 2017 9:07 pm

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: 3585
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat Dec 02, 2017 10:31 pm

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: 8537
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sun Dec 03, 2017 4:54 pm

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
Site admin


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 5 guests