2

When using koma's twolinechapter,
how do I control the first and second line?

I'd like to:

  1. Make the word Chapter all uppercase.
  2. Reduce the vspacing between [Chapter #] and the [section title].
  3. Center the [section title]. (Only the first line centers.)
    • Possible solution: \renewcommand*{\raggedchapter}{\centering}

MWE:

\documentclass{scrreprt}
\usepackage{setspace}
\usepackage{showframe}

\usepackage{lipsum}

\KOMAoptions{
           % headings      = small,
           % headings      = openany,
             parskip       = half-,
             headings      = twolinechapter}

\doublespacing

\setkomafont{chapter}      {\normalsize}
\setkomafont{section}      {\normalsize}
\setkomafont{subsection}   {\normalsize}
\setkomafont{subsubsection}{\normalsize}
\setkomafont{paragraph}    {\normalsize}
\setkomafont{subparagraph} {\normalsize}

\addtokomafont{chapter}    {\centering\vspace*{-3em}}


\begin{document}

\chapter*{A}
\lipsum[1]

\section*{Aa}
\lipsum[1]

\clearpage

\chapter{B}
\lipsum[1]

\section{Bb}
\lipsum[1]

\clearpage

\chapter{C}
\lipsum[1]

\clearpage

\end{document}
1
  • 1
    \renewcommand*\raggedchapter{\centering} appears to have some effect on centering both lines. Is this the appropriate method to center all chapter headings?
    – kando
    Jun 25, 2017 at 17:43

1 Answer 1

2

To make the word Chapter all uppercase you can redefine \chapterformat:

\renewcommand*{\chapterformat}{%
  \mbox{\MakeUppercase{\chapappifchapterprefix{\nobreakspace}}\thechapter\autodot
    \IfUsePrefixLine{}{\enskip}}%
}

To reduce the space between the two lines of the chapter title you can change the innerskip using e.g.

\RedeclareSectionCommand[
  innerskip=-\parskip
]{chapter}

To center both lines of the chapter title use

\renewcommand*\raggedchapter{\centering}

enter image description here

Code:

\documentclass[
  parskip=half-,
  headings=twolinechapter
]{scrreprt}

\usepackage{showframe}% show the page layout
\usepackage{lipsum}% only for dummy text

\usepackage{setspace}
\doublespacing

\renewcommand*{\chapterformat}{%
  \mbox{\MakeUppercase{\chapappifchapterprefix{\nobreakspace}}\thechapter\autodot
    \IfUsePrefixLine{}{\enskip}}%
}
\RedeclareSectionCommand[
  innerskip=-\parskip
]{chapter}

\renewcommand*\raggedchapter{\centering}

\RedeclareSectionCommands[font=\normalsize]
  {chapter,section,subsection,subsubsection,paragraph,subparagraph}

\begin{document}
\chapter*{A}
\lipsum[1]
\section*{Aa}
\lipsum[1]
\chapter{B}
\lipsum[1]
\section{Bb}
\lipsum[1]
\chapter{C}
\lipsum[1]
\end{document}
8
  • This is similar to your past answer here. Is this an updated response? (Why did you ditch the * in renewcommand for centering?) What are the appropriate methods for altering the vspace before the first line and/or after the second line? (You removed my \vspace from your answer.) Would this be something the typical user would be expected to realize?
    – kando
    Jun 25, 2017 at 18:06
  • 1
    @kando No this here is a different question. In the question you have linked is a rule drawn between the two lines of the chapter heading. Here only the skip between the prefix line and the title should be changed.
    – esdd
    Jun 25, 2017 at 18:16
  • 2
    @kando To change the space before and after the chapter title (including the prefix line) change beforeskip and afterskip using \RedeclareSectionCommand. I did this also in the last update of the answer which you have linked.
    – esdd
    Jun 25, 2017 at 18:25
  • 2
    You have to use at least afterskip=1sp minus 1sp if you do not want an inline heading. So the space between a section heading and the following text is at least the same as between two normal paragraphs.
    – esdd
    Jun 25, 2017 at 22:54
  • 1
    @kando, @esdd With KOMA-Script v3.26 (or later) you can also use runin=false to avoid inline headings. With this option you can use afterskip=0pt to have a zero skip or even afterskip=-2pt so have a real negative skip of 2pt. Apr 3, 2019 at 9:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .