GeneralAdd newpage at end of section automatically

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
axelh
Posts: 16
Joined: Wed Jan 23, 2008 12:22 pm

Add newpage at end of section automatically

Post by axelh »

Is there some easy way to make each section (not only chapter) start in a new page? How can this be achieved other than adding "\newpage" manually at the end of each section?

I have too many sections... too lazy :) and also I want to try \newpage, \clearpage, etc and compare what I prefer. so that I want to change it only once at the beginning for the whole document.

Thanks!

Axel

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Add newpage at end of section automatically

Post by Stefan Kottwitz »

Hi Axel,

you could do it this way:

Code: Select all

\let\stdsection\section
\renewcommand\section{\clearpage\stdsection}
Stefan
LaTeX.org admin
axelh
Posts: 16
Joined: Wed Jan 23, 2008 12:22 pm

Re: Add newpage at end of section automatically

Post by axelh »

Hi Stefan,

Thanks.

I tried, it works. BUT, the first section of each chapter is also starting on a new page, in a different page than the chapter's title. And I don't want that...

Any clue how to avoid it? Maybe by putting the new page command at the end of each section? But I don't see how to do it...
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Add newpage at end of section automatically

Post by Stefan Kottwitz »

Hi Axel,

you could check the section counter:

Code: Select all

\makeatletter
\renewcommand\section{\ifnum\c@section>0{\clearpage}\else\fi\stdsection}
\makeatother
Stefan
LaTeX.org admin
axelh
Posts: 16
Joined: Wed Jan 23, 2008 12:22 pm

Re: Add newpage at end of section automatically

Post by axelh »

that's smart!! thanks!
songuke
Posts: 1
Joined: Wed Jul 28, 2010 7:53 am

Add newpage at end of section automatically

Post by songuke »

For those who copy and paste, this is the code that works for me (merging from two pieces of code) above:

Code: Select all

\makeatletter
\let\stdsection\section
\renewcommand\section{\ifnum\c@section>0{\clearpage}\else\fi\stdsection}
\makeatother
Thanks.
Post Reply