7

Using XeLaTeX the following document produces the correct result if \setmainfont{Arial} is never called (the quotation marks are proper left- and right-quotation marks). Once I try to set a font (even if it has the proper glyphs!) the output appears improperly as ``Quote me!''.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Arial}
\begin{document}
``Quote me!''
\end{document}
lockstep
  • 250,273
aardvarkk
  • 361
  • 5
    Set the Ligatures=TeX feature for the font: \setmainfont[Ligatures=TeX]{Arial} – Gonzalo Medina Feb 06 '14 at 18:34
  • Interesting: this solves the problem in Windows TeXstudio where I created the example, but on my Ubuntu machine I get the error: ! Package xkeyval Error: 'TeX' undefined in families 'Ligatures'. – aardvarkk Feb 06 '14 at 18:38
  • 1
    Do you have an up-to-date TeX system (e.g. TeX Live) or are you using the one that comes with Ubuntu? – Joseph Wright Feb 06 '14 at 18:44
  • @JosephWright Yes, I installed texlive. Should be up to date. – aardvarkk Feb 06 '14 at 20:47
  • @aardvarkk No, I mean did you install TeX Live from TUG ('stand alone') or using the Ubuntu package system? – Joseph Wright Feb 06 '14 at 20:48
  • @JosephWright I installed from the package system. After taking a gander through the fontspec documentation, I found that Ligatures=TeX seems to be associated with LuaTeX? Instead, I switched to \fontspec[Mapping=tex-text]{Arial} as recommended by the documentation and it magically works! – aardvarkk Feb 06 '14 at 20:52
  • @GonzaloMedina I'd be happy to give you credit if you want to post an answer! I ended up having to go with Mapping=tex-text, but same idea. – aardvarkk Feb 06 '14 at 21:17
  • @aardvarkk Thank you. I've added an answer. – Gonzalo Medina Feb 07 '14 at 02:17
  • As an aside, in a future version of fontspec I plan to make Ligatures=TeX the default except when using \setmonofont. (Configurable, of course.) – Will Robertson Feb 07 '14 at 04:59

4 Answers4

10

Set the Ligatures=TeX feature for the font:

\setmainfont[Ligatures=TeX]{Arial}

with old versions of fontspec you should use

\setmainfont[Mapping=tex-text]{Arial}

instead. The later with also work with newer versions, but the former is recommended for better compatibility with LuaTeX documents.

A sample code:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Arial}
\begin{document}
``Quote me!''
\end{document}

produces

enter image description here

Gonzalo Medina
  • 505,128
3

Try using \setmainfont[Mapping=tex-text]{Arial}, which should work on older versions as well.

1

As of October 2021, but the fontspec package has done like this for a long time, the given example works as expected.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Arial}
\begin{document}
``Quote me!''
\end{document}

enter image description here

The \setmainfont and \setsansfont declarations inherit \defaultfontfeatures{Ligatures=TeX} unless countermanded before issuing the commands.

egreg
  • 1,121,712
0

The above didn't work for me, but the following bit did the trick:

\defaultfontfeatures{Ligatures=TeX}