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:

  1. %TITR Main Document 5.06in x 7.81in, facing pages
  2.  
  3. %Preamble
  4. \documentclass[10pt,british,twoside,openany]{scrbook}
  5. \usepackage{novel}
  6.  
  7. %Frontmatter
  8.  
  9. \begin{document}
  10.  
  11. \frontmatter
  12.  
  13.  
  14. %The header and footer
  15. \pagestyle{fancy}
  16. \fancyhead[LE,RO]{\tiny \slshape \leftmark}
  17. \fancyhead[LO,RE]{\tiny \slshape Ben Francis}
  18. \fancyhead[C]{}
  19. \fancyfoot[C]{\small \slshape \thepage \hspace{3mm} Tears in the Rain}
  20. \fancyfoot[RO]{\small \slshape Tears in the Rain}
  21. \fancyfoot[LE]{\small \slshape Tears in the Rain}
  22. \fancyfoot[C]{\thepage}
  23. \renewcommand{\footrulewidth}{0.25pt}
  24.  
  25. %The Chapters
  26. \input{./child_docs/child_docs.tex}
  27.  
  28. \end{document}
  29.  
  30. % which calls:
  31.  
  32. %novel.sty (Style package for the novel template)
  33. \usepackage{microtype}
  34. \usepackage{concrete}
  35. \usepackage{enumitem}
  36. \usepackage[T1]{fontenc}
  37. \usepackage{textcomp}
  38. \usepackage{framed}
  39. \usepackage{ragged2e}
  40. \usepackage[Lenny]{fncychap}
  41. \usepackage{graphicx}
  42. \usepackage[english]{babel}
  43. \usepackage{type1cm}
  44. \renewcommand\thepart{\Alph{part}}
  45. \newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}
  46. \KOMAoptions{open=any}
  47. \usepackage{fancyhdr}
  48. \setlength{\headheight}{15.2pt}
  49. \pagestyle{fancy}
  50. \widowpenalty=300
  51. \clubpenalty=300
  52. \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.
Reason: code marked

User avatar
Johannes_B
Site Moderator
Posts: 4186
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.

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


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

  1. \usepackage{fancyhdr}
  2. ...
  3. \pagestyle{fancy}


you can use

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


In both cases the header and footer can be set by

  1. \addtokomafont{pageheadfoot}{\slshape}
  2. \addtokomafont{pagehead}{\tiny}
  3. \addtokomafont{pagefoot}{\small}
  4. \ohead{\MakeUppercase{\leftmark}}
  5. \ihead{Ben Francis}
  6. \ofoot{Tears in the Rain}
  7. \cfoot{\pagemark}


MWE:

  1. \documentclass[10pt,
  2. british,% note novel.sty loads babel with UKenglish option
  3. open=any% note novel.sty sets also this option
  4. ]{scrbook}
  5.  
  6. \usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}
  7. %%% if you can't edit novel.sty:
  8. \PreventPackageFromLoading{fancyhdr}
  9. \DeclarePageStyleAlias{fancy}{scrheadings}
  10. %%% or if package fancyhdr and pagestyle fancy deleted from novel.sty:
  11. %\pagestyle{scrheadings}
  12.  
  13. \addtokomafont{pageheadfoot}{\slshape}
  14. \addtokomafont{pagehead}{\tiny}
  15. \addtokomafont{pagefoot}{\small}
  16. \ohead{\MakeUppercase{\leftmark}}
  17. \ihead{Ben Francis}
  18. \ofoot{Tears in the Rain}
  19. \cfoot{\pagemark}
  20.  
  21. \usepackage{novel}
  22.  
  23. \usepackage{lipsum}
  24.  
  25. \begin{document}
  26.  
  27. %The Chapters
  28. \chapter{First chapter}
  29. \section{First section}
  30. \lipsum{10}
  31. \section{Second section}
  32. \lipsum{10}
  33. \end{document}


Best regards
Elke

