# Section open right in scrbook

Using scrbook, I would like sections to open on a new odd page, like chapters do. How can I achieve that?

-

Just add \cleardoublepage to the action of \section.

No packages:

\long\expandafter\def\expandafter\section\expandafter{%
\expandafter\cleardoublepage\section}


Shorter:

\usepackage{etoolbox}
\preto\section{\cleardoublepage}


Note: the \section command has (in the standard classes and also in the KoMa-script classes) a definition without arguments. The arguments are absorbed by other macros called by it.

If you want to respect the openany or openright option, then \cleardoublepage is not the correct command. Thus

\usepackage{etoolbox}
\makeatletter
\preto\section{\if@openright\cleardoublepage\else\clearpage\fi}
\makeatother


should be used.

The "no package" version of this one might be

\makeatletter
\toks0={\if@openright\cleardoublepage\else\clearpage\fi}
\toks2=\expandafter{\section}
\long\edef\section{\the\toks0 \the\toks2 }
\makeatother

-
“Note: the \section command has … in the KoMa-script [sic!] … a definition without arguments.” That’s not fully true anymore since KOMA-Script version 3.10: With some options for the class key headings in the optional argument of all heading commands the keys head and tocentry are possible. Or did I misunderstand? –  Speravir Sep 18 '12 at 21:58
@Speravir The "user level" syntax for \section shows an optional argument; but the real implementation is always of the form \newcommand\section{\@startsection{...}...}: the optional argument (or the *-version) is absorbed by \@startsection or better, to go into more depth, by \@sect. –  egreg Sep 18 '12 at 22:07
OK, thanks for clarification. –  Speravir Sep 18 '12 at 22:18
@egreg Suppose I've defined \section{Appendix}, taking into account that "the \section command has ... a definition without arguments" how can I make the following command work: \preto{\section{Appendix}}{\setcounter{secnumdepth{0}}?. (I'm using the article class). –  petobens May 30 '13 at 16:03
There is a typo en my previous comment, it should read: \preto{\section{Appendix}}{\setcounter{secnumdepth}{0}}. –  petobens May 30 '13 at 16:12

You can redefine \section to add \cleardoublepage or \clearpage (depending on whether openright or openany is active) so as to behave as \chapter:

\documentclass{scrbook}
\usepackage{lipsum}

\makeatletter
\renewcommand\section{%
\if@openright\cleardoublepage\else\clearpage\fi
\@startsection{section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\setlength{\parfillskip}{\z@ \@plus 1fil}%
\raggedsection\normalfont\sectfont\nobreak\size@section\nobreak}}
\makeatother
\begin{document}

\section{Test Section One}
\lipsum[1]
\section{Test Section Two}
\lipsum[1]

\end{document}

-
This one is quite interesting, as it mimicks the behavior set for chapter. I like that. –  ℝaphink Sep 18 '12 at 14:29
@ℝaphink egreg has added the same in his edited answer. –  Gonzalo Medina Sep 18 '12 at 14:32
Yes. I chose his answer because it's got several options. –  ℝaphink Sep 18 '12 at 15:12
\documentclass{scrbook}
\let\mySection\section
\renewcommand\section{\cleardoublepage\mySection}
\begin{document}
\chapter{foo}
text
\section{bar}
text
\end{document}

-
Quite straightforward… –  ℝaphink Sep 18 '12 at 14:30