\documentclass[a4paper]{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1-4]\filbreak
\textbf{This should fit on page 1}~\lipsum[5]\filbreak\lipsum[6-10]\filbreak
\textbf{This should not fit on page 2}~\lipsum[11-12]\filbreak\lipsum[13-19]
\end{document}
The problem arises with the last \filbreak
in this example. It flushes \lipsum[13-19]
to the next page. I want to replace the last \filbreak
it with a command \stopfilbreak
, so that since \lipsum[11-12]
actualy didn't fit on page 2, then it would put \lipsum[11-12]
on page 3 with \lipsum[13-19]
following it (on page 3). Now it sets \lipsum[13-19]
on page 4.
I want a command \stopfilbreak
such that LaTeX interprets "fit the content between \filbreak
and \stopfilbreak
on the same page if possible, else break the page here and put it on a new page". The content to come after \stopfilbreak
should not be affected.
That is: i want a command that restores the normal flow after use of \filbreak
Be aware that it might be so that what would go between \filbreak
and \stopfilbreak
could be larger than a pagewidth, so minipage
would not work.
Below is some background info that I think might be helpful to answer my question:
Background info
Purpose of \filbreak
The TeXbook says that \filbreak
means roughly
“Break the page here and fill the bottom with blank space, unless there is room for more copy that is itself followed by \filbreak.”
That is, if we consider content that is "enclosed" by \filbreak
s, it inserts this content if there is room on the page, but goes to the next page if there is no room.
\filbreak
in practice
\filbreak
is defined by \par\vfil\penalty-200\vfilneg
. As I understand it, this finishes up the current paragraph, then fills the page with stretchable whitespace and then, at the bottom of the page/top of new page it says that "breaking" here is cheap. If the program then decides to break here, then the \vfilneg
doesn't do anything because there is no \vfil
to "neg", but if it doesn't then \vfilneg
puts the "cursor" back.
I'm not using \filbreak
as it was purposed. Everything in my VC-example works as expected, which indicates that I might be asking the wrong question?
\filbreak
is mistaken or at least imprecise. It does not really check or insert anything; it merely inserts a particular sequence of glue and penalties, which are used by the page builder whenever it decides to look for appropriate places to break the page. Rather than go by the informal description in The TeXbook, see the definition you've included. Anyway, it's not clear what you want exactly: where do you want the page breaks to happen / what would you like the general behaviour to be?\filbreak
is wrong. I get that it doesn't "check" anything, I just had problems wording this, which results in that my description of how\filbreak
works is imprecise. Maybe it's just confusing to have the Background info in there? I suspect you missed the "TL;DR"-section in the top (maybe because you read all the rest)? I thought it was quite clear there what I wanted to achieve. If I'm wrong, and you did read it, let me know what is unclear so I can clarify!\outputpenalty
cannot be used in that way to discriminate the two cases.