I am using article class with pdflatex and I wanted each section and subsection to begin on top of a new page. I used
\newcommand{\sectionbreak}{\clearpage}
\newcommand{\subsectionbreak}{\clearpage}
But sometimes a subsection ends by filling out its last page and LaTeX puts a new page. Then comes my \clearpage as above and another new page begins, giving me a blank page.
How do I know that a \newpage has already occurred so that I prevent (how?) the automatic \clearpage of the \newcommand above?
Thank you.
\clearpagein a section heading definition shouldn't cause a blank page even if a page break woul dhav enaturally occured at that point. Please always provide a small test document that shows the problem you are asking about. – David Carlisle Jan 02 '22 at 14:45