LaTeX forum ⇒ Text Formattingfancyhdr and Koma book class

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
User avatar
Johannes_B
Site Moderator
Posts: 4186
Joined: Thu Nov 01, 2012 4:08 pm

Re: fancyhdr and Koma book class

Postby Johannes_B » Tue Jul 22, 2014 10:30 am

It took me two hours (with interruptions) so here are my two cents:

You can go with fncychap if you want. It uses commands (like \rm) which are deprecated for right about 20 years now. To be honest, i think it is pretty ugly. Other people are making fun of it as well (but in conjunction with Comic Sans).

I changed your code a bit, please have a close look.
  1. % arara: lualatexmk
  2. \documentclass[10pt,english,british,twoside,openany]{scrbook}
  3. \usepackage{blindtext}
  4. \usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}
  5. \pagestyle{scrheadings}
  6. \addtokomafont{pageheadfoot}{\slshape}
  7. \addtokomafont{pagehead}{\tiny}
  8. \addtokomafont{pagefoot}{\small}
  9. \addtokomafont{disposition}{\rmfamily}%JB: rm for chapter headings
  10. %\ohead{\MakeUppercase{\leftmark}}%JB: do you REALLY want this
  11. %uppercased?
  12. \ohead{\leftmark}
  13. \ihead{Ben Francis}
  14. \ofoot{\mytitle}
  15. \cfoot{\pagemark}
  16.  
  17. \usepackage{microtype}
  18. \usepackage{ragged2e}
  19. %\usepackage[Lenny]{fncychap}%really ugly
  20. \usepackage{graphicx}
  21. \usepackage[british]{babel}
  22. \renewcommand\thepart{\Alph{part}}
  23.  
  24.  
  25. %\newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}
  26. %JB: Since you are using XeTeX, take advantage of fontspec
  27. %JB: LuaTeX and microtype work better together, so LuaLaTeX
  28. \usepackage{fontspec}
  29. \setmainfont{Linux Libertine O}%JB: Just as an example
  30. %\KOMAoptions{open=any}
  31. %\setlength{\headheight}{15.2pt}
  32. %\widowpenalty=300
  33. %\clubpenalty=300
  34. \renewcommand*{\partpagestyle}{empty}
  35. \usepackage{geometry}
  36. \geometry{paperwidth=5.06in,
  37. paperheight=7.81in,
  38. verbose,
  39. tmargin=0.5in,
  40. bmargin=1in,
  41. inner=0.75in,
  42. outer=0.5in,
  43. headheight=0.1in,
  44. headsep=0.15in,
  45. footskip=0.45in,
  46. twoside}
  47. %\usepackage{showframe}
  48. \iffalse
  49. We can better see how the text block is laid out on the page with
  50. package showframe. Be aware, that your marginpar column is
  51. running out of the page.
  52. \fi
  53. \newcommand{\mytitle}{Tears in the Rain}
  54. %JB: Saving it and later using it again.
  55. \begin{document}
  56. \title{\mytitle}
  57. \frontmatter
  58. \date{}
  59. \maketitle
  60. \begin{titlepage}
  61. \begin{flushright}
  62. {\huge \mytitle}%JB: Those are switches active
  63. %in the current group
  64. \vspace{0.5in}
  65. \huge{\raisebox{\depth}{\scalebox{1}[-1]{\mytitle}}} \par\bigskip
  66. \par\end{flushright}{\huge \par}
  67. \end{titlepage}
  68.  
  69.  
  70. \begin{titlepage}
  71. \noindent\includegraphics[width=4in,height=2in]{bensig}
  72. \vspace*{0.5in}
  73. \begin{flushright}
  74. {\Huge{}Tears in the Rain}
  75. \par\end{flushright}{\Huge \par}
  76. \end{titlepage}
  77.  
  78. \begin{titlepage}
  79. \begin{center}
  80. \emph{Copyright}
  81. \end{center}
  82. \begin{center}
  83. \textcopyright{ 2014 Ben Francis All rights reserved.}
  84. \end{center}
  85. \vspace*{0.5in}
  86. \begin{center}
  87. \begin{minipage}[t]{0.5\paperwidth}
  88. No part of this publication may be reproduced, stored
  89. in a retrieval system, or transmitted in any form, or by any means;
  90. mechanical, electrical, photocopying, scanning, recording or otherwise,
  91. without prior written consent from the publishers. Every effort has
  92. been made to contact all copyright holders. The author and publisher
  93. will gladly rectify any omissions.
  94. \end{minipage}
  95. \end{center}
  96. \vspace*{0.5in}
  97. \begin{center}
  98. ISBN:
  99. \end{center}
  100. \vspace*{0.2in}
  101. \begin{center}
  102. A CIP Record for this book is available from the British
  103. Library.
  104. \end{center}
  105. \vspace*{0.1in}
  106. \begin{center}
  107. Typeset in \LaTeXe
  108. \end{center}
  109. \end{titlepage}
  110.  
  111.  
  112.  
  113. \iffalse
  114. You have been doing much by hand. That isn't the LaTeX way, but
  115. ok for title pages. But please don't hand craft in the main part.
  116. \fi
  117.  
  118. \tableofcontents
  119.  
  120. \addchap{Preface}
  121. %JB addchap does magic for you
  122.  
  123. \emph{Tears in the Rain}, %JB: emphasize (use semantic markup)
  124. set in the emerging hippie Age of Aquarius in the early nineteen
  125. sixties... \marginpar{The times of Love, Peace and Music}
  126. \blindtext[3]
  127.  
  128. \mainmatter
  129. %\noindent%JB: Why?
  130. \part{How it all began}
  131. \blinddocument
  132. \part{How it all ended}
  133. \blinddocument
  134. \blinddocument
  135. \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 » Tue Jul 22, 2014 11:26 am

