XeLaTeX solution
The fontspec
package doesn't enable ligatures by default. To turn them on you can use:
\defaultfontfeatures{Ligatures=TeX}
Or add it when you load the font:
\setmainfont[Ligatures=TeX]{Helvetica}
LuaLaTeX
However, as discussed here How to enable ligatures for emdash/endash in LuaTeX ? (and noted in the comments by Ulrike Fischer) with LuaLaTeX it's probably not the best idea to use this method with LuaLatTeX (even though it works fine with XeLaTeX).
This means that converting existing documents to LuaLaTeX may give rise to problems. For new documents, it will mean adapting your regular methods to methods that are useable with LuaLaTeX.
Equivalents of the TeX ligatures
The standard TeX ligatures are:
`` '' -- --- !` ?` << >>
These combinations get turned into:
“ ” – — ¡ ¿ « »
Adapting to not using ligatures in either XeLaTeX or LuaLaTeX
The simplest solution is to simply type the actual characters in your source code. This is a simple solution for the en-dash, em-dash, ¡ and ¿, but is somewhat annoying for the quotation marks since most of us are not used to typing “ and ” in our source code. There are two possible solutions to this problem.
An editor based solution
With a good editor, it's easy to bind e.g. the " key to automatically insert “ ” for you as you type.
A LaTeX based solution
Alternatively, you can use the csquotes
package, which allows for very sophisticated quoting mechanisms. This may be overkill for many users, however. csquotes
allows you to define an active quote character so that it will automatically insert the correct quote characters. Alternatively, you can use explicit markup with the \enquote
command. (The csquotes
package has many other sophisticated capabilities; this is just a basic example.)
If you are using multiple languages with different quoting conventions, this can be quite useful. Here's a simple example:
\documentclass{article}
\usepackage{fontspec}
%\usepackage[french,english]{babel} % if using lualatex
\usepackage{polyglossia} % if using xelatex
\setmainlanguage{english} % if using xelatex & polyglossia
\setotherlanguage{french} % if using xelatex & polyglossia
\usepackage[autostyle=true,english=american,french=guillemets]{csquotes}
\MakeOuterQuote{"}
\begin{document}
"This is \enquote{some} text".
\enquote{This is \enquote{some} text}.
\begin{otherlanguage}{french}
"Une exemple en français."
\enquote{Une exemple en français.}
\end{otherlanguage}
\end{document}
This is made somewhat more complicated with LuaLaTeX, because depending on the language you are using, babel
is not fully supported by LuaLaTeX, and polyglossia
, which is used with XeLaTeX cannot be used with LuaLaTeX. See the following question for some discussion.
What is the implication of the warning in the fontspec manual with respect to babel and LuaTeX?
Best Answer
This is a known problem. As Joseph Wright wrote on the miktex mailing list: