The publisher requires that most of short words (shorter then 4 chars, and all the prepositions, etc.) should not be left last on the line but kept with the following word.


Following the last theorem, we
can see that ...


Following the last theorem, 
we can see that ...

Yes I can use sed to replace such spaces with ~ but that's not right a solutionas it will affect math.

P.S. We are using a standard extbook class. Thanks in advance.

  • You might also be interested in handling hyphenations. – Stephen Dec 17 '12 at 19:26
  • Good, I just thought that there might have been some rule regarding the minimal number of letters before/after a hyphenation, in which case Egreg's linked answer would have been helpful. Anyway, maybe somebody else looking at your question can be helped by Egreg's answer to the other question. – Stephen Dec 17 '12 at 19:48

I don't think a pure TeX solution is feasible (luatex might be possible).

If you can not accurately spot your math markup using sed/perl etc You could insert \shortwordspace rather than ~ directly and then define


so it does nothing in math mode.

| improve this answer | |
  • Thanks David, I thought there is something like \shortwordpenalty for controlling that. – saabeilin Dec 17 '12 at 15:28
  • (> luatex might be possible ) I hacked something (probably buggy) in LuaTeX :-) here – ShreevatsaR Jul 9 '17 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.