# ConTeXt: How can I prevent a block of text from being split over a page break?

At the end of below minimum working example there is a funny `\startdelimitedtext[endtext]` which should be printed at the bottom of the last page without being split over a page break. How do I render `[endtext]` indivisible?

``````\setuppapersize [A4][A4]
\setuplayout    [width=middle,  backspace=1.5in, cutspace=1.5in,
height=middle, topspace=0.75in, bottomspace=0.75in]

\setuppagenumbering[location={footer,center}]

\setuptolerance[horizontal, tolerant, stretch]

\setupexternalfigures [location=default]

\definedelimitedtext[endtext]
\setupdelimitedtext[endtext][before={\vfill}]

\starttext
\input douglas.tex

\input douglas.tex

One line

A second line

And another line

\startendtext
\startalignment[middle]
Written in Hasselt, Belgium!\crlf
\externalfigure[cow][height=31pt]\crlf
Other licensing available on request. Typesetting by \ConTeXt\ \contextmark.
\stopalignment
\stopendtext

\stoptext
``````

Boxes can't be broken across pages, so it makes sense to use a box here. The `\framed` command and the `\startframedtext` environment are examples of boxes.

Since you used `\vfill` I assume the text should be placed at the bottom of the page. This does not work as expected, since TeX removes the vertical space. This is a side effect of how page breaking works in TeX. Usually it's not desired to start a page with vertical space followed by a paragraph, so TeX removes it. That's what the `\null` is for. It's an empty box, so the page does start with a box instead of vertical space. The penalty prevents a page break between this box and the vertical space. Otherwise the vertical space would again end up at the top of the page and removed by TeX.

Furthermore, `\placefloats` ensures that all floats are printed before typesetting `endtext`.

Finally, I replaced your `\crlf` with the lines environment which does respect new lines.

``````\setupexternalfigures
[location=default]

\defineframedtext
[endtext]
[before=\placefloats\null\penalty\plustenthousand\vfill,
width=fit]

\startbuffer
\startendtext
\startlines [align=middle]
Written in Hasselt, Belgium!
\midaligned{\externalfigure[cow][height=31pt]}
Other licensing available on request. Typesetting by \ConTeXt\ \contextmark.
\stoplines
\stopendtext
\stopbuffer

\starttext
\dorecurse{9}{\input ward\par}
\getbuffer

\page
\dorecurse{5}{\input ward\par}
\getbuffer

\page
\dorecurse{9}{\input ward\par}
\getbuffer
\stoptext
``````

• The first box is at the top of the page! Maybe add a `after=\page` to ensure a pagebreak after the box. – Aditya Sep 10 '13 at 2:04
• @Aditya Yes, Marco was a bit eager to show examples by cramming them all in one file. Your remark would indeed correct this. Nonetheless, Marco's answer is correct for this use case. – Serge Stroobandt Sep 10 '13 at 7:11
• @Marco I have added a `\placefloats` at the start of the `begin=` statement. – Serge Stroobandt Sep 11 '13 at 12:43