1

In another question asked here (Customizing chapter and section style (scrbook)), esdd gave me some recommendations for improving my code. I'm opening here a new question for not mixing things. The code can be found below. Some of the corrections suggested by esdd I was able to made myself but I have still some remaining problems:

  1. Do not set \parskip manually! Use the KOMA-Script option parskip=half- instead. There are other values for this option like half, half+, half* and the same with full. For further explanations see the scrguien.pdf (KOMA-Script documentation).

Is the meaning of \parskip 0.1in in my code? Should I just replace this by parskip=half-?

  1. I would suggest to use package geometry to set the page margins.

How can this be done to get the same page layout as now?

main.tex

\documentclass[a4paper,twoside,12pt,chapterprefix=false,listof=totoc,bibliography=totoc]{scrbook}

\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{longtable}
\usepackage[font={small,sl},hang,labelfont=bf]{caption}
\usepackage{booktabs}

\ifpdfoutput{%
    \usepackage{graphicx}
    \usepackage[]{pdfpages}
}{%
    \usepackage{graphicx}
}
\usepackage{rotating}

\usepackage{scrlayer-scrpage}
\KOMAoptions{headinclude}

% **** Defining chapter style start ****

\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{charter}

\definecolor{mybluei}{RGB}{28,138,207}
\definecolor{myblueii}{RGB}{131,197,231}

\addtokomafont{disposition}{\usefont{T1}{qhv}{b}{n}\selectfont\color{myblueii}}

\addtokomafont{chapter}{\fontsize{30pt}{30pt}\selectfont}
\newkomafont{chapternumber}{\fontsize{50}{120}\selectfont\color{white}}
\newkomafont{chaptername}{\itshape\rmfamily\small\color{white}}
\addtokomafont{chapterentry}{\normalcolor}% entrys in tableofcontents not blue

\addtokomafont{section}{\fontsize{14pt}{14pt}\selectfont}
\newkomafont{sectionnumber}{\fontsize{18pt}{18pt}\selectfont\rmfamily\color{white}}

\addtokomafont{subsection}{\fontsize{12pt}{12pt}\selectfont}
\newkomafont{subsectionnumber}{\fontsize{16pt}{16pt}\selectfont\rmfamily\color{white}}

\setcounter{secnumdepth}{\subsectionnumdepth}% subsubsection and lower unnumbered

\renewcommand\chapterformat{%
  \raisebox{-6pt}{\colorbox{mybluei}{%
      \parbox[b][60pt]{45pt}{\centering%
        {\usekomafont{chaptername}{\chaptername}}%
        \vfill{\usekomafont{chapternumber}{\thechapter\autodot}}%
        \vspace{6pt}%
      }}}\enskip}

\renewcommand\sectionformat{%
  \setlength\fboxsep{5pt}%
  \colorbox{mybluei}{%
      \parbox{40pt}{\centering\usekomafont{sectionnumber}{\thesection\autodot}}}%
    \quad%
  }

\renewcommand\subsectionformat{%
  \setlength\fboxsep{5pt}%
  \colorbox{mybluei}{%
    \parbox{60pt}{\centering\usekomafont{subsectionnumber}{\thesubsection\autodot}}}%
\quad%
}

