# Rendering a unicode en-dash in XeLaTeX [closed]

If I am understanding things correctly, using XeLaTeX, all of these lines should be output with proper em- and en- dashes respectively:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Gentium Plus}

\begin{document}

Hello---world!

Hello—world!

Hello--world!

Hello–world!

\end{document}


However, no matter what font I choose I receive an error with the unicode en-dash (the em-dash works fine as does the -- sequence to generate the en-dash):

 ./dash-testing.te.tex:13: Undefined control sequence.
l.13 Hello\UTF
{2013}world! \\


But I can see, using InDesign glyph viewer or other, that character 2013 does indeed exist. And direct input of other characters, like “ and others is working.

How can I get the unicode en-dash to work?

Updated: this is the output I get if I continue the compilation (just to demonstrate that the proper font is indeed being used).

## closed as off-topic by egreg, user13907, barbara beeton, Alan Munn, user31729 Feb 14 '16 at 21:28

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Works for me if I substitute \setmainfont{GentiumPlus-R.ttf}. (Though my system doesn't find the font at all if I use your \setmainfont{Gentium Plus}.) – dedded Feb 14 '16 at 19:04
• That doesn't change anything for me...with either statement, Gentium Plus is being found. And I've tried with multiple other fonts that I know have the en-dash and same problem! – Chris Feb 14 '16 at 19:10
• I'm voting to close this question as off-topic because the issue was nonexistent – egreg Feb 14 '16 at 20:18

I copied your complete from my browser into a new text file and compiled it with xelatex and worked without any problems. I see absolutely no reason why your code should not work

• Try to make a complete new file in a new directory after having closed any console windows or probably having restarted your computer.

This helps sometimes when I have similiar problems...

• If this does not help, try updating your TeX-distribution

Gentium is also available as a Type 1 font, e.g. in TEXMF/fonts/type1/public/gentium-tug/ I suppose that you also have this font installed and XeLaTeX uses the first one which is found. However, you can force XeLaTeX to use the TrueType version with:

\setmainfont[
Extension=.ttf,
UprightFont=*-R,
ItalicFont=*-I]{GentiumPlus}


This is XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015) (preloaded format=xelatex 2016.2.13) 14 FEB 2016 20:43

 fontspec-xetex.sty    2016/02/01 v2.5a Font selection for XeLaTeX and LuaLaTeX

• No. I installed Gentium specifically for this purpose (and as noted above, specifying the .ttf as an earlier person proposed or the way you have shown) doesn't change the error message. I've also tried with Arial Unicode MS, Hoefler Text and a variety of fonts, some also installed just for troubleshooting. – Chris Feb 14 '16 at 19:55
• what TeX distribution do you have. Important is also the version of fontspec. Se my edit – user2478 Feb 14 '16 at 20:01
• xelatex --version results in: XeTeX 3.14159265-2.6-0.99992 (TeX Live 2015) and tlmgr gives this info for fontspec: cat-version: 2.5a cat-date: 2016-02-01 14:28:29 +0100 – Chris Feb 14 '16 at 20:03
• Then you have already the Gentium fonts installed in TEXMF/fonts/truetype/public/gentium-tug/ and you should use that ones. – user2478 Feb 14 '16 at 20:18

I'm so sorry to have wasted your time. This turns out to be a TexShop "problem." I didn't realize, until I was editing the test files in Vim, that TexShop wasn't showing me the exact source. Until I used Vim I couldn't see that where I saw an – the actual source literally had UTF{2013}.

This is a preference for supporting pTeX, fixed by turning that preference off as in this StackExchange answer: TexShop diacritic encoding