Many thanks - brilliant!

Mike

mike1264
Posts: 27
Joined: Wed Jul 24, 2013 6:07 pm

Postby mike1264 » Wed Jul 23, 2014 3:53 pm

Hi Johannes_b,

First off, thank you for the enormous time and effort you and others have given to my problems with formatting. It really is much appreciated!
I agree with you on the use of 'fancychap' - I have been thinking I would like to remove this because it detracts from the excellent formatting latex provides. The more I have read the comments in this posting from everyone including yourself, I am drawn more and more towards letting latex do the formatting with as little intervention from me. I am learning!
One small problem remains: when I run your code, as is, I can't see any headers or footers. I wonder if I have missed something?

Thanks,
Mike

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

Postby Johannes_B » Wed Jul 23, 2014 4:02 pm

Hi Mike,

we like to help :-)

Are the headers and footers missing on all pages?
Pages where a chapter starts are set with the plain style, cf. scrguien.pdf
You can change the plain style as well by providing an optional argument to \ohead[plain]{others}.

Titlepages are empty by default.
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 » Wed Jul 23, 2014 6:34 pm

Hi Johannes_B,

Regarding the code you provided, just a few questions:

    1. Where you use "blindtext" in your code, is this adding random text at that point - like lorem ipsum does?

    2. Where you use "blinddocument" that inserts an example document with example formatting. Should I write in at that point an "addchap" or an "\input" or "\include" with a pointer to one of my chapter files?

    3. The \marginpar{The times of Love, Peace and Music} statement in the code adds a marginal note - do I need to make the margin larger for this to be included if I need to?

    4. This statement in the code I didn't understand why it is there: "\iffalse We can better see how the text block is laid out on the page with package showframe. Be aware, that your marginpar column is running out of the page.\fi". I understand it as an 'if-then' statement.

Thanks,
Mike

mike1264
Posts: 27
Joined: Wed Jul 24, 2013 6:07 pm

Postby mike1264 » Wed Jul 23, 2014 6:52 pm

A little question,

Can '\marginpar{A note in the margins.}' be assigned to either outer or inner margins?

Cheers,
Mike

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

Postby Johannes_B » Thu Jul 24, 2014 2:33 pm

Hi Mike,

1. Exactly, just some random text so there is something to see on the page.

2. Not sure what you mean. Where Blinddocument inserts a chapter, you can do the same.

No matter if you use input or include at the point, but there are differences.

Please make a mental note, that \chapter{chapter title} makes a numbered chapter \addchap adds an unnumbered chapter.

3. Exactly, your margin is atm just not big enough to fit a marginpar. If you do not need marginpars, then nevermind. ;-)

4. This \iffalse \fi is indeed a conditional. It treats everything inbetween as a comment. This is not very good style but pretty handy in a minimal example. The thing about marginpars have been discussed in 3. :-)

Not sure about the marginpars in inner and outer margin. But i think it is possible using scrlayer-scrpage, or scrlayer-notecolumn. Would need to check that. Please open up a new question for that.

Little hint, use *code* instead of *mwe* to include code.
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 » Thu Jul 24, 2014 2:46 pm

Hi Johannes_B ,

Again - thanks!! I'll work on your suggestions this afternoon and finalise the layout.

Mike


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 5 guests