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: 4185
Joined: Thu Nov 01, 2012 4:08 pm

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.
% arara: lualatexmk
\documentclass[10pt,english,british,twoside,openany]{scrbook}
\usepackage{blindtext}
\usepackage[automark,headsepline,footsepline=.25pt]{scrlayer-scrpage}
\pagestyle{scrheadings}
\addtokomafont{pageheadfoot}{\slshape}
\addtokomafont{pagehead}{\tiny}
\addtokomafont{pagefoot}{\small}
\addtokomafont{disposition}{\rmfamily}%JB: rm for chapter headings
%\ohead{\MakeUppercase{\leftmark}}%JB: do you REALLY want this
%uppercased?
\ohead{\leftmark}
\ihead{Ben Francis}
\ofoot{\mytitle}
\cfoot{\pagemark}

\usepackage{microtype}
\usepackage{ragged2e}
%\usepackage[Lenny]{fncychap}%really ugly
\usepackage{graphicx}
\usepackage[british]{babel}
\renewcommand\thepart{\Alph{part}}


%\newcommand{\apostrophe}{\XeTeXglyph\XeTeXcharglyph"0027\relax}
%JB: Since you are using XeTeX, take advantage of fontspec
%JB: LuaTeX and microtype work better together, so LuaLaTeX
\usepackage{fontspec}
\setmainfont{Linux Libertine O}%JB: Just as an example
%\KOMAoptions{open=any}
%\setlength{\headheight}{15.2pt}
%\widowpenalty=300
%\clubpenalty=300
\renewcommand*{\partpagestyle}{empty}
\usepackage{geometry}
\geometry{paperwidth=5.06in,
paperheight=7.81in,
verbose,
tmargin=0.5in,
bmargin=1in,
inner=0.75in,
outer=0.5in,
headheight=0.1in,
headsep=0.15in,
footskip=0.45in,
twoside}
%\usepackage{showframe}
\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
\newcommand{\mytitle}{Tears in the Rain}
%JB: Saving it and later using it again. 
\begin{document}
\title{\mytitle}
\frontmatter
\date{}
\maketitle
\begin{titlepage}
\begin{flushright}
	{\huge \mytitle}%JB: Those are switches active
%in the current group
	\vspace{0.5in}
	\huge{\raisebox{\depth}{\scalebox{1}[-1]{\mytitle}}} \par\bigskip
	\par\end{flushright}{\huge \par}
\end{titlepage}


\begin{titlepage}
\noindent\includegraphics[width=4in,height=2in]{bensig}
\vspace*{0.5in}
\begin{flushright}
	{\Huge{}Tears in the Rain}
	\par\end{flushright}{\Huge \par}
\end{titlepage}

\begin{titlepage}
\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}
\end{titlepage}



\iffalse
You have been doing much by hand. That isn't the LaTeX way, but
ok for title pages. But please don't hand craft in the main part.
\fi

\tableofcontents

\addchap{Preface}
%JB addchap does magic for you

\emph{Tears in the Rain}, %JB: emphasize (use semantic markup)
set in the emerging hippie Age of Aquarius in the early nineteen
sixties... \marginpar{The times of Love, Peace and Music}
\blindtext[3]

\mainmatter
%\noindent%JB: Why?
\part{How it all began}
\blinddocument
\part{How it all ended}
\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 » 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: 4185
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: 4185
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 7 guests