How can you get Context MkIV to automatically put in page breaks to keep \section
, etc. headings with the paragraph when accompanied with a floating image, instead of putting the heading at the end of a partial page and the first paragraph wit image in that section at the top of the next page? Adding \testpage
to the sectioning macros doesn't seem a general solution because there is often space for a line of two of text, just not enough for the image.
MWE:
\setuppapersize[letter]
\setupexternalfigures[location=default]
\starttext
\chapter{Chapter}
\section{Section 1}
\input lorem.tex
\input lorem.tex
\section{Section 2}
\placefigure [right]{cow}
{\externalfigure[cow][height=2in]}
\input lorem.tex
\stoptext
This puts the section heading on page one, with the text and image on page two. I'd like to put the section heading with the text and image, without manually adjusting every time the document changes.
Note: there is an solution to a related problem at ConTeXt: Wrapped text misbehaves at page breaks that might be adapted, as it also dealing with finding the size of an image, but I'm a beginner to Context, and not ready to jump into the deep end.
Edit: \testpage
is not a general solution without a way to automatically measure the following image in "number of line", the somewhat arbitrary input to \testpage