4

My publisher wants the chapter titles centered. Sometimes the title is spreading over two lines which means that the title in the first line very much looks like text. Is it possible to add some indent on the right and left? Or limit the \textwidth to say 0.8\textwidth?

MWE:

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{blindtext}

\renewcommand*{\raggedchapter}{\centering}  
\setkomafont{chapter}{\normalfont}

\begin{document}

\chapter{A very long title with more than one line of text to be typeset in the center with indentation at the left and right}

\blindtext
\end{document}

Current output with the desired maximum expansion in red: enter image description here

6

You can redefine \chapterlinesformat:

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{blindtext}

\renewcommand*{\raggedchapter}{\centering}
\setkomafont{chapter}{\normalfont}

\renewcommand*\chapterlinesformat[3]{%
  \raggedchapter
  \parbox{.8\textwidth}{\raggedchapter#2#3}%
  \par\nopagebreak
}

\begin{document}

\chapter{A very long title with more than one line of text to be typeset in the center with indentation at the left and right}

\blindtext
\end{document}

enter image description here

| improve this answer | |
  • Both solutions seem to work fine! I prefer this one to Ulrikes because it works without loading a package. But from a technical side it is beyond me which one is better/preferable. – Martin Mueller Dec 14 '17 at 9:28
4

You can do it with the ragged2e package:

\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{ragged2e}
\renewcommand*{\raggedchapter}{%
 \CenteringLeftskip=2cm plus 2em\relax 
 \CenteringRightskip=2cm plus 2em\relax 
 \Centering}
\setkomafont{chapter}{\normalfont}

\begin{document}

\chapter{A very long title with more than one line of text to be typeset in the center with indentation at the left and right}


\blindtext
\end{document}

enter image description here

But I normally prefer to add a new line manually as you can than more easily choose a semantically sensible place:

  \chapter[text for the toc]{%
   A very long title with more than one line of text \\
   to be typeset in the center with indentation at the left and right}
| improve this answer | |
  • I just noticed this solution does not center the chapter mark properly. this is easily done by moving \thechapter to the beginning of the main text of the chapter. – Martin Mueller Dec 14 '17 at 22:35

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.