I would like to start each section on a new page. Is adding the following to my preamble this the preferred method, or a hack?
\let\stdsection\section
\renewcommand\section{\newpage\stdsection}
I would like to start each section on a new page. Is adding the following to my preamble this the preferred method, or a hack?
\let\stdsection\section
\renewcommand\section{\newpage\stdsection}
The titlesec package allows to do this with just
\newcommand{\sectionbreak}{\clearpage}
It's cleaner than what you were doing and the package also allows to completely customize sections. Here's a fully compilable code sample showing how it works:
\documentclass{article}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
\begin{document}
Text
\section{Title}
Text
\subsection{Title}
Text
\subsection{Title}
Text
\section{Title}
Text
\end{document}
\subsection without content, the \section after it won't be pushed to a new page. I don't know whether this is a bug, expected, or irrelevant, but I thought it's worth mentioning it as first I was a bit puzzled why the \clearpage solution didn't work.
– Karoly Horvath
Jul 26 '13 at 17:43
\ttl@straight@ii in titlesec.sty, you clearly see the explanation for this phenomenon: the \sectionbreak command is only used if the boolean @nobreak is false, which is not the case just after a subsection title (but is once some text has been typesetted). One could easily patch \ttl@straight@ii to behave as you want, but it's probably simpler to use the solution from http://tex.stackexchange.com/q/47047
– Philippe Goutet
Jul 26 '13 at 19:11
\thispagestyle{plain} together with \pagestyle{fancyplain} from the fancyhdr package.
– JonnyJD
May 12 '15 at 08:16
\clearpage does (it clears all figures then makes a page break). Try using another pagebreaking command like \pagebreak if you don't want this.
– Philippe Goutet
Apr 27 '16 at 04:55
hyperref before titlesec, which is why it doesn't work (there are a few exceptions, but generally speaking, hyperref should be the last package you load). Alternatively, you can make if work with hyperref loaded first by using \newcommand{\sectionbreak}{\clearpage\phantomsection}.
– Philippe Goutet
Nov 09 '16 at 06:45
\newcommand{\sectionbreak}{\ifnum\value{page}=1\ifnum\value{section}=1\else\clearpage\fi\else\clearpage\fi}
– Philippe Goutet
May 07 '20 at 07:47
\section and that made the first \section to use \clearpage right after that text. Which makes sense.
However, things don't work out for me in general, because apparently titlesec doesn't go well with the documentclass amsart which I need. Thanks anyway, I liked your approach.
– Jim
May 11 '20 at 03:08
Obligatory ConTeXt solution:
\setuphead[section][page=yes] % or page=right
With an uptodate TeX distribution you can use
\AddToHook{cmd/section/before}{\clearpage}
Example:
\documentclass{article}
\AddToHook{cmd/section/before}{\clearpage}
\begin{document}
\tableofcontents
Text
\section{Title}
Text
\subsection{Title}
Text
\subsection{Title}
Text
\section{Title}
Text
\end{document}
texdoc lthooks-doc in a command prompt.
– esdd
Jan 07 '23 at 12:25
The accepted answer in that form won't work as expected in LyX. This solution causes problems when the document includes a ToC and hyperref support: It makes the paging of the hyperref links be off-sync with the document paging (e.g. clicking on Section 3 which is on p4 will take you to p3 instead).
As mentioned in the comments, this happens because by default LyX is loading hyperref before titlesec. To work around this you can use \newcommand{\sectionbreak}{\clearpage\phantomsection}.
Alternatively, in LyX, you can include in Document Settings > Local Layout:
Provides hyperref
And then load hyperref manually in the LaTeX preamble, like this:
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
\usepackage{hyperref}
Another solution, which uses the sectsty package:
\usepackage{sectsty}
\sectionfont{\clearpage}
An alternative solution is to enclose each section in an \include, because \include does an automatic \clearpage before. No preamble necessary!
I would rather use what Philippe Goutet has already mentioned.
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
These are very convenient and save you the effort of typing \clearpage at the end of each section. Needless to mentioned that you can apply the same to \subsection and \subsubsection. You can also manage the spacing between the section title and the first paragraph.
Perhaps you should take a look at the documentation if you're interested.
I used to use the \renewcommand{\sectionbreak}{\clearpage} solution, but it stopped working when I wanted to change the font color using secsty...
so had to use this instead:
\usepackage{etoolbox}
\preto{\section}{%
\ifnum\value{section}=0 \else\clearpage\fi
}
the conditional is there to keep it from putting the first section of a new chapter on a new page. If you want also the first section of each chapter on a new page you can simply use
\preto{\section}{\clearpage} with etoolbox or \sectionfont{\clearpage} with secsty
For me, only a combination of the previous answers works correctly:
\usepackage{sectsty}
\sectionfont{\clearpage\phantomsection}
(The same without \phantomsection causes refs point to incorrect page.
And \newcommand{\sectionbreak}{\clearpage} causes an error with pandoc,
with or without \phantomsection.)
\clearpageinstead of\newpageif you use floats. – Stefan Kottwitz Jan 22 '11 at 22:11\section{with\clearpage\section{– Seamus Jan 22 '11 at 22:41