User avatar
Johannes_B
Site Moderator
Posts: 4186
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:

  1. \documentclass{scrbook}
  2. \usepackage{scrlayer-scrpage}
  3. \clearscrheadfoot
  4. \addtokomafont{pagehead}{\tiny\slshape}
  5. \addtokomafont{pagefoot}{\small\slshape}
  6. \ohead{\leftmark}
  7. \ihead{Ben Francis}
  8. \ofoot{Tears in the Rain}
  9. \cfoot{\pagemark}
  10. \usepackage{blindtext}
  11. \begin{document}
  12. \blinddocument
  13. \blinddocument
  14. \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

  1. \documentclass[10pt,english,british,twoside,openany]{scrbook}
  2. %\usepackage{scrpage2}
  3. \usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}
  4. \addtokomafont{pageheadfoot}{\slshape}
  5. \addtokomafont{pagehead}{\tiny}
  6. \addtokomafont{pagefoot}{\small}
  7. \ohead{\MakeUppercase{\leftmark}}
  8. \ihead{Ben Francis}
  9. \ofoot{Tears in the Rain}
  10. \cfoot{\pagemark}
  11. \usepackage{microtype}
  12. \usepackage{concrete}
  13. \usepackage{enumitem}
  14. \usepackage[T1]{fontenc}
  15. \usepackage{textcomp}
  16. \usepackage{framed}
  17. \usepackage{ragged2e}
  18. \usepackage[Lenny]{fncychap}
  19. \usepackage{graphicx}
  20. \usepackage[british]{babel}
  21. \usepackage{type1cm}
  22. %\usepackage{fancyhdr}
  23. \renewcommand\thepart{\Alph{part}}
  24. \newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}
  25. \KOMAoptions{open=any}
  26. \setlength{\headheight}{15.2pt}
  27. %\pagestyle{fancy}
  28. \widowpenalty=300
  29. \clubpenalty=300
  30. \renewcommand*{\partpagestyle}{empty}
  31.  
  32. \begin{document}
  33. \title{Tears in the Rain}
  34. \date{}
  35. \maketitle
  36. \frontmatter
  37. \pagestyle{empty} %Empty page left
  38. \noindent \begin{flushright}
  39. {\huge{}Tears in the Rain}
  40. \par\end{flushright}{\huge \par}
  41. \cleardoubleoddemptypage
  42. \thispagestyle {empty}
  43. \includegraphics{./images/bensig.jpg}
  44. \vspace*{0.5in}
  45. \begin{flushright}
  46. {\Huge{}Tears in the Rain}
  47. \par\end{flushright}{\Huge \par}
  48. \clearpage
  49. \begin{center}
  50. \emph{Copyright}
  51. \end{center}
  52. \begin{center}
  53. \textcopyright{ 2014 Ben Francis All rights reserved.}
  54. \end{center}
  55. \vspace*{0.5in}
  56. \begin{center}
  57. \begin{minipage}[t]{0.5\paperwidth}
  58. No part of this publication may be reproduced, stored
  59. in a retrieval system, or transmitted in any form, or by any means;
  60. mechanical, electrical, photocopying, scanning, recording or otherwise,
  61. without prior written consent from the publishers. Every effort has
  62. been made to contact all copyright holders. The author and publisher
  63. will gladly rectify any omissions.
  64. \end{minipage}
  65. \end{center}
  66. \vspace*{0.5in}
  67. \begin{center}
  68. ISBN:
  69. \end{center}
  70. \vspace*{0.2in}
  71. \begin{center}
  72. A CIP Record for this book is available from the British
  73. Library.
  74. \end{center}
  75.  
  76. \vspace*{0.1in}
  77.  
  78. \begin{center}
  79. Typeset in \LaTeXe
  80. \end{center}
  81.  
  82. \cleardoubleoddemptypage
  83. \thispagestyle {empty}
  84. \vspace*{\fill}
  85.  
  86. \tableofcontents
  87.  
  88. \markboth{\MakeUppercase{Preface}}{}
  89. \addcontentsline{toc}{chapter}{Preface}
  90.  
  91. \chapter*{Preface}
  92. \input{./chapters/a_front/pref.tex}
  93.  
  94. \mainmatter
  95. \noindent
  96.  
  97. %The Chapters
  98. \input{./child_docs/child_docs.tex}
  99.  
  100.  
  101. \end{document}

