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.

I’ve just installed TeX Live 2012. As mentioned elsewhere on this site, the release history explains that “the parameter \XeTeXdashbreakstate is set to 1 by default, for both xetex and xelatex. This allows line breaks after em-dashes and en-dashes, which has always been the behavior of plain TEX, LATEX, LuaTEX, etc.”

I rarely use xetex; I’ve worked almost exclusively with luatex since the release of TeX Live 2011. The only frequent problem I had was that I did not get line breaks after em-dashes, and now in 2012 I’m still not getting them, unless I refrain from using the Unicode character — which certainly seems against the spirit of luatex.

Consider this example, where the same paragraph is typed 3 times, with the em-dashes entered differently in each:

\documentclass[11pt,a5paper]{book}
\usepackage{fontspec,microtype}
\setmainfont[Ligatures=TeX,RawFeature={protrusion=default}]{TeX Gyre Termes}
\pdfprotrudechars=2
\usepackage[showframe]{geometry}

% Will Robertson’s macro from http://tex.stackexchange.com/questions/34608/
\DeclareRobustCommand\dash{%
 \unskip\nobreak\thinspace\textemdash\allowbreak\thinspace\ignorespaces}

\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight
\pdfinfo{/Title (Jeeves Takes Charge) /Author (P.G. Wodehouse)}
\begin{document}
% using ---
Now, touching this business of old Jeeves---my man, you know---how do we
stand? Lots of people think I’m much too dependent on him. My Aunt
Agatha, in fact, has even gone so far as to call him my keeper. Well,
what I say is: Why not? The man’s a genius. From the collar upward he
stands alone.

% typing the em-dash (easy in utf-8 locale with compose key)
Now, touching this business of old Jeeves—my man, you know—how do we
stand? Lots of people think I’m much too dependent on him. My Aunt
Agatha, in fact, has even gone so far as to call him my keeper. Well,
what I say is: Why not? The man’s a genius. From the collar upward he
stands alone.

% using Will Robertson’s macro
Now, touching this business of old Jeeves\dash my man, you know\dash how do we
stand? Lots of people think I’m much too dependent on him. My Aunt
Agatha, in fact, has even gone so far as to call him my keeper. Well,
what I say is: Why not? The man’s a genius. From the collar upward he
stands alone.
\end{document}

The result looks like this:

result of compiling the example above with lualatex

I’ve experimented with various free and commercial fonts, always with the same result.

Is there some luatex equivalent to \XeTeXdashbreakstate which I could set?

share|improve this question
3  
That is the expected behavior, when you use --- it is treated as a ligature of hyphens and thus have line breaks like hyphen, but not with the Unicode character. In XeTeX --- was being mapped to the Unicode character, so there was no breaks in both cases. –  Khaled Hosny Jul 10 '12 at 7:54
    
@KhaledHosny Expected by the developers, I suppose you mean, because it’s surprising to users. I always thought of --- as a mere convenience, as a way to get an em-dash even if stuck in an ASCII environment. I didn’t realize that --- was a sort of super-em-dash, an em-dash plus other nice features which don’t belong to em-dashes as such. –  Thérèse Jul 10 '12 at 11:09
    
I’m not saying it is a desired behavior, I’m just saying it is not a bug, may be a mis feature, lack of feature but not a bug. –  Khaled Hosny Jul 10 '12 at 16:27
    
The line breaking with --- is merely a side effect of the way it is implemented in TeX; a ligature of hyphens, try entering it directly in legacy TeX (\char124 with Computer Modern), no line breaks. –  Khaled Hosny Jul 10 '12 at 16:34
    
@KhaledHosny: Thank you for these explanations, and thank you also for the many good things you make available on your GitHub page. –  Thérèse Jul 10 '12 at 19:48

3 Answers 3

up vote 5 down vote accepted

I am not sure what the correct answer is. The UTF-8 emdash is considered part of the word. You see this (when you leave out microtype) in the log file:

Overfull \hbox (19.42857pt too wide) in paragraph at lines 28--33
[][]\EU2/TeXGyreTermes(0)/m/n/10.95 Now, touch-ing this busi-ness of old Jeeves
—my man, you know—how

I am not sure if TeX is able at all to decompose the words when it encounters a character such as emdash. So my answer would be "it's not possible".

What you can do, it's slightly a hack:

\catcode`\—=13
\protected\def—{\unskip\nobreak\thinspace\textemdash\allowbreak\thinspace\ignorespaces}

This makes the emdash active and inserts a "breakable" emdash.

Another possibility would be to filter the emdash in a LuaTeX callback and replace it with something breakable.

share|improve this answer
    
Wouldn't it be better \protected\def—{\dash} (where \dash is defined as in the question)? Or just adding \protected in front of \def, of course. –  egreg Jul 10 '12 at 8:16
    
@egreg probably. I have no idea what the \protected does, but I trust you :) –  topskip Jul 10 '12 at 8:25
3  
It makes (Lua)TeX write the character instead of its expansion in auxiliary files, for instance. –  egreg Jul 10 '12 at 8:26
    
@Patrick it behaves like \unexpanded in ConTeXt. –  phg Jul 10 '12 at 9:06
1  
One drawback of this approach is that you always get a good break-point before the em-dash; when an em-dash is used to mark the end of a sub-sentence---as this example illustrates---the break-point should be after the em-dash. So, the solution will be to make . an active character and use different definitions for odd and even em-dashes in each sentence (just kidding :-)). –  Aditya Jul 10 '12 at 12:53

Imho from the unicode view there shouldn't be automatically a break point after such dashes. With unicode you should probably insert a Zero Width Space (U+200B). It doesn't work out-of-the-box with lualatex, you need something like luaunicodespace (https://github.com/khaledhosny/luaunicodespace):

\documentclass[]{scrbook}
\usepackage{fontspec}
\directlua {
require('luaunicodespace')
luatexbase.add_to_callback("pre_linebreak_filter", luaunicodespace.handler, "luaotfload", 1)
luatexbase.add_to_callback("hpack_filter",         luaunicodespace.handler, "luaotfload", 1)
}
\textwidth=3cm
\begin{document}
Text—Text—Text—Text—Text—Text—Text—Text

Text—^^^^200bText—^^^^200bText—^^^^200bText—^^^^200bText—^^^^200bText—^^^^200bText—^^^^200bText

\end{document}
share|improve this answer
    
Thank you, Ulrike. I didn’t know about the zero width space, and it’s fairly easy to insert in Emacs. –  Thérèse Jul 10 '12 at 19:45

See the last paragraph here: http://www.heise.de/newsticker/meldung/TeX-Live-Jahrgang-2012-1634828.html, you have to set the parameter \XeTeXdashbreakstate to null explicitly starting TeX 2012.

share|improve this answer
    
I’m using luatex, not xetex, and I want line breaks after em-dashes; the result shown in the second paragraph of the image is what I object to. –  Thérèse Jul 10 '12 at 6:55

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.