4

This is a similar question to How to get straight quotation marks?, but in my case, I want literal ' and " marks to stay that way, as I use Unicode curly quotes when I want curly quotes. Is there a simple header option to make this happen? I’m using LuaTeX and fontspec.

(Background: I’m using Emacs to export existing Org documents—written, not by me, with straight quotes only—as PDFs. When I did this with the default PDFLaTeX setup, Unicode special characters (not quotes, but other special characters) wouldn’t render. So I changed the compiler to LuaTeX and found a way to add \usepackage{fontspec} and \setmainfont{Linux Libertine O} to my documents’ header options, and now Unicode special characters work, but every straight quote is rendered as a closing curly quote. This is simply too much for my autistic sensibilities!)

1
  • 1
    Welcome to TeX.SE. – Mico Feb 27 at 6:28
7

The "smart" closing single and double quotes are generated if fontspec's option Ligatures=TeX option is active, which is the case by default. To switch it off, just specify the option Ligatures=TeXOff -- or, equivalently, [RawFeature=-tlig] -- when running \setmainfont or \setsansfont. Observe that this approach works with all fonts, not just Linux Libertine O.

Note that setting Ligatures=TeXOff will also prevent -- and --- being converted automatically to en-dashes and em-dashes, respectively. Please advise if this might cause a problem for your document. (Given that your document already Unicode curly quotes, I tend to think that it might also use Unicode en- and em-dash characters; however, I may be wrong.)

enter image description here

\documentclass{article}
\usepackage{fontspec}
\newcommand\dummysentence{A sentence with straight 'single' and  "double" quotes.}

\begin{document}
\setmainfont{Linux Libertine O}[Ligatures=TeXOff] % or [RawFeature=-tlig]
\dummysentence

\setmainfont{EB Garamond}[Ligatures=TeXOff,
                          Scale=MatchLowercase % same x-height as preceding font
                         ]
\dummysentence 

\setsansfont{Helvetica Neue}[Ligatures=TeXOff,Scale=MatchLowercase]
\textsf{\dummysentence}

\setsansfont{Myriad Pro Cond}[Ligatures=TeXOff,Scale=MatchLowercase]
\textsf{\dummysentence}
\end{document}

`

3
  • Do you have a reference for this TeXOff syntax? It's not in the fontspec manual as far as I can tell and I get Key 'fontspec-opentype/Ligatures' accepts only a fixed set of choices – Clément Mar 7 at 17:08
  • @Clément - I can only point to section 3.1.8, "Ligatures", of the fontspec manual, along with associated table 11. Version 2.7i of the package, dated 2020/02/21, is used with MacTeX2020 and MacTeX2021. Which version of the package is on your system? – Mico Mar 7 at 17:20
  • 1
    Version 2.7h of 2020/02/03; thanks, with the pointer in the manual I found the reference. Using the RawFeature form works. – Clément Mar 7 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.