## 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:

%TITR Main Document 5.06in x 7.81in, facing pages

%Preamble
\documentclass[10pt,british,twoside,openany]{scrbook}
\usepackage{novel}

%Frontmatter

\begin{document}

\frontmatter

\pagestyle{fancy}
\fancyfoot[C]{\small \slshape \thepage \hspace{3mm} Tears in the Rain}
\fancyfoot[RO]{\small \slshape Tears in the Rain}
\fancyfoot[LE]{\small \slshape Tears in the Rain}
\fancyfoot[C]{\thepage}
\renewcommand{\footrulewidth}{0.25pt}

%The Chapters
\input{./child_docs/child_docs.tex}

\end{document}

% which calls:

%novel.sty (Style package for the novel template)
\usepackage{microtype}
\usepackage{concrete}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{framed}
\usepackage{ragged2e}
\usepackage[Lenny]{fncychap}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{type1cm}
\renewcommand\thepart{\Alph{part}}
\newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}
\KOMAoptions{open=any}
\usepackage{fancyhdr}
\pagestyle{fancy}
\widowpenalty=300
\clubpenalty=300
\renewcommand*{\partpagestyle}{empty}

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.

Johannes_B
Site Moderator
Posts: 4185
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

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


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}
\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}

%%% if you can't edit novel.sty:
%%% or if package fancyhdr and pagestyle fancy deleted from novel.sty:

\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: 4185
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}
\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.
Mike

\documentclass[10pt,english,british,twoside,openany]{scrbook}
%\usepackage{scrpage2}
\ofoot{Tears in the Rain}
\cfoot{\pagemark}
\usepackage{microtype}
\usepackage{concrete}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{framed}
\usepackage{ragged2e}
\usepackage[Lenny]{fncychap}
\usepackage{graphicx}
\usepackage[british]{babel}
\usepackage{type1cm}
%\usepackage{fancyhdr}
\renewcommand\thepart{\Alph{part}}
\newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}
\KOMAoptions{open=any}
%\pagestyle{fancy}
\widowpenalty=300
\clubpenalty=300
\renewcommand*{\partpagestyle}{empty}

\begin{document}
\title{Tears in the Rain}
\date{}
\maketitle
\frontmatter
\pagestyle{empty} %Empty page left
\noindent \begin{flushright}
{\huge{}Tears in the Rain}
\par\end{flushright}{\huge \par}
\cleardoubleoddemptypage
\thispagestyle {empty}
\includegraphics{./images/bensig.jpg}
\vspace*{0.5in}
\begin{flushright}
{\Huge{}Tears in the Rain}
\par\end{flushright}{\Huge \par}
\clearpage
\begin{center}
\end{center}
\begin{center}
\end{center}
\vspace*{0.5in}
\begin{center}
\begin{minipage}[t]{0.5\paperwidth}
No part of this publication may be reproduced, stored
in a retrieval system, or transmitted in any form, or by any means;
mechanical, electrical, photocopying, scanning, recording or otherwise,
without prior written consent from the publishers. Every effort has
\end{minipage}
\end{center}
\vspace*{0.5in}
\begin{center}
ISBN:
\end{center}
\vspace*{0.2in}
\begin{center}
A CIP Record for this book is available from the British
Library.
\end{center}

\vspace*{0.1in}

\begin{center}
Typeset in \LaTeXe
\end{center}

\cleardoubleoddemptypage
\thispagestyle {empty}
\vspace*{\fill}

\tableofcontents

\markboth{\MakeUppercase{Preface}}{}

\chapter*{Preface}
\input{./chapters/a_front/pref.tex}

\mainmatter
\noindent

%The Chapters
\input{./child_docs/child_docs.tex}

\end{document}

Johannes_B
Site Moderator
Posts: 4185
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]
%TITR Main Document 5.06in x 7.81in, facing pages
%Preamble
\documentclass[10pt,english,british,twoside,openany]{scrbook}
%\usepackage{scrpage2}
\ofoot{Tears in the Rain}
\cfoot{\pagemark}

%\usepackage{novel}

%\usepackage{lipsum}

%\usepackage{novel}
\usepackage{microtype}
\usepackage{concrete}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{framed}
\usepackage{ragged2e}
\usepackage[Lenny]{fncychap}
\usepackage{graphicx}
\usepackage[british]{babel}
\usepackage{type1cm}
%\usepackage{fancyhdr}
\renewcommand\thepart{\Alph{part}}
\newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}
\KOMAoptions{open=any}
%\pagestyle{fancy}
\widowpenalty=300
\clubpenalty=300
\renewcommand*{\partpagestyle}{empty}
\usepackage[paperwidth=5.06in,paperheight=7.81in]{geometry}

