Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

Wrong:

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

Right:

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.

share|improve this question
    
You might also be interested in handling hyphenations. –  Stephen Dec 17 '12 at 19:26
    
Thanks Stephen, hyphenation is already OK. –  saabeilin Dec 17 '12 at 19:43
    
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

1 Answer 1

up vote 5 down vote accepted

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

 \protected\def\shortwordspace{\ifmmode\else~\fi}

so it does nothing in math mode.

share|improve this answer
    
Thanks David, I thought there is something like \shortwordpenalty for controlling that. –  saabeilin Dec 17 '12 at 15:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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