Par break/justification problem
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. Example: First part of the paragraph: second part is run in and then the text continues. Second example: This is still the first part of the pagrah: second part will now be put on the next line but the last line of the first part should be fully justified. What kind of hskip/penalty/whatever combo should I put between the first and last part for this to happen? -- Giuseppe "Oblomov" Bilotta
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.
Example:
First part of the paragraph: second part is run in and then the text continues.
Second example:
This is still the first part of the pagrah: second part will now be put on the next line but the last line of the first part should be fully justified.
What kind of hskip/penalty/whatever combo should I put between the first and last part for this to happen?
hm, taco should know ... my guess is something {\parfillskip ... \break} maybe with some looseness another option is (if you intervene manually) is to play with those etex penalties arrays Hans
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
participants (3)
-
Giuseppe Bilotta
-
Hans Hagen
-
Taco Hoekwater