[Tex/LaTex] Using parskip and geometry package correctly in the document

formattinggeometryparskip

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?

Best Answer

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.

Related Question