sillsdev / ptx2pdf

XeTeX based macro package for typesetting USFM formatted (Paratext output) scripture files
21 stars 7 forks source link

Prevent Orphan Words not working for me #869

Closed mnjames closed 11 months ago

mnjames commented 1 year ago

As stated in the title, when I select "Prevent Orphan Words" in the UI, I still get words alone on their own line.

Looking at texmodel.py, in lines 1202 and 1203, I don't understand why the replacement is adding an en quad (\u2000) rather than a non-breaking space (\u00A0). When I replace \u2000 with \u00A0 it looks like things work correctly.

But since no one else has complained about this I'm wondering if I'm possibly missing something.

mhosken commented 1 year ago

That setting doesn't block a single word wrap. But it says to TeX that it would be best not to wrap there. You can adjust the precise penalty of such a break, raising it or lowering it. See your tech ref manual for details.

mnjames commented 1 year ago

I'm assuming it has to be \badspacepenalty that we're talking about. Setting it from -9999 to 10000 doesn't result in any change. Setting it to -10000 gets rid of one of the bad orphans (in a short sample file), but not a 2nd. Setting it to -10000 and radically changing the "Between words" spacing fixes the 2nd one.

I don't want to generally let the spacing be that extreme, so I may need to solve at least some of the problems with stretching/shrinking things manually. But what are the dangers of setting \badspacepenalty-10000?


Note that the TeXpert Hacks UI doesn't allow you to se the \badspacepenalty as a negative (so I did it in *mods.tex).

I tried to use your super complicated regex in Changes, but it didn't work. Why? '(?<=\\[^ctm][^\\]+)(\s+[^ 0-9\\\n\u2000\u00A0]{1,6}) ([^ 0-9\\\n\u2000\u00A0]{1,8}\n(?:\\[pmqsc]|$))' > '\1\u00A0\2'

davidg-sil commented 1 year ago

negative \badspacepenalty ought to be encouraging TeX to break there. -10000 means 'if this place is considered as a break point, accept it'. E.g.: image

So, urm, I'm not at all sure what's going on. Does the final USFM view actually show \badspacepenatly at all the expected places??

markpenny commented 1 year ago

BTW - I have just updated the lower limit for \badspacepenalty. @davidg-sil or @mnjames - are there any other spin buttons (e.g. OptionalBreakPenalty) that need their defaults tweaked?

image

davidg-sil commented 1 year ago

-10000 means 'force a break here'. It should thus produce horrible breaks / layout. If that's what people want for testing, I suppose that's fine.....

On Fri, Jun 23, 2023 at 6:06 AM Mark Penny @.***> wrote:

BTW - I have just updated the lower limit for \badspacepenalty. @davidg-sil https://github.com/davidg-sil or @mnjames https://github.com/mnjames - are there any other spin buttons (e.g. OptionalBreakPenalty) that need their defaults tweaked?

[image: image] https://user-images.githubusercontent.com/12962708/248143319-b2640d4e-9199-464b-997e-3d5b9665c508.png

— Reply to this email directly, view it on GitHub https://github.com/sillsdev/ptx2pdf/issues/869#issuecomment-1603623906, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOA7H2H6FMYYEZ4IHOS6GQ3XMUB2JANCNFSM6AAAAAAYGHDDIA . You are receiving this because you were mentioned.Message ID: @.***>