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.

In the following small example I get unexpected but different results in XeLaTeX and LuaLaTeX:

\documentclass{article}
\usepackage{fontspec}
\setlength\parindent{0pt}
\newcommand*\x{\rule{1cm}{1cm}}

\begin{document}

\x\,\x \par
\x~\x  \par
\x \x  \par  % U202F ('NARROW NO-BREAK SPACE') between
\x \x  \par  % U2009 ('THIN SPACE') between

\end{document}
  1. XeLaTeX: The second, third, and fourth squares have the same wide distance.
  2. LuaLaTeX: The third and fourth squares have no distance.

I would expect in case three and four the same small distance as in case one with both engines. Are these bugs, or can I correct it by myself?

share|improve this question
2  
It depends on the used font, specifically, if the font has those glyphs. You use fontspec but do not specify any font. If you do that, I'd wager you'll see the same outcome. –  morbusg Dec 22 '13 at 10:28
add comment

1 Answer

up vote 17 down vote accepted

If you look at the log file, you'll find

Missing character: There is no <E2><80><AF> in font [lmroman10-regular]:mapping=tex-text!
Missing character: There is no <E2><80><89> in font [lmroman10-regular]:mapping=tex-text!

(I used an ‘ASCII representation’, so the UTF-8 bytes are shown). The UTF-8 sequences correspond to

<E2><80><AF> → U+202F NARROW NO-BREAK SPACE
<E2><80><89> → U+2009 THIN SPACE

If the font has no glyph in those slots, the consequence is either printing a rectangle (old versions of XeTeX), some space or nothing at all.

You can obviate with newunicodechar:

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}

\setlength\parindent{0pt}
\newcommand*\x{\rule{1cm}{1cm}}
\newunicodechar{^^^^202f}{~}
\newunicodechar{^^^^2009}{\,}

\begin{document}

\x\,\x \par
\x~\x  \par
\x \x  \par  % U202F ('NARROW NO-BREAK SPACE') between
\x \x  \par  % U2009 ('THIN SPACE') between

\end{document}

Instead of a ^^^^ sequence you can insert the explicit character; but in the case of space characters this is awkward as editors don't distinguish between them; but

\newunicodechar{ }{~}   % U+202F NARROW NO-BREAK SPACE
\newunicodechar{ }{\,}  % U+2009 THIN SPACE

would work as well.

enter image description here

share|improve this answer
add comment

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.