I am writing a document which consists of the repeating format: text, figure, then a larger paragraph. How can I prevent a page break between both of the text and figure
environments, whilst not removing the ability to automatically break the page within the body of the second text?
\nopagebreak
doesn't seem to have any effect after the figure
environment. (And I assume confining it to a minipage
would not allow page-breaking in this second paragraph.)
I'm fine with white space at the end of a page, but I'd rather each repeating group not necessarily start on a new page.
Best Answer
May be that what the OP is looking for is simply a version of, say, the
center
environment which prohibits page breaks above and below itself; this is easy to accomplish. For example, the following MWE defines an environment namedcenternopagebreaks
that locally redefines the appropriate parameters and then invokes thecenter
environment.Note: While testing this example, I’ve noticed that the
\captionof
command inserts a legal breakpoint between the figure and its caption. I’ve made up for this by wrapping everything up in aminipage
environment, but isn’t this a bug?I don’t think that it is meaningful to show the output; rather, you should uncomment the diagnostic commands and check that the penalties reported in the transcript file are correct.