I have a book with lots of chapters and many sections in each chapter.
Some chapters, I want to automatically make each section start on new page, but not in some other chapters.
The problem is that \newcommand{\sectionbreak}{\clearpage}
from titlesec
when added to preamble, has a global effect on the whole document. So all sections in each chapter will start on new page.
Is there a way to control when this command is active (or other solution) so one can turn it on/off at start of the chapter they want each section to start on or not at a new page?
I can of course not use titlesec
command at all, and manually add \clearpage
before each section
in those specific chapters, but this is too much work, as there are many sections and many chapters, and also if later I changed my mind, I have to go edit them all again one by one.
If there is one command per chapter, then I have to turn that off in one place and it will be much easier to maintain also.
Here is a MWE of what I mean
\documentclass[11pt]{scrbook}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}%this is global effect
\begin{document}
\chapter{introduction}
%\Need Command Here To turn OFF Starting Each
%Section On New Page After The First Section
\section{A}
blabla
\section{B}
blabla
\chapter{Another chapter}
%\Need Command Here To turn ON Starting Each Section On New Page
%And later on, in next chapter, I might turn it off again
\section{A}
blabla
\section{B}
blabla
\end{document}
reference start-new-page-with-each-section
btw, I use lualatex.
\renewcommand\sectionbreak{}
at the start of chapters where it is disabled and redefine it back to clearpage in the others.