[XeTeX] avoiding line break after dash

Mike Maxwell maxwell at umiacs.umd.edu
Mon Dec 8 00:34:53 CET 2014


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?
-- 
	Mike Maxwell
	maxwell at umiacs.umd.edu
	"My definition of an interesting universe is
	one that has the capacity to study itself."
         --Stephen Eastmond

-----------MWE---------------
\documentclass[11pt,letterpaper]{report}
\usepackage{fontspec}
\setmainfont{Charis SIL}
\usepackage{hyphenat}
%\lccode`\-=0
%\exhyphenpenalty=10000
\begin{document}

sentence-{}final particle
filler filler filler filler filler filler filler filler fil
-abcd
\textbf{-{}eve}. It may also be written as foo-{}fa in
informal writing, as that is how it is pronounced.
blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa
blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa
blaa blaa blaa blaa blaa blaa blaa blaa blaa blaa.
\end{document}


More information about the XeTeX mailing list