3

This is follow up question from Section Numbering in "Convex Optimizaion" by Boyd et. al. with Koma Script.

Is it possible, using the scrbook class, to place the chapter (section) numbers in the margin and center the chapter (section) titles?

8
  • Anything is possible, but some things are easier than others. Basically, this will invole replacing the given \chapter command. Commented Aug 22, 2014 at 23:51
  • Are you simply looking for \renewcommand\raggedsection\centering?
    – Johannes_B
    Commented Aug 23, 2014 at 17:45
  • @Johannes_B No, the chapter numbers should be placed in the margin, cf. tex.stackexchange.com/questions/196963/…. Commented Aug 23, 2014 at 20:29
  • You have to add my line to the other answer.
    – Johannes_B
    Commented Aug 23, 2014 at 20:44
  • @Johannes_B No, that does not work, because the chapter numbers well be centered, too. Note: when using koma-scriptyou should write \addtokomafont{disposition}{\centering}. Commented Aug 23, 2014 at 21:33

1 Answer 1

1

This version implements requests and advice from comments.

\documentclass{scrbook}
\usepackage{lipsum}

\makeatletter
\renewcommand*{\chapterformat}{%
  \chapappifchapterprefix{\nobreakspace}%
  \llap{\thechapter\autodot\enskip%
}}
\renewcommand*{\@@makechapterhead}[1]{\chapterheadstartvskip
  {%
    \normalfont\sectfont\nobreak\size@chapter{}%
    \noindent\ifnumbered{chapter}{\chapterformat}\fi
    \parbox[t]{\textwidth}{\centering\size@chapter{#1}}%
  \nobreak\chapterheadendvskip\par
}}
\makeatother

\begin{document}
\tableofcontents

\chapter{Center}

\lipsum
\end{document}
5
  • Thank you, is it possible to place the chapter numbers in the left margin centered relative as in cgnieder's solution for tex.stackexchange.com/questions/196963/…? Commented Aug 26, 2014 at 16:57
  • 1
    Sure. I assume you would want it right justified, since the left margin is smaller (odd page). Commented Aug 26, 2014 at 21:11
  • Sorry, it took longer than expected. Commented Aug 26, 2014 at 22:38
  • You're missing a % after {\nobreakspace}; moreover \size@chapter has no argument. Instead of a group with a setting of \parindent, just \noindent\mbox is sufficient.
    – egreg
    Commented Aug 26, 2014 at 23:09
  • @egreg - Thanks. I tend to leave the original code unchanged if I'm not sure what it does. Commented Aug 27, 2014 at 3:20

You must log in to answer this question.

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