1

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.

Imran
  • 3,096

1 Answers1

0

I thank David Carlisle; his authoritative statement that such an abnormality should not happen with \clearpage command urged me to go over my file with confidence that I will catch something.

It turned out that I have a \verbatim environment at the end of a section and the last line happens to be a blank line (not my intention) and it is this blank line which prints on the next page. The next page having thus being used (albeit with a blank line) LaTeX starts the new section on a new page, giving me a blank page which actually contains the last blank line of a \verbatim environment.

Removing that blank line solved the apparent anomality.

Thanks again to David Carlisle.

(However, now just out of curiosity, is there a key to check if Latex started a new page?)

Thanks to everyone who took time to comment.

Mensch
  • 65,388