[XeTeX] Unexplained behavior

Bogdan Butnaru bogdanb+xetex at gmail.com
Sat Jan 15 22:44:42 CET 2011


On Sat, Jan 15, 2011 at 20:01, Paul Isambert <zappathustra at free.fr> wrote:
> \thinspace is a \kern, which adapts to the mode it is in. What you want is
> an horizontal space, but what happens is a vertical one, because the \kern
> occurs in vertical mode (TeX is between paragraph at the time when \sepdash
> occur, and between paragraph you're basically in vertical mode). You have to
> begin the \sepdash macro with \leavevmode, so TeX switches to horinzontal
> mode and typesets a horizontal space.

Oh, thanks for the explanation. It fixed that problem, but then I
noticed another one. I went through a few variations and I can’t get a
version that does what I want no matter what. Here’s what I’ve tried:

I want a typed em-dash to
1) in running text, be typeset with a small space around it
1a) ideally the space should be thin even if the source contains
spaces around it
1b) ideally the space should be glue rather than a kern, so it can
stretch a bit in stretched lines
2) line breaks should be forbidden before a dash, but should be allowed after
3) if a dash begins/ends a line, the space before/after it should disappear
4) and there should be no weird behavior otherwise...

Below my signature there’s an example of the things I tried; they all
fail in one of the cases above:

\EmDashA has weird behavior at the end of a page (page 2 in the result)
\EmDashB has weird behavior at the end of a line (page 10 in the
result; only happens for justified text)
\EmDashC avoids the above, but the thin space does not disappear at
the start of a line (none of the three does this, though the ones with
glue at the right work on right-aligned paragraphs for some reason); .

—Bogdan Butnaru

\documentclass{memoir}

\usepackage{xunicode}
\usepackage{fontspec}

\setstocksize{5cm}{5cm}
\settrimmedsize{\stockheight}{\stockwidth}{*}
\settypeblocksize{\topskip  + 3\baselineskip}{4cm}{*}
\setlrmargins{*}{*}{1}
\setulmargins{*}{*}{1}
\checkandfixthelayout[fixed]
\fixdvipslayout

\def\dashspace{\hskip .1em}
\def\hzthspace{\leavevmode\thinspace}

\def\EmDashA{\nobreak\dashspace—\dashspace\ignorespaces}

\def\EmDashB{\unskip\hzthspace—\allowbreak\hzthspace\ignorespaces}

\def\EmDashC{\unskip\hzthspace—\dashspace\ignorespaces}

\def\EmDash{—}

\catcode `\— = \active

\newcommand{\test}[1]{
\let — = #1
\cleartoevenpage
This paragraph should fit on the page:

Cp cdp cdp cdp cdp—cdp cdp cdp.

—Filler

Filler. \par Filler.

\clearpage
Line below should not—

Be spaced from the one above.
\clearpage
Should be aligned:

\EmDash line 1

—line 2

\EmDash line 3

\clearpage
\begin{flushright}
line 1\EmDash

line 2—

line 3\EmDash
\end{flushright}
}

\begin{document}
\test{\EmDashA}
\test{\EmDashB}
\test{\EmDashC}
\end{document}



More information about the XeTeX mailing list