Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have used LaTeX on and off for a number of years now for several large documents with evolving versions over long lifetimes. But every time it seems like, powerful and wonderful as LaTeX is, there arise cases where I want to tweak the pagination in ways that are impossible without using the \newpage or \clearpage sledgehammer.

The macro I think I want is something like

\ifnotremaining{<length>}{<cmd>}

that is, if less than space remains on the page then perform . For example:

\ifnotremaining{5cm}{\newpage}

Note that <length> need not be perfect–if a little too big no problem, or a little small (perhaps because the "protected" text got bigger) then you just increase it a bit. FWIW, I am usually happy with \raggedbottom.

An alternative might be a \disablepagebreak and \enablepagebreak pair which could be used to forbid a page break in the given range of text. (This capability cannot be formulated as an environment because it cannot always nest wrt other environemnts.)

Is there something I have overlooked that can fill this need?

share|improve this question
1  
Welcome to TeX.sx! Maybe you want to have a look at the package needspace –  egreg Feb 1 '13 at 14:29
    
Have you tried the pagebreak's optional argument? –  vonbrand Feb 1 '13 at 14:30
1  
the needspace package provides the \needspace{_space needed_} command (otherwise only available in memoir). the command looks pretty trivial, but it reserves the space you need. of course, this means you need to run your document to see where the page break falls, before adding the command. –  wasteofspace Feb 1 '13 at 15:06
    
\needspace is new to me, but looks like exactly what I seek. I will definitely try it out. –  Ron Brender Feb 1 '13 at 19:08

1 Answer 1

Let me switch the comments to an answer

The package needspace does exactly what are you looking for.

The package has the following introduction:

This packages two commands, \needspace and \Needspace, for reserving space to keep a certain amount of material from being split over a page break. If there is not enough space, a \newpage is automatically inserted.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.