Page Layout ⇒ not enough space for chapter
not enough space for chapter
Hi,
sometimes happens to me, that a chapter title is at the very bottom of the page and the content of the chapter is on the new page.
This does not look nice. Is there any way, how to tell latex to move the whole chapter to the new page, if there is not enough space in the current page?
I can use \pagebreak, but this "manual" aproach can be tricky...
also I googled samepage, but I am looking for something that can be applied globally on the whole document
thanks a lot
sometimes happens to me, that a chapter title is at the very bottom of the page and the content of the chapter is on the new page.
This does not look nice. Is there any way, how to tell latex to move the whole chapter to the new page, if there is not enough space in the current page?
I can use \pagebreak, but this "manual" aproach can be tricky...
also I googled samepage, but I am looking for something that can be applied globally on the whole document
thanks a lot
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
not enough space for chapter
It cannot happen with a real chapter, i.e. with
Stefan
\chapter
. Do you mean \section
? Or which command shows the problem here?Stefan
LaTeX.org admin
Re: not enough space for chapter
yes, sorry - I meant section
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
not enough space for chapter
Yes,
Stefan
\chapter
starts a new page by itself and is always on top. Normally a section heading should also not be at the end of a page. Do you have a small example document showing such a behavior, with your class and your settings resp. preamble?Stefan
LaTeX.org admin
Re: not enough space for chapter
unfortunately I am not able to create an example of this behaviour...
but here is a sample document with my preamble and it shows what I want to change in latex settings - there is a section with only 2 lines of content and then a page break
but here is a sample document with my preamble and it shows what I want to change in latex settings - there is a section with only 2 lines of content and then a page break
- Attachments
-
- sample.tex
- (2.85 KiB) Downloaded 276 times
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
not enough space for chapter
Text lines at the end are normal - just a section title at the end would be strange.
Well, in any case you could use the
needspace package, even if you don't like this case of the example.
Just specify the required space, here I said 4 lines, but you could give it in ex, pt, cm or any unit as well.
Stefan
Well, in any case you could use the

Code: Select all
\usepackage{needspace}
...
\needspace{4\baselineskip}
\section{test}
Stefan
LaTeX.org admin
not enough space for chapter
needspace looks like it is what I want, but is there any way, how to define it once in preamble, so I don't need to use needspace before each section?
thanks a lot
thanks a lot
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
not enough space for chapter
Sure, you could redefine \section, hook into a related macro, or patch it. Fore example:
Stefan
Code: Select all
\usepackage{needspace}
\usepackage{etoolbox}
\patchcmd{\section}{\@startsection}{\needspace{4\baselineskip}\@startsection}{}{}
LaTeX.org admin
Re: not enough space for chapter
thanks a lot - the wonderful world of latex keeps me amazed all the time 
