[XeTeX] Unexplained behavior

Paul Isambert zappathustra at free.fr
Sun Jan 16 12:00:06 CET 2011


Le 15/01/2011 22:44, Bogdan Butnaru a écrit :
> 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...

1a) You unskip, very well.
1b) Allright, but an \hskip without plus/minus component doesn't stretch 
or shrink. (I've seen such a glue in your code.)
2) and 3) seems contradictory; if linebreak can't happen before a dash, 
how can it starts a line? You mean it starts a paragraph?
As for line ends, don't worry, space removal is ensured.

Your code wasn't minimal enough for me to try to make sense of it. I'll 
also try to honor point 5 in your next mail, but that is a hack; 
interchartoks would be better. Anyway here's a solution (untested):


\def\thedash{—}
\newskip\dashskip
\dashskip=.1em plus .1em % Or whatever else.

\def\mydash{%
   \unless\ifvmode
     \unskip
     \nobreak
     \hskip\dashskip
   \fi
   \thedash
   \checkpunctuation
}

\makeatletter
\def\checkpunctuation{%
   
\@ifnextchar,{}{\@ifnextchar.{}{\@ifnextchar:{}{\@ifnextchar;{}{\hskip\dashskip}}}}%
% You should actually call with all the necessary characters.
}
\makeatother


More information about the XeTeX mailing list