Hans Hagen wrote:
Giuseppe Bilotta wrote:
I have a paragraph that is formed by two parts: these are
normally run together, except when the last line of the
first part ends at less than a certain amount max_amount
from the right margin. In this case, there should a
'seamless line break', i.e. a line break with the text still
fully justified to the right margin.
One way or another, you have to do trial typesetting because
the length of the last line is not known until the other lines
in first part have been typeset as well. You can do that with
a multi-pass approach using \pdfsavepos (but be prepared
for a potentially large number of required passes), but I
guess a local \setbox will be good enough, even if it is not
bulletproof under all conditions:
\newif\ifwidefirstpart % a switch for signalling
\def\starttwopart#1\secondpart#2\stoptwopart%
{\global\widefirstpartfalse
% The \ifdim test is the important part
\setbox0\vbox{#1$$\ifdim\predisplaysize>.8\hsize
\global\widefirstparttrue \fi$$}%
#1\ifwidefirstpart\unskip\break\fi #2\par }
% test
\starttext
\dorecurse{10}%
{\starttwopart
This is the\dorecurse{\recurselevel}{ filled} first part
\secondpart
This is the second part.
\stoptwopart }
\stoptext
Cheers, Taco
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context