%Frontmatter
\begin{document}
\title{Tears in the Rain}
\date{}
\maketitle
\frontmatter
\pagestyle{empty} %Empty page left
\noindent \begin{flushright}
\huge{Tears in the Rain}
\vspace{0.5in}
\huge{\raisebox{\depth}{\scalebox{1}[-1]{Tears in the Rain}}} \par\bigskip
\par\end{flushright}{\huge \par}
\cleardoubleoddemptypage
\thispagestyle {empty}
%\includegraphics{./images/bensig.jpg}
\includegraphics[width=4in,height=2in]{./images/bensig}
\vspace*{0.5in}
\begin{flushright}
{\Huge{}Tears in the Rain}
\par\end{flushright}{\Huge \par}

\clearpage
\begin{center}
\end{center}
\begin{center}
\end{center}
\vspace*{0.5in}
\begin{center}
\begin{minipage}[t]{0.5\paperwidth}
No part of this publication may be reproduced, stored
in a retrieval system, or transmitted in any form, or by any means;
mechanical, electrical, photocopying, scanning, recording or otherwise,
without prior written consent from the publishers. Every effort has
\end{minipage}
\end{center}
\vspace*{0.5in}
\begin{center}
ISBN:
\end{center}
\vspace*{0.2in}
\begin{center}
A CIP Record for this book is available from the British
Library.
\end{center}

\vspace*{0.1in}

\begin{center}
Typeset in \LaTeXe
\end{center}

\cleardoubleoddemptypage
\thispagestyle {empty}
\vspace*{\fill}

\tableofcontents

\markboth{\MakeUppercase{Preface}}{}
%\input{./chapters/a_front/pref.tex} Pasted below

%Mainmatter
\mainmatter
\noindent

\end{document}


%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 8580 times

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

%TITR Main Document 5.06in x 7.81in, facing pages
%Preamble
\documentclass[
10pt,
%english,% either english or british
british,% either english or british
twoside,
open=any
]{scrbook}
%\usepackage{scrpage2}
\ofoot{Tears in the Rain}
\cfoot{\pagemark}

\usepackage{microtype}
\usepackage{concrete}
\usepackage{enumitem}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{framed}
\usepackage{ragged2e}
\usepackage[Lenny]{fncychap}
\usepackage{graphicx}
\usepackage{babel}
%\usepackage{type1cm}% do you need this package?

\renewcommand\thepart{\Alph{part}}
%\newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}%using this command inside the document gives me an error even if I run xelatex
%\KOMAoptions{open=any}% already set in the class options
%\setlength{\headheight}{15.2pt}% useless, later changed by geometry
%\pagestyle{fancy}
\widowpenalty=300
\clubpenalty=300
\renewcommand*{\partpagestyle}{empty}
\usepackage[paperwidth=5.06in,paperheight=7.81in]{geometry}
\geometry{verbose,tmargin=0.5in,bmargin=1in,inner=0.75in,outer=0.5in,

%Frontmatter
\begin{document}
\title{Tears in the Rain}
\date{}
\author{}% avoid the missing author warning
\maketitle
\frontmatter
\pagestyle{empty} %Empty page left
\noindent \begin{flushright}
\huge{Tears in the Rain}
\vspace{0.5in}
\huge{\raisebox{\depth}{\scalebox{1}[-1]{Tears in the Rain}}} \par\bigskip
\par\end{flushright}{\huge \par}
\cleardoubleoddemptypage
\thispagestyle {empty}
%\includegraphics{./images/bensig.jpg}
\includegraphics[width=4in,height=2in]{./images/bensig}
\vspace*{0.5in}
\begin{flushright}
{\Huge{}Tears in the Rain}
\par\end{flushright}{\Huge \par}

\clearpage
\begin{center}
\end{center}
\begin{center}
\end{center}
\vspace*{0.5in}
\begin{center}
\begin{minipage}[t]{0.5\paperwidth}
No part of this publication may be reproduced, stored
in a retrieval system, or transmitted in any form, or by any means;
mechanical, electrical, photocopying, scanning, recording or otherwise,
without prior written consent from the publishers. Every effort has
\end{minipage}
\end{center}
\vspace*{0.5in}
\begin{center}
ISBN:
\end{center}
\vspace*{0.2in}
\begin{center}
A CIP Record for this book is available from the British
Library.
\end{center}

\vspace*{0.1in}

\begin{center}
Typeset in \LaTeXe
\end{center}

%\thispagestyle {empty}
%\vspace*{\fill}

\tableofcontents

%\markboth{\MakeUppercase{Preface}}{}
%\input{./chapters/a_front/pref.tex} Pasted below

%Mainmatter
\mainmatter
\noindent
\chapter{First chapter}

\end{document}`

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