Is there a way to compute the remaining space on the current page and issue an optional command?
Asked
Active
Viewed 1,269 times
25
-
1Related question: How to define a figure size so that is consume the rest of a page?. – Martin Scharrer Apr 23 '11 at 18:28
3 Answers
22
See the needspace package. It might do what you need, or at least give inspiration for whatever it is you're trying to do :-) Namely, the \pagegoal and \pagetotal registers should help.
Torbjørn T.
- 206,688
Will Robertson
- 73,872
9
In ConTeXt, \testpage[n] checks if there is enough space for n lines.
Torbjørn T.
- 206,688
Aditya
- 62,301
-
Thanks! I think it is high time I start migrating to ConTeXt it seems to be the answer to a lot of difficult issues. – yannisl Oct 13 '10 at 12:56
1
Here is a small example demonstrating how the accepted answer's \pagetotal etc behave -- note they only seem to change after a \par (click for high resolution image):
Here is the code used for it:
\documentclass{article}
% http://www.tug.org/utilities/plain/cseq.html#pagedepth-rp
\def\tpageitemsB{%
\the\pagetotal;%
\the\pagegoal;%
\the\pagedepth;%
\the\pagestretch;%
\the\pageshrink;%
\the\pagefilstretch;%
\the\pagefillstretch;%
\the\pagefilllstretch%
}
\begin{document}
\tpageitemsB: ligula aliquet magna, \\
\tpageitemsB: Morbi ac orci et nisl \\
\tpageitemsB: Suspendisse ut massa. \\
\tpageitemsB: a nulla. Cum sociis na \\
\tpageitemsB: dis parturient montes, \\
\tpageitemsB: Aliquam tincidunt urna \\
\tpageitemsB: vestibulum turpis. Pel \\
\tpageitemsB: mauris. \\
\noindent
\tpageitemsB: Nulla malesuada porttitor \par\noindent
\tpageitemsB: congue non, volutpat \par\noindent
\tpageitemsB: libero. Vi- vamus viverra \par\noindent
\tpageitemsB: nonummy pel- lentesque \par\noindent
\tpageitemsB: semper elit. Proin fer \par\noindent
\tpageitemsB: diam turpis, molestie vita \par\noindent
\tpageitemsB: nec, leo. Maecenas lacinia \\
\tpageitemsB: eleifend at, accumsan nec, \\
\tpageitemsB: Morbi blandit ligula feugi \\
\tpageitemsB: consequat lorem. Sed lacin \\
\tpageitemsB: Pellentesque tincidunt pur \\
\tpageitemsB: non enim. Praesent euis \\
\tpageitemsB: mobibendum quam in telus. \\
\tpageitemsB: lectus. Donec et mi. Nam v \\
\tpageitemsB: Vestibu- lum pellentesque \\
\tpageitemsB:\\
\tpageitemsB: Quisque ullamcorper placer \\
\tpageitemsB: Morbi vel justo vitae lacu \\
\tpageitemsB: Lorem ipsum do- lor sit am \\
\tpageitemsB: adipiscing elit. In hac ha \\
\tpageitemsB: Integer tempus convallis a \\
\tpageitemsB: Nunc elementum fermentum w \\
\tpageitemsB: imperdiet, enim sed gravid \\
\tpageitemsB: odio placerat quam, ac pul \\
\tpageitemsB: enim. Nunc vitae tortor. P \\
\tpageitemsB: amet nisl. Vi- vamus quis \\
\tpageitemsB: vehicula. \\
\noindent
\tpageitemsB: Fusce mauris. Vestibulum l \\
\tpageitemsB: Sed bibendum, nulla a fauc \\
\tpageitemsB: ultricies tellus, ac venen \\
\tpageitemsB: Vestibulum diam. Aliquam p \\
\tpageitemsB: sagittis posuere, turpis l \\
\tpageitemsB: hendrerit risus eros eget \\
\tpageitemsB: erat in sapien mattis port \\
\tpageitemsB: porttitor. Nulla facilisi. \\
\tpageitemsB: com- modo facilisis. Morbi \\
\tpageitemsB: dignissim inter- dum, just \\
\tpageitemsB: et vehicula libero dui cur \\
\tpageitemsB: ligula sed lacus. Duis cur \\
\tpageitemsB: ac magna. Cras nulla. Null \\
\tpageitemsB: leo. Quisque egestas wisi \\
\end{document}
sdaau
- 17,079
