3

I'd like to have there be a page break in between each section, just like in this question, but I'd also like there to be no page break prior to the first section (that is, between the title and the first section). I'm currently using that question's best answer's suggestion:

\let\stdsection\section
\renewcommand\section{\clearpage\stdsection}

but I can obviously change.

  • if there is text between the title and the first \section, do you still want no page break before the first \section? – barbara beeton Sep 17 '14 at 14:49
4

Instead of \clearpage add a command that, the first time, redefines itself to be the same as \clearpage:

\let\latexsection\section
\renewcommand{\section}{\sectionbreak\latexsection}
\newcommand{\sectionbreak}{\global\let\sectionbreak\clearpage}
| improve this answer | |
  • 1
    Are you Sauron? – joshlf Sep 17 '14 at 19:15
  • 1
    @synful No, I only practice TeX wizardry, which is surely white magic. ;-) – egreg Sep 17 '14 at 20:07
  • *which is whitespace magic – joshlf Sep 17 '14 at 21:58
2

This version resembles the version of egreg, but it regards the (total) section number, such, that there is no pagebreak just before the first section occurs (unless manually forced)

\documentclass[12pt]{article}

\usepackage{etoolbox}%
\usepackage{blindtext}%
\usepackage{assoccnt}%



\let\LaTeXStandardSection\section
\newcounter{totalsection}%

\DeclareAssociatedCounters{section}{totalsection}

\renewcommand{\section}{%
  \ifnumequal{\number\value{totalsection}}{0}{%
  }{%
    \clearpage%
  }%
  \LaTeXStandardSection
}%

\begin{document}

\tableofcontents

\section{First -- with no pagebreak}
\section{Second with pagebreak}%


\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.