Reviving an old thread because I found a really simple solution. Hopefully this will also be useful to someone else. On Mon, 18 Oct 2010, Wolfgang Schuster wrote:
Am 18.10.2010 um 14:18 schrieb Otared Kavian:
Your solution works as intended when the framed, highlighted text with background spans over two pages (though it doesn't when it spans over three pages or more, but this is not a real issue, since it is a bad idea to have such long highlighted texts…).
I guess this is also possible with textbackground:
\newcounter\CurrentBackground
\def\StartBackground {\doglobal\increment\CurrentBackground \setposition{Background:b:\CurrentBackground}% \startbackground}
\def\StopBackground {\stopbackground \setposition{Background:e:\CurrentBackground}}
\def\DrawBackground {\ifnum\MPp{Background:b:\CurrentBackground}=\MPp{Background:e:\CurrentBackground} \startMPcode draw topboundary OverlayBox withcolor red ; draw bottomboundary OverlayBox withcolor red ; draw leftboundary OverlayBox withcolor red ; draw rightboundary OverlayBox withcolor red ; \stopMPcode \else\ifnum\realpageno=\MPp{Background:b:\CurrentBackground} \startMPcode draw topboundary OverlayBox withcolor red ; draw leftboundary OverlayBox withcolor red ; draw rightboundary OverlayBox withcolor red ; \stopMPcode \else\ifnum\realpageno=\MPp{Background:e:\CurrentBackground} \startMPcode draw bottomboundary OverlayBox withcolor red ; draw leftboundary OverlayBox withcolor red ; draw rightboundary OverlayBox withcolor red ; \stopMPcode \else \startMPcode draw leftboundary OverlayBox withcolor red ; draw rightboundary OverlayBox withcolor red ; \stopMPcode \fi\fi\fi}
\defineoverlay[DrawBackground][\DrawBackground]
\setupbackground[background=DrawBackground]
A much simpler solution using textbackgrounds: \startuseMPgraphic{splitframe} for i=1 upto nofmultipars : if one_piece_multi_par : draw multipars[i] ; elseif multilocs[i]=1 : draw topboundary multipars[i] ; draw leftboundary multipars[i] ; draw rightboundary multipars[i] ; elseif multilocs[i]=2 : draw leftboundary multipars[i] ; draw rightboundary multipars[i] ; elseif multilocs[i]=3 : draw leftboundary multipars[i] ; draw rightboundary multipars[i] ; draw bottomboundary multipars[i]; fi ; endfor ; \stopuseMPgraphic \definetextbackground [splitframe] [state=start, mp=splitframe, location=paragraph] \starttext \startsplitframe \input knuth \endgraf \stopsplitframe \blank[big] \startsplitframe \dorecurse{4}{\input knuth \endgraf} \stopsplitframe \blank[big] \startsplitframe \dorecurse{10}{\input knuth \endgraf} \stopsplitframe \stoptext Aditya