## LaTeX forum ⇒ Text Formatting ⇒ fancyhdr and Koma book class

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
mike1264
Posts: 27
Joined: Wed Jul 24, 2013 6:07 pm

### fancyhdr and Koma book class

Hello,

My main document consists of:


I am receiving the following error:
Usage of package fancyhdr' together(scrbook) with a KOMA-Script class is not recommended.

Do I need to change the document class to memoir perhaps (which would need a lot of work on the formatting?

Many thanks,
Mike
Last edited by Stefan Kottwitz on Thu Jul 24, 2014 11:57 pm, edited 1 time in total.
Reason: code marked

Johannes_B
Site Moderator
Posts: 4186
Joined: Thu Nov 01, 2012 4:08 pm
With a KOMA class the package scrlayer-scrpage is recommended. It's in the same bundle and so works well together with scrbook.

Also, please use the code-button for proper markup.

EDIT: As i see it, novel.sty loads fancyhdr per default. You could prevent it from doing so, or use something different. Let me take a closer look on this tomorrow.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

esdd
Posts: 36
Joined: Sat Jan 25, 2014 9:13 pm
If you can't edit this strange novel.sty file directly then add the following lines in your document preamble before loading novel.sty.

\usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}\PreventPackageFromLoading{fancyhdr}\DeclarePageStyleAlias{fancy}{scrheadings}

If you can delete the following two lines from novel.sty

\usepackage{fancyhdr}...\pagestyle{fancy}

you can use

\usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}\pagestyle{scrheadings}

In both cases the header and footer can be set by

\addtokomafont{pageheadfoot}{\slshape}\addtokomafont{pagehead}{\tiny}\addtokomafont{pagefoot}{\small}\ohead{\MakeUppercase{\leftmark}}\ihead{Ben Francis}\ofoot{Tears in the Rain}\cfoot{\pagemark}

MWE:

\documentclass[10pt,   british,% note novel.sty loads babel with UKenglish option   open=any% note novel.sty sets also this option]{scrbook} \usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}%%% if you can't edit novel.sty:\PreventPackageFromLoading{fancyhdr}\DeclarePageStyleAlias{fancy}{scrheadings}%%% or if package fancyhdr and pagestyle fancy deleted from novel.sty:%\pagestyle{scrheadings} \addtokomafont{pageheadfoot}{\slshape}\addtokomafont{pagehead}{\tiny}\addtokomafont{pagefoot}{\small}\ohead{\MakeUppercase{\leftmark}}\ihead{Ben Francis}\ofoot{Tears in the Rain}\cfoot{\pagemark} \usepackage{novel} \usepackage{lipsum} \begin{document}    %The Chapters   \chapter{First chapter}   \section{First section}   \lipsum{10}   \section{Second section}   \lipsum{10}\end{document}

Best regards
Elke

Johannes_B
Site Moderator
Posts: 4186
Joined: Thu Nov 01, 2012 4:08 pm
I think you put novel.sty together yourself. My code is basically identical to Elkes code:

\documentclass{scrbook}\usepackage{scrlayer-scrpage}\clearscrheadfoot\addtokomafont{pagehead}{\tiny\slshape}\addtokomafont{pagefoot}{\small\slshape}\ohead{\leftmark}\ihead{Ben Francis}\ofoot{Tears in the Rain}\cfoot{\pagemark}\usepackage{blindtext}\begin{document}\blinddocument\blinddocument\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

mike1264
Posts: 27
Joined: Wed Jul 24, 2013 6:07 pm
Hi Johannes_B and Elke,

Thank you very much indeed for your fully informative replies. You've probably guessed, I am a newcomer to Latex and, I'm stumbling along, in the dark, hands outstretched and feeling my way . I'll amend the scripts tonight, then hopefully I've got a workable .tex file. The .sty file I put together myself and, I can see from your suggestions I've made a bit of a hash of it. But, I'm learning - painfully slow - but getting there step by step.

Again, thank you for your time and patience! It is much appreciated I assure you.

Mike

mike1264
Posts: 27
Joined: Wed Jul 24, 2013 6:07 pm
Hi Johannes_B and Elke,
I am continuing to have a problem with the following code. I have followed your advice and now receive a series of warnings. However, the resulting .pdf file seems to be OK. Have I done something wrong in the code? I have added contents of the .sty file I was using to the main file.
Thanks for your help!
Mike


Johannes_B
Site Moderator
Posts: 4186
Joined: Thu Nov 01, 2012 4:08 pm
Your example is not compilable, as we don't have neither the pic, nor the input-files.

The warning might come from the fancychap package. It does some funny stuff.

btw: Instead of doing it by hand, just use \addchap{Preface} and let the addcontentsline/markboth command go.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

mike1264
Posts: 27
Joined: Wed Jul 24, 2013 6:07 pm
Hi Johannes_B,
Thanks - warnings are still there. Here is an improved MWE which perhaps will make more sense.

[MWE]

%pref.tex

\textit {Tears in the Rain}, set in the emerging hippie Age of Aquarius in the early nineteen sixties...

\vspace*{0.3in}

[img]\includegraphics[width=2in,height=1in]{./images/bensig}[/img]

[/MWE]

mike1264
Posts: 27
Joined: Wed Jul 24, 2013 6:07 pm
Sorry - the image file is attached.
Mike
Attachments
image resized for better readability in the forum
bensig.jpg (18.32 KiB) Viewed 8106 times

esdd
Posts: 36
Joined: Sat Jan 25, 2014 9:13 pm
Here is a suggestion to avoid a part of the warnings


In addition there is a warning that marignal notes overrun the paper. That is not a problem if you have no margin notes. Otherwise you have to change the pagelayout defined by the package geometry.

All of the \rm warnings come from the usage of the fancychap package. But I think you don't want to remove this package from your document.

Best regards
Elke