Start sections on a new page, excepting the first one

sectioningtitlesec

So, I've seen this, but I need sections to start on a new page only after the first one

And I've been trying many different methods, and I was thinking that I could make an if statement somewhere that if the section number exceeds 2, it'll begin adding a \clearpage. But I need this if statement to run with each new section that gets created, in theory

My major attempt at this was to do it inside my already-exsiting \titleformat command, since I thought that it'll run the if with each new section, and it looked something like this:

\newcommand{\sectionbreak}{} % create it empty at first to modify later
\titleformat{\section}
{\large\bfseries}
{\thesection}
{0pt}
{
\ifnum\value{section} > 1
{\renewcommand{\sectionbreak}{\clearpage}}
\else{\renewcommand{\sectionbreak}{}}
\fi
}
{}

I thought it'll run the if after each section, because, in another document, I have another \ifnum statement similar to this one that makes a \hspace smaller in the separator, if the section number is larger than 10

But, this doesn't work, and I don't know what else to try. So, any solutions? This is going to be something used in both a book, and also in an article documentclass. So, class isn't very relevant

Best Answer

Just define \sectionbreak properly:

\documentclass{book}

\usepackage{titlesec}

\titleformat{\section}
  {\large\bfseries}
  {\thesection}
  {1em}
  {}
\newcommand{\sectionbreak}{\ifnum\value{section}>0 \clearpage\fi}

\begin{document}

\tableofcontents

\chapter{One:}

\section{on same page}

Some text

\section{On new page}

Some text

\section{On new page}

Some text

\chapter{Two:}

\section{on same page}

Some text

\section{On new page}

Some text

\section{On new page}

Some text

\end{document}

enter image description here

Related Question