LaTeX forum ⇒ Text Formattingfancyhdr 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

Postby mike1264 » Sat Jul 19, 2014 9:16 pm

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
	

	%The header and footer
	\pagestyle{fancy}
	\fancyhead[LE,RO]{\tiny \slshape \leftmark}
	\fancyhead[LO,RE]{\tiny \slshape Ben Francis}
	\fancyhead[C]{}
	\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}
\setlength{\headheight}{15.2pt}
\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.

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

Postby Johannes_B » Sat Jul 19, 2014 11:19 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

Postby esdd » Sun Jul 20, 2014 1:46 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

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

Postby Johannes_B » Sun Jul 20, 2014 5:15 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

Postby mike1264 » Sun Jul 20, 2014 6:10 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 :lol: . 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

Postby mike1264 » Mon Jul 21, 2014 10:44 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

\documentclass[10pt,english,british,twoside,openany]{scrbook}
%\usepackage{scrpage2}
\usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}
\addtokomafont{pageheadfoot}{\slshape}
\addtokomafont{pagehead}{\tiny}
\addtokomafont{pagefoot}{\small}
\ohead{\MakeUppercase{\leftmark}}
\ihead{Ben Francis}
\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}
\setlength{\headheight}{15.2pt}
%\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}
	\emph{Copyright}
	\end{center}
	\begin{center}
	\textcopyright{ 2014 Ben Francis All rights reserved.}
	\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
		been made to contact all copyright holders. The author and publisher
		will gladly rectify any omissions.
	\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}}{} 
	\addcontentsline{toc}{chapter}{Preface}
	
	\chapter*{Preface}
	\input{./chapters/a_front/pref.tex}

\mainmatter
\noindent

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

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

Postby Johannes_B » Mon Jul 21, 2014 11:00 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

Postby mike1264 » Mon Jul 21, 2014 11:46 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}
\usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}
\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}

%\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}
\setlength{\headheight}{15.2pt}
%\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,headheight=0.1in,headsep=0.15in,footskip=0.45in,twoside}

%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}
	\emph{Copyright}
	\end{center}
	\begin{center}
	\textcopyright{ 2014 Ben Francis All rights reserved.}
	\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
		been made to contact all copyright holders. The author and publisher
		will gladly rectify any omissions.
	\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}}{} 
	\addcontentsline{toc}{chapter}{Preface}
	%\addchap{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

Postby mike1264 » Tue Jul 22, 2014 12:03 am

Sorry - the image file is attached.
Mike
Attachments
bensig.jpg
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

Postby esdd » Tue Jul 22, 2014 10:02 am

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}
\usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}
\addtokomafont{pageheadfoot}{\slshape}
\addtokomafont{pagehead}{\tiny}
\addtokomafont{pagefoot}{\small}
\ohead{\MakeUppercase{\leftmark}}
\ihead{Ben Francis}
\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,
  %headheight=0.1in,% useless, to small
  headsep=0.15in,footskip=0.45in,twoside}
\setlength\headheight{12pt}% suggested by scrlayer-scrpage

%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}
        \emph{Copyright}
        \end{center}
        \begin{center}
        \textcopyright{ 2014 Ben Francis All rights reserved.}
        \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
                been made to contact all copyright holders. The author and publisher
                will gladly rectify any omissions.
        \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}

        \cleardoubleevenemptypage % if the table of contents should start on an even page
        %\thispagestyle {empty} 
        %\vspace*{\fill}

        \tableofcontents
        
        %\markboth{\MakeUppercase{Preface}}{} 
        %\addcontentsline{toc}{chapter}{Preface}
        \addchap{Preface}% use this instead of the two lines above and instead of \chapter*{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


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 3 guests