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?

  • Anything is possible, but some things are easier than others. Basically, this will invole replacing the given \chapter command. – John Kormylo Aug 22 '14 at 23:51
  • Are you simply looking for \renewcommand\raggedsection\centering? – Johannes_B Aug 23 '14 at 17:45
  • @Johannes_B No, the chapter numbers should be placed in the margin, cf. http://tex.stackexchange.com/questions/196963/section-numbering-in-convex-optimizaion-by-boyd-et-al-with-koma-script/196981?noredirect=1#comment458008_196981. – Christopher Aug 23 '14 at 20:29
  • You have to add my line to the other answer. – Johannes_B Aug 23 '14 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}.

    – Christopher Aug 23 '14 at 21:33
  • Oh, you are right. I was too careless, sorry. – Johannes_B Aug 24 '14 at 07:08
  • Looking at the source for scrbook (Aaaaagh!) I noticed that the table of contents uses \chapter to write "Contents" so if you change the chapter format you will also change the table of contents format. – John Kormylo Aug 26 '14 at 02:57
  • Yes, that's perfectly fine with me. – Christopher Aug 26 '14 at 05:52

1 Answers1

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}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • Thank you, is it possible to place the chapter numbers in the left margin centered relative as in cgnieder's solution for http://tex.stackexchange.com/questions/196963/section-numbering-in-convex-optimizaion-by-boyd-et-al-with-koma-script/196981?noredirect=1#comment458008_196981? – Christopher Aug 26 '14 at 16:57
  • 1
    Sure. I assume you would want it right justified, since the left margin is smaller (odd page). – John Kormylo Aug 26 '14 at 21:11
  • Sorry, it took longer than expected. – John Kormylo Aug 26 '14 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 Aug 26 '14 at 23:09
  • @egreg - Thanks. I tend to leave the original code unchanged if I'm not sure what it does. – John Kormylo Aug 27 '14 at 03:20