From bc1557528fd180341d342f62f08654f23b58bcc3 Mon Sep 17 00:00:00 2001 From: jfbu Date: Wed, 4 Dec 2019 23:57:46 +0100 Subject: [PATCH] LaTeX: inhibit so-called TeX Ligatures with xelatex and lualatex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #6886 It is difficult to understand why fontspec _by default_ turns straight double quotes " into ” i.e. right curly ones, calling this "TeX ligature", but that's life and fortunately fontspec also provides a way to turn this off. With this workaround also a straight ' in LaTeX file, (i.e. a straight ' in source and smartquotes = False was used) will not become a curly quote and this is an advantage compared to the pdflatex situation. We suppress TeX Ligatures also for \ttfamily (used in code-blocks) but that appears to be already the case with fontspec although user manual does not seem explicit (and no list of what exactly the TeX Ligatures are is to be found in fontspec user documentation, one has to go into its source code). (the fact that Pygmentize escapes the " to \char`\" TeX mark-up would not by itself prevent the transformation into a curly double quote, it is because fontspec does not apply this transform to monospace typeface that it did not show). --- CHANGES | 2 ++ sphinx/writers/latex.py | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 3122c33b3..3692108a3 100644 --- a/CHANGES +++ b/CHANGES @@ -81,6 +81,8 @@ Bugs fixed include this match. * #6848: config.py shouldn't pop extensions from overrides * #6867: text: extra spaces are inserted to hyphenated words on folding lines +* #6886: LaTeX: xelatex converts straight double quotes into right curly ones + (shows when :confval:`smartquotes` is ``False``) * #6876: LaTeX: multi-line display of authors on title page has ragged edges Testing diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 4c07e552d..7cefa5a6d 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -194,7 +194,8 @@ ADDITIONAL_SETTINGS = { 'latex_engine': 'xelatex', 'polyglossia': '\\usepackage{polyglossia}', 'babel': '', - 'fontenc': '\\usepackage{fontspec}', + 'fontenc': ('\\usepackage{fontspec}\n' + '\\defaultfontfeatures[\\rmfamily,\\sffamily,\\ttfamily]{}'), 'fontpkg': XELATEX_DEFAULT_FONTPKG, 'textgreek': '', 'utf8extra': ('\\catcode`^^^^00a0\\active\\protected\\def^^^^00a0' @@ -205,7 +206,7 @@ ADDITIONAL_SETTINGS = { 'polyglossia': '\\usepackage{polyglossia}', 'babel': '', 'fontenc': ('\\usepackage{fontspec}\n' - '\\defaultfontfeatures[\\rmfamily,\\sffamily]{}'), + '\\defaultfontfeatures[\\rmfamily,\\sffamily,\\ttfamily]{}'), 'fontpkg': LUALATEX_DEFAULT_FONTPKG, 'textgreek': '', 'utf8extra': ('\\catcode`^^^^00a0\\active\\protected\\def^^^^00a0'