98

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}
6
  • 4
    Perhaps you would like to use \clearpage instead of \newpage if you use floats.
    – Stefan Kottwitz
    Commented Jan 22, 2011 at 22:11
  • 2
    Why not use a document class that allows chapters, and use them instead (since they automatically start on new page..)
    – Seamus
    Commented Jan 22, 2011 at 22:34
  • 1
    ASeamus not a bad idea, but I'd prefer not to have to change the document class Commented Jan 22, 2011 at 22:39
  • 3
    Alternatively, just find and replace all \section{ with \clearpage\section{
    – Seamus
    Commented Jan 22, 2011 at 22:41
  • 2
    @Seamus I'd like to use this in emacs org-mode, so it is more straightforward to place this in the preamble Commented Jan 22, 2011 at 22:44

9 Answers 9

14

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}
3
  • thanks - I've made this the accepted answer since it is the simplest and doesn't require another package Commented Jul 28, 2021 at 20:36
  • How can I learn about the \AddToHook{}{} command?
    – youthdoo
    Commented Jan 3, 2023 at 13:29
  • @youthdoo See mirrors.ctan.org/macros/latex/base/lthooks-doc.pdf or use texdoc lthooks-doc in a command prompt.
    – esdd
    Commented Jan 7, 2023 at 12:25
115

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}
11
  • 20
    note: if you have a \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. Commented Jul 26, 2013 at 17:43
  • 3
    @KarolyHorvath: if you look up the code for \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 tex.stackexchange.com/q/47047 Commented Jul 26, 2013 at 19:11
  • 2
    @Kaspar: yes, that's what \clearpage does (it clears all figures then makes a page break). Try using another pagebreaking command like \pagebreak if you don't want this. Commented Apr 27, 2016 at 4:55
  • 1
    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). In this sense, the hack in the original question is the better approach...
    – landroni
    Commented Nov 7, 2016 at 20:36
  • 4
    @landroni: no, it works perfectly. You're probably loading 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}. Commented Nov 9, 2016 at 6:45
13

Obligatory ConTeXt solution:

\setuphead[section][page=yes] % or page=right
4
  • 2
    This mysterious answer seems to have more than what meet the eyes. Care to elaborate? Thanks.
    – DrBeco
    Commented Sep 25, 2018 at 4:41
  • 1
    @DrBeco: ConTeXt is a macro package built on TeX (just as LaTeX is a macro package built on TeX). ConTeXt has a much more consistent user interface and many questions that arise in LaTeX have a simple solution in ConTeXt. I am one of the few ConTeXt users on this site. And when I wrote this answer, I was proving ConTeXt solution to various LaTeX questions.
    – Aditya
    Commented Sep 25, 2018 at 7:13
  • If tex4ht would work with context, I would try context. But from what I understand tex4ht only works with latex. This is a major limitation to many who want to convert latex to HTML as well to pdf.
    – Nasser
    Commented May 17, 2019 at 4:30
  • 1
    ConTeXt supports XHTML and XML export out of the box: wiki.contextgarden.net/Export
    – Aditya
    Commented May 17, 2019 at 20:43
8

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}
1
  • +1 for the discussion on LyX. The wider TeX-universe is very diverse, so all aspects are quite valuable to one or the other.
    – Dohn Joe
    Commented May 20, 2021 at 11:26
7

Another solution, which uses the sectsty package:

\usepackage{sectsty}
\sectionfont{\clearpage}
1
  • 1
    Thanks, this finally worked. Tre previous answers, including the accepted answer, didn't do the job in overleaf
    – NeStack
    Commented Apr 29, 2021 at 14:58
3

An alternative solution is to enclose each section in an \include, because \include does an automatic \clearpage before. No preamble necessary!

1
  • 5
    Welcome to TeX.SX! While this works, it may require quite a substantial change to the set-up of the document. Commented Nov 13, 2014 at 10:01
2

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.

3
  • 1
    Would you add this information to the answer above? When answers don't add new information, they may be downvoted on this site. Commented Sep 6, 2018 at 16:07
  • So should I delete my answer?
    – KareemJ
    Commented Sep 7, 2018 at 19:16
  • 3
    Yes, I think that the basis of your question doesn't add anything. If there is something new, you can add that as an edit. Brevity is good, few answers (if new answers don't add information) are good for stackexchange. Commented Sep 9, 2018 at 12:40
2

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

1

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.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .
https://tex.stackexchange.com/questions/9497/start-new-page-with-each-section
tex.stackexchange.com
CC-MAIN-2024-30
268207
application/http; msgtype=response
sha1:WSBY6IXXY7DVNA3D4NVSODZMXL5BB4RC
<urn:uuid:88698d6e-144a-46f4-b3f2-691d278404dd>
2024-07-24T02:49:52Z
104.18.43.226
text/html
sha1:CJKQMNUIVTCB5VDDHJ3F5KYT67MFMOBT
<urn:uuid:27a815f1-bee2-4669-b966-65bf35cf9833>
https://tex.stackexchange.com/questions/9497/start-new-page-with-each-section
response
<urn:uuid:5ec18602-cfd0-4b06-b012-66a29a64cb5f>
isPartOf: CC-MAIN-2024-30
publisher: Common Crawl
description: Wide crawl of the web for July 2024
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-235
software: Apache Nutch 1.20 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.5-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/