\makeatletter
\renewcommand\sectionlinesformat[4]{%
  \@hangfrom{\hspace*{#2}#3}{#4}%
  \ifstr{#1}{section}{%
    \par\nobreak\vspace*{-\parskip}% <- changed
    \ifstr{#3}{}{%
      \rule[\dp\strutbox]{\textwidth}{1pt}}{%
      \hspace*{50pt}\rule[\dp\strutbox]{\dimexpr\textwidth-50pt}{1pt}}%
  }{}%
  \ifstr{#1}{subsection}{%
    \par\nobreak\vspace*{-\parskip}% <- changed
    \ifstr{#3}{}{%
      \rule[\dp\strutbox]{\textwidth}{1pt}}{%
      \hspace*{70pt}\rule[\dp\strutbox]{\dimexpr\textwidth-70pt}{1pt}}%
  }{}%
}
\makeatother

% **** Defining chapter style end ****

\ifpdfoutput{%
    \usepackage[pdftex,
        bookmarks,
        bookmarksopen=true,
        bookmarksnumbered=true,
        pdfauthor={Rafael Wampfler},
        pdftitle={Engagement Detector: Modelling engagement dynamics in virtual environments},
        pdfsubject={The report of the master thesis about the modelling engagement dynamics in virtual environments.},
        pdfkeywords={machine learning, engagement dynamics, classification, virtual environments, calcularis, learning, minecraft},
        colorlinks=false,
        linkcolor=black,
        citecolor=black,
        filecolor=black,
        urlcolor=black,
        anchorcolor=black,
        menucolor=black,
        breaklinks=true,
        pageanchor=true,
        plainpages=false,
        linkbordercolor=red,
        citebordercolor=red,
        urlbordercolor=red,
        pdfpagelabels=true]{hyperref}
}{}

\ifpdfoutput{%
    \pdfcompresslevel=9
    \DeclareGraphicsExtensions{.pdf,.png}
}{}

\bibliographystyle{alpha}

\topmargin -0.5in
\textheight 9.3in
\textwidth 6.3in
\oddsidemargin 0.18in
\evensidemargin -0.22in
\parskip 0.1in
\parindent 0in

\renewcommand{\arraystretch}{1.5}
\renewcommand{\baselinestretch}{1}

\begin{document}

\input{studchapter}

\hypersetup{pageanchor=false}

\hypersetup{pageanchor=true}
\pagenumbering{roman}
\setcounter{page}{1}

%\include{abstract}

%\include{acknowledgment}

\tableofcontents
\cleardoublepage

\listoffigures
\cleardoublepage

\listoftables
\cleardoublepage

\pagenumbering{arabic}

% ---- MAIN PART ----

  \chapter{Chapter Title}
  \section{Section Title}
  \blindtext
  \addsec{Unnumbered Section Title}
  \blindtext
  \subsection{Subsection Title}
  \blindtext
  \subsubsection{Subsubsection Title}
  \blindtext
  \blinddocument

% ---- END MAIN PART ----

\appendix
\clearpage

%\include{appendix}

\clearpage
\renewcommand*{\chapterpagestyle}{empty}

\bibliography{references}

\end{document}

studchapter.tex

\renewcommand*{\chapterheadstartvskip}{\vspace*{215pt}}

\def\mychpstyleintl{%
{\noindent\setlength{\tabcolsep}{0pt}\setlength{\arrayrulewidth}{2pt}%
\begin{tabular}{c}
\\[100pt]
\begin{tabular}{lr}
\begin{tabular}{p{0.6\linewidth}}
\\
\end{tabular}
&
\begin{tabular}{p{0.4\linewidth}}
\rightline{{%
\sffamily%
\fontseries{bx}%
\fontshape{n}%
\fontsize{100}{120}%choose baselineskip to be 1.2 times font size
\selectfont
\thechapter}}
\end{tabular}
\end{tabular}\\[300pt]
\end{tabular}
}}

Edit: There are two more problems which I encountered.

  1. cfr said that times is deprecated and should not be used. He said

URW's Helvetica clone should be scaled to match URW's Times clone

Should I now use URW Helvetica or URW Times? I don't understand it exactly. Second, how can I use it? Is just need something which replaces excactly usepackage{times}.

  1. When I compile the document I'm getting the following message on line 1

Underfull \vbox (badness 1960) has occurred while \output is active []

How can I resolve this?

Edit 2: I have two last problems regarding the layout.

  1. I would like to have the following spacing:

    \titlespacing*{\chapter}{0pt}{50pt}{30pt} \titlespacing*{\section}{0pt}{13.2pt}{0} \titlespacing{\subsection}{0pt}{13.2pt}{0} \titlespacing{\subsubsection}{0pt}{13.2pt}{*0}

I think I have to do it with the following command:

\RedeclareSectionCommand[
  beforeskip=50sp,
  afterskip=30\baselineskip]{chapter}

\RedeclareSectionCommands[
  beforeskip=0\baselineskip,
  afterskip=13.2\baselineskip
]{section,subsection,subsubsection}

But what values do I have to insert? When I use it, there is no change in the spacing.

  1. How can I make a horizontal rule below the top header (where the current chapter page or section is written)? And last but not least on the even pages it is written
  1. Chapter title

but I would like it to have

Chapter 1. Chapter title

Is this possible?

  • Reg. 1): parskip=half- is an option you have to pass to KOMA, i.e., delete \parskip 0.1in completely and do \documentclass[parskip=half-]{scrbook}. Reg. 2) Use the options provided by geometry, e.g., \usepackage[left=3cm, right=2cm, textheight=9.3in, textwidth=6.3in, top=2.5in, includehead]{geometry}. I suggest you consult the documentation of those packages. – Arash Esbati Jan 24 '16 at 19:51
  • If you are using KOMA - and it is impossible to tell what you are doing when you don't post compilable code - use typearea rather than geometry if at all possible as the latter will break some KOMA functionality. times is deprecated and ought not be used. URW's Helvetica clone should be scaled to match URW's Times clone. Saying \ifpdfoutput then \pdfoutput=1 is pointless (if A=1, then let A=1). Don't set graphics extensions unless you are really, really sure you need to. subfigure is obsolete. Don't pass pdftex to graphicx. Don't load packages twice. – cfr Jan 24 '16 at 20:12
  • Do you really need to use lower level font switching so much? \usepackage{charter} almost certainly has no effect. If it is doing anything, it probably isn't something you want. Unless you have a very special use case and are a typographic expert, stick to the higher level commands and the range of sizes and families they offer e.g. \sffamily, \Huge, \LARGE etc. – cfr Jan 24 '16 at 20:14
  • @cfr Thank you everybody for the help. I have changed the code, now it should compile – machinery Jan 24 '16 at 21:31
  • I have made an update, see Edit in the post above. – machinery Jan 24 '16 at 22:16
