# Expectations for Shrinking and Expanding

Hi,

I’m using PTXPrint 1.8.1. I have been trying to improve the default layout on some pages by working with the adjustments list to stretch or shrink paragraphs.

My question is – How does PTXPrint decide on whether to apply requested adjustments to the layout. My current experience is that I can request a longer (+1) or shorter (-1) paragraph, but whether or not PTXPrint (TeX) applies that request is trial / error.

I’m sure that the spacing adjustments parameters given will have a big impact on whether the +1 or -1 can actually be obeyed. But, in numerous cases I am trying to shrink a paragraph which has a short last line, has more than 10 lines of text, and appears to have room for adjustment, but the shrink request with -1 at the appropriate reference has no effect.

What other factors are involved in understanding how PTXPrint decides whether to apply an adjustment, or not?

Jeff

Hi Jeff, When I’m using the adjustments list, I pretty much never use -1. As you’ve seen, it often doesn’t “take”. I just plan my layout based on expanding paragraphs. If I glance through the PDF output and it looks like there are some “difficult” breaks, or an inconvenient number of pages, I often will make slight adjustments to the Base Font Size (on the Layout tab first), to give me a better starting point.

Thanks, Jeff.

It’s really helpful to hear your experience.

With some scripts and fonts, I think that expansion will end up more pleasing or acceptable than shrinking. And with others it will be the reverse. And obviously depends on the paragraph in question.

A question I don’t know the answer to – whether it is possible in TeX to indicate that I absolutely want one more line - and TeX can feel free to use all of the limits of the min / max in my spacing adjustment settings (but only as much as needed). I know that goes against the grain of limiting ‘badness’, but it would make it easier for someone to take some control and try various approaches to fitting on a specific page or spread.

Jeff

Hi Jeff,

I know that this is an area that can get very frustrating - with trial and error, and if we were able to make it more interactive/dynamic through the UI, it would make the experience much more pleasant.

Yes, I like the suggestion about being able to force an extra line, or reduce a line - but have no idea whether we can pull that off at the TeX macro level. I’ll let the TeXperts think about that one…

We have the Spacing Adjustments settings on the Fonts+Scipts tab, but they tend to make a lot of other places pretty ugly too.

I wonder if there could be a way to only apply these more radical adjustments to specific problem paragraphs only, rather than to the whole document. That would be like forcing the grow/shrink.

This would be a great addition to PTX Print. I’ve used the kerning adjustment in LO Writer for years: There it applies to selected text, not to entire paragraphs, which makes the tweaks a bit less noticeable, I think. There I define three Character Styles with “less” and “more” shrinking and one level of expanding, and experiment with problem paragraphs until it looks best. This would be harder to design in PTX Print, I’m sure, but it would be nice to be able to go more “radical” for specific paragraphs, or even verses.

Thanks!

One option for applying commands to selected paragraphs/verses only would be the trigger mechanism. E.g. if the normal inter-letter space were set to between 0.999 and 1.001, the relevant parameters could be tweaked at the start point and reset at the end-point.

This could get long.
First, how TeX breaks paragraphs is a whole chapter in the TeXbook. Basically there is a \tolerance (set to 9000 which is very generous. PlainTeX sets it to 200) that governs whether a particular way of breaking the paragraph is going to be considered. So if reducing the paragraph by a line makes the badness > 9000 it won’t reduce the paragraph however much you ask it. Likewise for increasing the paragraph. TeX’s natural paragraph length is chosen to minimise the badness. So reducing or increasing the paragraph will make it worse, but that’s balanced against a better page layout. A large tolerance isn’t bad given TeX minimises the badness for a paragraph. It just says we really don’t want over or underfull lines thank you.
In our experience, TeX rarely allows a paragraph to reduce. Have more shrinky spaces helps (the default min shrink for a space is 66% so 95% actually makes it less shrinky). Likewise the default max stretch is 150% so 140% makes it less stretchy. Adding intercharacter spacing is unlikely to make much difference to line breaking. It might but really all it does is soak up some extra stretch from the spaces making them less ugly. BTW if TeX breaks a really really bad line, it doesn’t matter how low you limit the max stretch, TeX will just stretch everything in proportion to fill the line overflowing any maxima.

This bit is mathematical: The 9000 tolerance needs to be divided by the number of lines to get an average. Let’s say there are 10 lines in a paragraph, so we get an average of 900 badness per line. TeX calculates badness as 100x(actual shrink or stretch / maximum shrink or stretch)^3. So that means it can allow a line to shrink or stretch on average up to 2 x the total for the line. Thus it might reduce spaces down to half their minimum or stretch them to twice their maximum. Obviously this is a worst case and TeX always chooses the best looking paragraph it can. So don’t worry that everything will look far worse than you specify. In practise, things look really good and by choosing which paragraphs to stretch wisely, one can fix problems in a way that is not obvious to the untrained eye.

Why does TeX not shrink paragraphs well? Because usually the max shrink of the spaces on a line are insufficient to pull a whole word up let alone 2 or 3. It depends if you are willing to let your min space be down at 40% of a space, which really isn’t much.
For scripts that don’t have word spaces then the key is to give plenty of places for TeX to break lines by inserting ZWSP characters liberally.

Now as to per paragraph changes. Yes we could change the values of the glue paragraph by paragraph, but I don’t know how we would provide a UI for that. Would you want to do all that work? Perhaps a more helpful way is to create a tool that measures all the possible paragraph shrinks and stretches and lets you know the range of values that will actually happen. We have some thoughts on improving the whole UI around adjustment lists anyway.

BTW here’s a tip. You can always increase the line count for a heading style since they aren’t justified, so TeX will happily make those lines shorter and shorter to have more of them in a paragraph. But they are also very noticeable on the page.