Maybe some of you can already guess what I'm trying to achieve; I want to redefine some commands with the following result: every \section
should start on a new page except for sections which are placed directly after a \part.
MWE:
\documentclass[a4paper,10pt]{article}
\usepackage{lipsum}
\begin{document}
\part{Part one}
\section{First section}
\lipsum[1]
\section{Second section}
\lipsum[2]
\section{Third section}
\lipsum[1]
\part{Part two}
\section{First section}
\lipsum[3]
\section{Second section}
\lipsum[1]
\end{document}
In the above example, every \section
should create a new page but not the "First sections", since they're located directly after a \part
command.
I started with
\let\oldsection\section
\renewcommand\section{\newpage\oldsection}
but then I got stuck not finding an answer to the question on how to built up an exception (so that the \part
sticks together with the following \section
on one page).
I hope you know how to cope with my problem – you probably do; I never saw you being unable to solve a problem!
Best Answer
Use a conditional to turn off page breaks after a part:
If you want to exclude some section from the mechanism, add
to your preamble and use
\sectionnobreak
instead of\section
. Alternatively, addto the preamble and type
for the section you want to exclude from the automatic page break. The first section after
\part
will not need any adjustment in any case.