Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

parshape and raggedright

338 views
Skip to first unread message

Will Robertson

unread,
Jun 23, 2008, 9:16:24 AM6/23/08
to
Hello,

Okay, I know that a true \parshape doesn't make sense with
\raggedright. Nonetheless, I've got a problem in which \raggedright
gives very poor results in a square-shaped paragraph when too many
lines are specified in the parshape (the first line's linebreak is only
a couple of words into the paragraph). See minimal example below.

Is there any possible workaround here? I'm thinking at the moment of
setting the paragraph in a non-ragged paragraph and counting the lines
to adjust my parshape linecount, but that's tedious to say the least.

Many thanks,
Will

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\raggedright
\newlength\tmp\tmp=241.84842pt
\def\oneline{ 0pt \tmp}
\def\fivelines{\oneline\oneline\oneline\oneline\oneline}
\parshape 10 \fivelines\fivelines
\lipsum[66]
\bigskip
\parshape 7 \fivelines\oneline\oneline
\lipsum[66]
\end{document}

Enrico Gregorio

unread,
Jun 23, 2008, 9:50:52 AM6/23/08
to
Will Robertson <wsp...@gmail.com> wrote:

Maybe using \RaggedRight from ragged2e.sty? It's adjustable, IIRC.

Ciao
Enrico

Will Robertson

unread,
Jun 23, 2008, 11:02:28 PM6/23/08
to
On 2008-06-23 23:20:52 +0930, Enrico Gregorio <greg...@math.unipd.it> said:

> Maybe using \RaggedRight from ragged2e.sty?

Well, hey, it works! I just kinda assumed \raggedright would be the
simpler case, but the world of TeX's paragraph shapes often surprises
me. \RaggedRight is the winner, and should really be the default
anyway, I suppose :)

Will

Enrico Gregorio

unread,
Jun 24, 2008, 4:10:52 AM6/24/08
to
Will Robertson <wsp...@gmail.com> wrote:

Perhaps somebody might be able to understand precisely why the first
line in your example comes out with only one word. The main difference
between \raggedright and \RaggedRight is that the former sets \rightskip
to "0pt plus 1fil", while the latter sets it to "0pt plus 20pt".

The relevant parameter for \raggedright is the skip register
\@flushglue, which however is used also in many other places and notably
to restore the normal value of \parfillskip. Therefore it's not very
recommended to change its value.

OTOH, \RaggedRight uses its own registers and \RaggedRightRightskip is
adjustable at will.

Ciao
Enrico

Will Robertson

unread,
Jun 24, 2008, 5:29:52 AM6/24/08
to
On 2008-06-24 17:40:52 +0930, Enrico Gregorio <greg...@math.unipd.it> said:
>
> Perhaps somebody might be able to understand precisely why the first
> line in your example comes out with only one word.

TeX by Topic claims that "If there are fewer than $n$ lines [in a
\parshape specification] the remaining specifications are ignored" but I
guess it's lying :)

Must be some odd effect due to the paragraph optimisation but it's
certainly not intuitive with the coarse level of understanding I have
about the whole process.

Thanks for your suggestion, regardless of the reasons why it does what
it does (I knew of the existence of ragged2e, I just hadn't thought to
try it yet). I'm glad to have it working!

Cheers,
Will

Enrico Gregorio

unread,
Jun 24, 2008, 5:55:34 AM6/24/08
to
Will Robertson <wsp...@gmail.com> wrote:

> On 2008-06-24 17:40:52 +0930, Enrico Gregorio <greg...@math.unipd.it> said:
> >
> > Perhaps somebody might be able to understand precisely why the first
> > line in your example comes out with only one word.
>
> TeX by Topic claims that "If there are fewer than $n$ lines [in a
> \parshape specification] the remaining specifications are ignored" but I
> guess it's lying :)

I don't think so. :)

> Must be some odd effect due to the paragraph optimisation but it's
> certainly not intuitive with the coarse level of understanding I have
> about the whole process.

TeX splits the paragraph into lines minimizing demerits with a quite
complex algorithm. I guess that the presence of more line specifications
in the first case (a ten line \parshape) forces TeX to compute
demerits differently.

If you try with a 5 line specification, you get exactly the same
result as with the 7 line. Or even with a one line, since TeX uses
the last line shape when the paragraph has more lines than specified
in \parshape.

OTOH, if you set the \hsize to 241.84842pt and use no \parshape, you
get a different 7 line paragraph. Amazing.

Ciao
Enrico

Donald Arseneau

unread,
Jun 24, 2008, 8:36:30 PM6/24/08
to

Donald Arseneau

unread,
Jun 24, 2008, 8:45:49 PM6/24/08
to
On Jun 23, 6:16 am, Will Robertson <wsp...@gmail.com> wrote:
> Okay, I know that a true \parshape doesn't make sense with
> \raggedright.

Sure it does, if you just use it to set indents (like LaTeX's lists).

> Nonetheless, I've got a problem in which \raggedright
> gives very poor results in a square-shaped paragraph when too many
> lines are specified in the parshape

Looks like a likely TeX bug to me. You should report it.

That's not to say it *is* a bug, or something that would be accepted
as a bug.

If you think about LaTeX's (poor) \raggedright implementation, every
possible combination of unstretched lines give the same total
demerits:
zero (plus those for \linepenalty). The reason you generally get the
short line at the end is because of the way TeX chooses the "last"
path among equals. I don't know that that behavior is gauranteed,
or even mentioned in The TeXbook. But it looks like \parshape is
screwing with it.

Donald Arseneau
as...@triumf.ca

Will Robertson

unread,
Jun 24, 2008, 10:39:13 PM6/24/08
to
On 2008-06-25 10:15:49 +0930, Donald Arseneau <as...@triumf.ca> said:

> On Jun 23, 6:16 am, Will Robertson <wsp...@gmail.com> wrote:
>> Okay, I know that a true \parshape doesn't make sense with
>> \raggedright.
>
> Sure it does, if you just use it to set indents (like LaTeX's lists).

True true. I was thinking of heart-shapes or something like that :)

> Looks like a likely TeX bug to me. You should report it.
>
> That's not to say it *is* a bug, or something that would be accepted
> as a bug.

Thanks, will do.

> If you think about LaTeX's (poor) \raggedright implementation, every
> possible combination of unstretched lines give the same total
> demerits:
> zero (plus those for \linepenalty). The reason you generally get the
> short line at the end is because of the way TeX chooses the "last"
> path among equals. I don't know that that behavior is gauranteed,
> or even mentioned in The TeXbook. But it looks like \parshape is
> screwing with it.

Yes, that makes sense.
Well, I guess we'll see in seven years or so if Knuth ever looks at it :)

Many thanks,
Will

0 new messages