[XeTeX] avoiding line break after dash

David Carlisle d.p.carlisle at gmail.com
Mon Dec 8 01:14:16 CET 2014


On 7 December 2014 at 23:34, Mike Maxwell <maxwell at umiacs.umd.edu> wrote:
> I have a document that has word-initial dashes (they indicate that the
> "word" is a suffix).  When the paragraph they're in is just right, xelatex
> insists on inserting an unwanted line break immediately after the dash.
> I've tried lots of things to prevent this: setting the lccode for dash to
> zero, replacing the ASCII dash with an en-dash (U+2013), using or not using
> a {} immediately after the dash, putting an \mbox around the dash and word
> (works, but difficult to use in the particular context I'm working in), and
> several other things that I can't remember right now.
>
> Another thing I've tried is to set the \exhyphenpenalty to 10000.  This
> works if I do it in the preamble, but I don't really want it to have scope
> over the entire document.  But if I put that command inside a {...} together
> with the dash+word, it has no effect.
>
> Using a Unicode non-breaking hyphen (U+2011) appears to prevent the line
> break when I try this with a different font.  Unfortunately, the font I need
> to use doesn't have a glyph for this code point, so I get a box in the PDF.
> (Is there a way to use the ASCII dash glyph for this code point, while
> preserving the non-breaking status of the U+2011 code point?  Short of
> hacking the font.)
>
> My MWE is after my sig line; the unwanted line break appears between the
> dash and the "abcd".  This behavior seems to be exquisitely sensitive to
> things around it, including the remainder of the paragraph, and the presence
> of other dashes within the paragraph; hence the text may seem longer than it
> needs to be, but I couldn't get the same bad result if I shortened it much.
>
> Suggestions?
> --


If adding markup rather than a general setting is acceptable you can use

\mbox{-}abcd

David


More information about the XeTeX mailing list