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. tex.stackexchange.com/questions/196963/…. – 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
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}
  • 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/…? – 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 3:20

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.