2

The KOMA-Script classes provide an option parskip to use a skip instead a par indent. Remove both lines \parskip 0.1in and \parindent 0in from your code and use

\documentclass[...,parskip=half-,...]{scrbook}

to get a similar skip between paragraphs.

KOMA-Script classes load and use package typearea to calculate the margins and the text body. If you have special needs for the margins you can use package geometry.

From the KOMA-Script documentation:

The typearea package was not made to set up predefined margin values. If you have to do so you may use package geometry (see [Ume10]).

But then you are full responsible for the settings of the margins and the text block and you have to avoid options and commands of typearea.

So remove \KOMAoptions{headinclude} and the settings for \topmargin, \textheight, \textwidth, \oddsidemargin and \evensidemargin and use instead

\usepackage{geometry}
\geometry{%
  includehead,
  top = .5in,
  textheight = 9.3in,
  textwidth = 6.3in,
  inner = 1.18in
}

Here is a short MWE without all the stuff that is not related to parskip and geometry:

\documentclass[12pt,
  parskip=half-% <- insert this line
]{scrbook}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}

% insert the following lines
\usepackage{geometry}
\geometry{%
  includehead,
  top = .5in,
  textheight = 9.3in,
  textwidth = 6.3in,
  inner = 1.18in
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% remove the following lines from your document
%\KOMAoptions{headinclude}% has no effect if geometry is later used

%\topmargin -0.5in
%\textheight 9.3in
%\textwidth 6.3in
%\oddsidemargin 0.18in
%\evensidemargin -0.22in
%\parskip 0.1in
%\parindent 0in
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{blindtext}% dummy text
\begin{document}
\tableofcontents
\chapter{Chapter Title}
\Blindtext
\blinddocument
\end{document}

Result:

enter image description here

Note that your inner margin is wider than the outer margin. Normally the outer margin should be twice as wide as the inner margin. For further explanations see KOMA-Script documentation section 2.1. Fundamentals of Page Layout.


Regarding your third question: Replace package times by package mathptmx and use option scaled for package helvet:

\usepackage{mathptmx}
\usepackage[scaled]{helvet}

Regarding your fourth question: KOMA-Script classes use \flushbottom for twosided documents automatically. If you want to change this behavior set \raggedbottom. Please read \flusbottom vs \raggedbottom.

  • Thank you very much. I will try it out and let you know. By the way, do you have some solution for my problem 3 and 4 (original post above)? Especially the one with the time package... – machinery Jan 25 '16 at 0:27
  • It worked very well, thank you very much. The problem 3 and 4 from my original post remains. cfr said that the geometry package will break some functionality of the koma class. Is this not right? I'm a bit confused. Second, you said that the outer margin should be twice as wide as the inner margin. How would this change the code? I think in the template the text width is a bit too high but I think when the outer margin is twice the inner margin this should change. – machinery Jan 25 '16 at 10:18
  • See my updated answer. You can use geometry with a KOMA-Script class if you need special settings for the margins. This is also mentioned in the documentation (see the quote in my answer). But then you can not use the possibilies of package typearea and you are fully responsible for the margins and the text block settings. Please do not ask different things in one question. – esdd Jan 25 '16 at 21:25
  • Thank you again very much. Your help is a pleasure. Everything is fine except the thing with the margin is confusing me. It is a template from my university for my master thesis. As you see the template is far from perfect but with the corrections here it should be ok. I know how to write LaTeX but I'm not good in styling. Would it be possible that you quickly show me how to make the outer margin twice the inner margin (or how you would set the margins for a thesis)? In most other thesis, the text body width is also much smaller... Grüsse aus Deutschland. ;) – machinery Jan 25 '16 at 23:15
  • If there are no specifications that must be respected I would remove geometry at all and let typearea do the job. Package typearea is loaded by the KOMA-Script classes automatically. But if you have to set special margin widths you have to use geometry. If the outer margin should be twice as wide as the inner (as recommended for twosided documents) set inner=<innervalue> and outer=<outervalue> with outervalue is twice innervalue. In that case do not set textwidth. Maybe you need a bindingoffset. Please read the class and package documentations. – esdd Jan 26 '16 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.