User avatar
Johannes_B
Site Moderator
Posts: 4186
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]
  1. %TITR Main Document 5.06in x 7.81in, facing pages
  2. %Preamble
  3. \documentclass[10pt,english,british,twoside,openany]{scrbook}
  4. %\usepackage{scrpage2}
  5. \usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}
  6. \addtokomafont{pageheadfoot}{\slshape}
  7. \addtokomafont{pagehead}{\tiny}
  8. \addtokomafont{pagefoot}{\small}
  9. \ohead{\MakeUppercase{\leftmark}}
  10. \ihead{Ben Francis}
  11. \ofoot{Tears in the Rain}
  12. \cfoot{\pagemark}
  13.  
  14. %\usepackage{novel}
  15.  
  16. %\usepackage{lipsum}
  17.  
  18. %\usepackage{novel}
  19. \usepackage{microtype}
  20. \usepackage{concrete}
  21. \usepackage{enumitem}
  22. \usepackage[T1]{fontenc}
  23. \usepackage{textcomp}
  24. \usepackage{framed}
  25. \usepackage{ragged2e}
  26. \usepackage[Lenny]{fncychap}
  27. \usepackage{graphicx}
  28. \usepackage[british]{babel}
  29. \usepackage{type1cm}
  30. %\usepackage{fancyhdr}
  31. \renewcommand\thepart{\Alph{part}}
  32. \newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}
  33. \KOMAoptions{open=any}
  34. \setlength{\headheight}{15.2pt}
  35. %\pagestyle{fancy}
  36. \widowpenalty=300
  37. \clubpenalty=300
  38. \renewcommand*{\partpagestyle}{empty}
  39. \usepackage[paperwidth=5.06in,paperheight=7.81in]{geometry}
  40. \geometry{verbose,tmargin=0.5in,bmargin=1in,inner=0.75in,outer=0.5in,headheight=0.1in,headsep=0.15in,footskip=0.45in,twoside}
  41.  
  42. %Frontmatter
  43. \begin{document}
  44. \title{Tears in the Rain}
  45. \date{}
  46. \maketitle
  47. \frontmatter
  48. \pagestyle{empty} %Empty page left
  49. \noindent \begin{flushright}
  50. \huge{Tears in the Rain}
  51. \vspace{0.5in}
  52. \huge{\raisebox{\depth}{\scalebox{1}[-1]{Tears in the Rain}}} \par\bigskip
  53. \par\end{flushright}{\huge \par}
  54. \cleardoubleoddemptypage
  55. \thispagestyle {empty}
  56. %\includegraphics{./images/bensig.jpg}
  57. \includegraphics[width=4in,height=2in]{./images/bensig}
  58. \vspace*{0.5in}
  59. \begin{flushright}
  60. {\Huge{}Tears in the Rain}
  61. \par\end{flushright}{\Huge \par}
  62.  
  63. \clearpage
  64. \begin{center}
  65. \emph{Copyright}
  66. \end{center}
  67. \begin{center}
  68. \textcopyright{ 2014 Ben Francis All rights reserved.}
  69. \end{center}
  70. \vspace*{0.5in}
  71. \begin{center}
  72. \begin{minipage}[t]{0.5\paperwidth}
  73. No part of this publication may be reproduced, stored
  74. in a retrieval system, or transmitted in any form, or by any means;
  75. mechanical, electrical, photocopying, scanning, recording or otherwise,
  76. without prior written consent from the publishers. Every effort has
  77. been made to contact all copyright holders. The author and publisher
  78. will gladly rectify any omissions.
  79. \end{minipage}
  80. \end{center}
  81. \vspace*{0.5in}
  82. \begin{center}
  83. ISBN:
  84. \end{center}
  85. \vspace*{0.2in}
  86. \begin{center}
  87. A CIP Record for this book is available from the British
  88. Library.
  89. \end{center}
  90.  
  91. \vspace*{0.1in}
  92.  
  93. \begin{center}
  94. Typeset in \LaTeXe
  95. \end{center}
  96.  
  97. \cleardoubleoddemptypage
  98. \thispagestyle {empty}
  99. \vspace*{\fill}
  100.  
  101. \tableofcontents
  102.  
  103. \markboth{\MakeUppercase{Preface}}{}
  104. \addcontentsline{toc}{chapter}{Preface}
  105. %\addchap{Preface}
  106. %\input{./chapters/a_front/pref.tex} Pasted below
  107.  
  108. %Mainmatter
  109. \mainmatter
  110. \noindent
  111.  
  112. \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 8022 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

  1. %TITR Main Document 5.06in x 7.81in, facing pages
  2. %Preamble
  3. \documentclass[
  4. 10pt,
  5. %english,% either english or british
  6. british,% either english or british
  7. twoside,
  8. open=any
  9. ]{scrbook}
  10. %\usepackage{scrpage2}
  11. \usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}
  12. \addtokomafont{pageheadfoot}{\slshape}
  13. \addtokomafont{pagehead}{\tiny}
  14. \addtokomafont{pagefoot}{\small}
  15. \ohead{\MakeUppercase{\leftmark}}
  16. \ihead{Ben Francis}
  17. \ofoot{Tears in the Rain}
  18. \cfoot{\pagemark}
  19.  
  20. \usepackage{microtype}
  21. \usepackage{concrete}
  22. \usepackage{enumitem}
  23. \usepackage[T1]{fontenc}
  24. \usepackage{textcomp}
  25. \usepackage{framed}
  26. \usepackage{ragged2e}
  27. \usepackage[Lenny]{fncychap}
  28. \usepackage{graphicx}
  29. \usepackage{babel}
  30. %\usepackage{type1cm}% do you need this package?
  31.  
  32. \renewcommand\thepart{\Alph{part}}
  33. %\newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}%using this command inside the document gives me an error even if I run xelatex
  34. %\KOMAoptions{open=any}% already set in the class options
  35. %\setlength{\headheight}{15.2pt}% useless, later changed by geometry
  36. %\pagestyle{fancy}
  37. \widowpenalty=300
  38. \clubpenalty=300
  39. \renewcommand*{\partpagestyle}{empty}
  40. \usepackage[paperwidth=5.06in,paperheight=7.81in]{geometry}
  41. \geometry{verbose,tmargin=0.5in,bmargin=1in,inner=0.75in,outer=0.5in,
  42. %headheight=0.1in,% useless, to small
  43. headsep=0.15in,footskip=0.45in,twoside}
  44. \setlength\headheight{12pt}% suggested by scrlayer-scrpage
  45.  
  46. %Frontmatter
  47. \begin{document}
  48. \title{Tears in the Rain}
  49. \date{}
  50. \author{}% avoid the missing author warning
  51. \maketitle
  52. \frontmatter
  53. \pagestyle{empty} %Empty page left
  54. \noindent \begin{flushright}
  55. \huge{Tears in the Rain}
  56. \vspace{0.5in}
  57. \huge{\raisebox{\depth}{\scalebox{1}[-1]{Tears in the Rain}}} \par\bigskip
  58. \par\end{flushright}{\huge \par}
  59. \cleardoubleoddemptypage
  60. \thispagestyle {empty}
  61. %\includegraphics{./images/bensig.jpg}
  62. \includegraphics[width=4in,height=2in]{./images/bensig}
  63. \vspace*{0.5in}
  64. \begin{flushright}
  65. {\Huge{}Tears in the Rain}
  66. \par\end{flushright}{\Huge \par}
  67.  
  68. \clearpage
  69. \begin{center}
  70. \emph{Copyright}
  71. \end{center}
  72. \begin{center}
  73. \textcopyright{ 2014 Ben Francis All rights reserved.}
  74. \end{center}
  75. \vspace*{0.5in}
  76. \begin{center}
  77. \begin{minipage}[t]{0.5\paperwidth}
  78. No part of this publication may be reproduced, stored
  79. in a retrieval system, or transmitted in any form, or by any means;
  80. mechanical, electrical, photocopying, scanning, recording or otherwise,
  81. without prior written consent from the publishers. Every effort has
  82. been made to contact all copyright holders. The author and publisher
  83. will gladly rectify any omissions.
  84. \end{minipage}
  85. \end{center}
  86. \vspace*{0.5in}
  87. \begin{center}
  88. ISBN:
  89. \end{center}
  90. \vspace*{0.2in}
  91. \begin{center}
  92. A CIP Record for this book is available from the British
  93. Library.
  94. \end{center}
  95.  
  96. \vspace*{0.1in}
  97.  
  98. \begin{center}
  99. Typeset in \LaTeXe
  100. \end{center}
  101.  
  102. \cleardoubleevenemptypage % if the table of contents should start on an even page
  103. %\thispagestyle {empty}
  104. %\vspace*{\fill}
  105.  
  106. \tableofcontents
  107.  
  108. %\markboth{\MakeUppercase{Preface}}{}
  109. %\addcontentsline{toc}{chapter}{Preface}
  110. \addchap{Preface}% use this instead of the two lines above and instead of \chapter*{Preface}
  111. %\input{./chapters/a_front/pref.tex} Pasted below
  112.  
  113. %Mainmatter
  114. \mainmatter
  115. \noindent
  116. \chapter{First chapter}
  117.  
  118. \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 5 guests