I use a very custom style (not mine) and very frequently I get a heading on the bottom of a page and the next paragraph on the top of the next page. Sometimes this paragraph may be a list or similar. The same is true for listings and the listing description.
- Is there a general way how I can adjust the "badness" of these events?
- Or can I adjust when a section heading would be on the last, say, 3cm of a page it should go to the next page?
- Or can I say, if a *listing description" is on the top 3cm of a page pull 5 more listing lines from the last page onto this page?
The style I use does not use standard structure tags and environments. But lets call them section, subsection, listing and I will try to migrate them to my lingo.
listingenvironment. For example, if the description is separate from the actuallistingwhich itself is contained in aminipage(say), then you won't be able to extract "a couple of lines". However, itlistingis typeset as a list (say,enumerate), then you can issue your\needspacebetween the last couple of\items, to make sure "things stay together". If this is insufficient, provide more detail about the actual definition of yourlistingenvironment (or any other environments for that matter). – Werner Oct 20 '11 at 06:46\newcommand{\mylistingheading}{#2}-- well, that sounds promising. Maybe I can tweak that with a\needspace– towi Oct 20 '11 at 06:55\needspace{6em}every time? – Jeroen May 15 '14 at 16:32\needspace{6em}as part of the section command. Easiest would be to add\let\oldsection\section \renewcommand{\section}{\needspace{6em}\oldsection}to your preamble. It may depend on your document class (which I don't know). – Werner May 15 '14 at 17:02needspaceto all of them at once? – Jeroen May 15 '14 at 17:26\sectiondownward (inbookorreport) and\subsectiondownward (inarticle) use\@startsectionto guide the construction/setup of the layout. One could tie into\@startsection, but that would exclude\part. Lots of things to consider, and therefore my easy solution is to add the\needspaceon a per-command basis. – Werner May 15 '14 at 19:28