LaTeX: support for Greek and Cyrillic

0. do not escape Unicode Greek letters via LaTeX math mark-up: pass them
   through un-modified to LaTeX document,

1. if "fontenc" receives extra option LGR, then pdflatex will support
   Unicode Greek letters (not in math), and with extra option T2A it
   will support (most) Unicode Cyrillic letters.

2. for pdflatex with LGR, this will use "textalpha" LaTeX package and
   "substitutefont" package to set up some automatic font substitution
   to work around the unavailability of Greek with "times"
   package (which is default font package chosen by Sphinx for
   pdflatex), same with T2A and "substitutefont" for Cyrillic.

3. for xelatex/lualatex, set up Computer Modern Unicode as default font,
   as it supports Cyrillic and Greek scripts,

4. for platex, don't do anything special as the engine already has
   its default font supporting Cyrillic and Greek (even in math mode!)

Closes: #5251
Fixes:  #5248
Fixes:  #5247
This commit is contained in:
jfbu 2018-11-15 18:04:11 +01:00
parent 6c94801ec2
commit 2825e338c2
10 changed files with 286 additions and 112 deletions

49
CHANGES
View File

@ -4,7 +4,41 @@ Release 2.0.0 (in development)
Dependencies
------------
* LaTeX builder now depends on TeX Live 2015 or above
* LaTeX builder now depends on TeX Live 2015 or above.
* LaTeX builder may need these additional LaTeX packages for PDF builds
(with ``'pdflatex'`` :confval:`latex_engine`):
.. list-table:: Requirements
:header-rows: 1
* - LaTeX package (CTAN)
- Ubuntu xenial
- needed for
* - substitutefont
- texlive-latex-extra
- Greek or Cyrillic letters (in non-Cyrillic documents)
* - textalpha
- texlive-lang-greek
- Greek letters (in text, not math)
* - gfsartemisia
- fonts-gfs-artemisia (texlive-fonts-extra)
- Greek letters (in text, not math)
* - gfsneohellenic
- fonts-gfs-neohellenic (texlive-fonts-extra)
- Greek letters (in text, not math)
* - cbfonts
- texlive-lang-greek
- Greek letters (in text, not math)
* - cm-lgc
- texlive-fonts-extra
- Cyrillic letters (in non-Cyrillic documents)
These extra package are not required by default. The first two are needed if
the :confval:`latex_elements`.\ ``'fontenc'`` key has been modify to declare
the use of the ``LGR`` (Greek) and/or ``T2A`` (Cyrillic) font encoding. Even
then, the last four are font packages arising in the default value for
:confval:`latex_elements`.\ ``'fontpkg'``, and may be replaced by other font
packages providing ``LGR`` and/or ``T2A`` support.
Incompatible changes
--------------------
@ -15,6 +49,11 @@ Incompatible changes
has been longly used as default of sphinx-quickstart.
* LaTeX: Move message resources to ``sphinxmessage.sty``
* LaTeX: Stop using ``\captions<lang>`` macro for some labels
* LaTeX: Greek letters in text are not escaped to math mode mark-up, and they
will use the text font not the math font. If (and only if) the document
contains such Greek Unicode letters *and* the :confval:`latex_engine` is
``'pdflatex'`` then the :confval:`latex_elements`.\ ``'fontenc'`` key
**must** be used to declare usage of the ``LGR`` font encoding.
Deprecated
----------
@ -58,10 +97,18 @@ __ https://github.com/sphinx-contrib/sphinx-pretty-searchresults
* #4018: htmlhelp: Add :confval:`htmlhelp_file_suffix` and
:confval:`htmlhelp_link_suffix`
* #5559: text: Support complex tables (colspan and rowspan)
* LaTeX: support rendering (not in math, yet) of Greek and Cyrillic Unicode
letters in non-Cyrillic document even with ``'pdflatex'`` as
:confval:`latex_engine`
Bugs fixed
----------
* #5247: LaTeX: PDF does not build with default font config for Russian
language and ``'xelatex'`` or ``'lualatex'`` as :confval:`latex_engine`
(refs: #5251)
* #5248: LaTeX: Greek letters in section titles disappear from PDF bookmarks
Testing
--------

View File

@ -56,10 +56,17 @@ latex_documents = [('contents', 'sphinx.tex', 'Sphinx Documentation',
'Georg Brandl', 'manual', 1)]
latex_logo = '_static/sphinx.png'
latex_elements = {
'fontenc': r'\usepackage[LGR,T2A,T1]{fontenc}',
'fontpkg': r'''
\usepackage[sc]{mathpazo}
\usepackage[scaled]{helvet}
\usepackage{courier}
\substitutefont{LGR}{\rmdefault}{udidot}
\substitutefont{LGR}{\sfdefault}{neohellenic}
\substitutefont{LGR}{\ttdefault}{cmtt}
\substitutefont{T2A}{\rmdefault}{fcm}
\substitutefont{T2A}{\sfdefault}{fcs}
\substitutefont{T2A}{\ttdefault}{fct}
''',
'passoptionstopackages': '\\PassOptionsToPackage{svgnames}{xcolor}',
'preamble': '\\DeclareUnicodeCharacter{229E}{\\ensuremath{\\boxplus}}',

View File

@ -164,6 +164,8 @@ The builder's "name" must be given to the **-b** command-line option of
* ``texlive-latex-recommended``
* ``texlive-fonts-recommended``
* ``texlive-latex-extra``
* ``texlive-fonts-extra``, ``texlive-lang-greek`` (if needed to
support Greek or Cyrillic letters in non-cyrillic document)
* ``latexmk`` (for ``make latexpdf`` on GNU/Linux and MacOS X)
* ``texlive-luatex``, ``texlive-xetex`` (see :confval:`latex_engine`)

View File

@ -2043,17 +2043,48 @@ information.
``babel``, not ``polyglossia``.
``'fontpkg'``
Font package inclusion, default ``'\\usepackage{times}'`` (which uses
Times for text, Helvetica for sans serif and Courier for code-blocks).
Font package inclusion, the default is ``'\\usepackage{times}'`` which
uses Times for text, Helvetica for sans serif and Courier for monospace.
.. versionchanged:: 1.2
Defaults to ``''`` when the :confval:`language` uses the Cyrillic
script.
.. versionchanged:: 1.5
Defaults to ``''`` when :confval:`latex_engine` is ``'xelatex'``.
.. versionchanged:: 1.6
Defaults to ``''`` also with ``'lualatex'``.
.. versionchanged:: 2.0
Support for individual Greek and Cyrillic letters:
- In order to support occasional Cyrillic (физика частиц)
or Greek letters (Σωματιδιακή φυσική) in
a document whose language is English or a Latin European
one, the default set-up is enhanced (only for ``'pdflatex'``
engine) to do:
.. code-block:: latex
\substitutefont{LGR}{\rmdefault}{artemisia}
\substitutefont{LGR}{\sfdefault}{neohellenic}
\substitutefont{LGR}{\ttdefault}{cmtt}
\substitutefont{T2A}{\rmdefault}{fcm}
\substitutefont{T2A}{\sfdefault}{fcs}
\substitutefont{T2A}{\ttdefault}{fct}
For this however, the ``'fontenc'`` key must be used to tell
LaTeX to load the ``LGR`` (Greek) or ``T2A`` (partial Cyrillic)
font encoding. If ``'fontenc'`` is not modified the above lines
are not executed.
In a custom ``'fontpkg'`` setting, do not use ``\substitutefont``
with a font encoding not also declared via ``'fontenc'``.
- For ``'xelatex'`` and ``'lualatex'``, the default is
``'\\setmainfont{CMU Serif}'`` (and similar for sans
serif and monospace) . This OpenType font family supports
both Cyrillic and Greek scripts (contrarily to the
default font configured by LaTeX for ``xelatex/lualatex``
if ``'fontpkg'`` is left to empty string, as was the case
prior to 2.0).
- ``'platex'`` (Japanese documents) engine supports individual
Cyrillic and Greek letters with no need of extra user set-up.
``'fncychap'``
Inclusion of the "fncychap" package (which makes fancy chapter titles),
default ``'\\usepackage[Bjarne]{fncychap}'`` for English documentation
@ -2130,13 +2161,69 @@ information.
.. versionadded:: 1.2
``'fontenc'``
"fontenc" package inclusion, default ``'\\usepackage[T1]{fontenc}'``.
"fontenc" package inclusion, defaults to
``'\\usepackage[T1]{fontenc}'``.
.. versionchanged:: 1.5
Defaults to ``'\\usepackage{fontspec}'`` when
:confval:`latex_engine` is ``'xelatex'``.
.. versionchanged:: 1.6
``'lualatex'`` also uses ``fontspec`` per default.
.. versionchanged:: 2.0
With ``'pdflatex'`` you can add ``LGR`` and/or ``T2A``
(before ``T1`` which should remain the last) to trigger
automatic support of occasional Greek and Cyrillic letters
in text.
.. attention::
Prior to 2.0, Unicode Greek letters were escaped to use LaTeX
math mark-up. This is not the case anymore so it may be needed
to modify this key into ``'\\usepackage[LGR,T1]{fontenc}'`` and
also to make sure to have the suitable Greek font packages
as listed in :doc:`../changes` (or replacements).
``'textgreek'``
The default (``'pdflatex'`` only) is
``'\\usepackage{textalpha}'``, but only if ``'fontenc'`` was
modified by user to include ``LGR`` option. If not, the key
value will be forced to be empty string.
This is needed for ``pdfLaTeX`` to support Unicode input of Greek
letters such as φύσις. Expert users may want to load the ``textalpha``
package with its option ``normalize-symbols``.
.. note::
- Unicode Greek letters in text were, prior to release 2.0, escaped
to LaTeX math markup in the produced LaTeX file, hence their
rendering in PDF used the math font. They are now copied over
unmodified to the LaTeX file and rendered in PDF by the text
font. But the ``LGR`` font encoding must be loaded.
- Unicode Greek letters are not accepted in :rst:dir:`math`
contents. LaTeX math mark-up ``\alpha`` etc..., must be used
there.
- With ``'xelatex'`` or ``'lualatex'``, this is ignored as the
support for Unicode Greek letters comes from using an OpenType
font which supports the Greek script. This is the case (since
2.0) with the default fonts used by Sphinx for these engines.
Besides, Unicode input in math (not only Greek symbols) can be
obtained by adding ``\usepackage{unicode-math}`` to the LaTeX
preamble (and perhaps use ``\setmathfont`` to switch to some
other OpenMath font than the XeLaTeX default). Then one can use
``:math:`α=\alpha``` input. But take note that
``\usepackage[math-style=literal]{unicode-math}`` is needed to
obtain in PDF similar output as in HTML+MathJaX, i.e. the ``α``
remains upright, and the ``\alpha`` gives an italic letter.
- With ``platex`` (Japanese), this key setting is ignored:
Greek (and Cyrillic) letters are handled natively by the engine
own default fonts.
.. versionadded:: 2.0
``'geometry'``
"geometry" package inclusion, the default definition is:

View File

@ -26,7 +26,9 @@
<%= fontenc %>
<%= amsmath %>
<%= multilingual %>
<%= substitutefont %>
<%= fontpkg %>
<%= textgreek %>
<%= fncychap %>
\usepackage<%= sphinxpkgoptions %>{sphinx}
<%= sphinxsetup %>

View File

@ -247,6 +247,8 @@
\DeclareStringOption[\inv@mag in]{vmargin}
\DeclareStringOption[.5\dimexpr\inv@mag in\relax]{marginpar}
\fi
% Allow Cyrillic letters in non-Cyrillic document (needed for pdflatex only)
\DeclareBoolOption[false]{cyrnocyr}
\DeclareStringOption[0]{maxlistdepth}% \newcommand*\spx@opt@maxlistdepth{0}
\DeclareStringOption[-1]{numfigreset}
@ -361,6 +363,28 @@
\newcommand\sphinxsetup[1]{\setkeys{sphinx}{#1}}
%% CYRILLIC IN NON-CYRILLIC DOCUMENTS (pdflatex only)
%
% refs: https://tex.stackexchange.com/q/460271/4686
%
\ifspx@opt@cyrnocyr
\@tfor\@tempa:=%
{ae}{a}{b}{chrdsc}{chvcrs}{ch}{c}{dje}{dze}{dzhe}{d}{erev}{ery}{e}%
{f}{ghcrs}{gup}{g}{hdsc}{hrdsn}{h}{ie}{ii}{ishrt}{i}{je}%
{kbeak}{kdsc}{kvcrs}{k}{lje}{l}{m}{ndsc}{ng}{nje}{n}{otld}{o}{p}{r}%
{schwa}{sdsc}{sftsn}{shch}{shha}{sh}{s}{tshe}{t}{ushrt}{u}{v}%
{ya}{yhcrs}{yi}{yo}{yu}{y}{zdsc}{zhdsc}{zh}{z}\do
{%
\expandafter\DeclareTextSymbolDefault\expandafter
{\csname cyr\@tempa\endcsname}{T2A}%
\expandafter\uppercase\expandafter{\expandafter
\def\expandafter\@tempa\expandafter{\@tempa}}%
\expandafter\DeclareTextSymbolDefault\expandafter
{\csname CYR\@tempa\endcsname}{T2A}%
}%
\DeclareTextSymbolDefault{\CYRpalochka}{T2A}%
\fi
%% MAXLISTDEPTH
%
% remove LaTeX's cap on nesting depth if 'maxlistdepth' key used.

View File

@ -147,40 +147,61 @@
(merge-rule "\(\sb{\text{7}}\)" "₇" :string)
(merge-rule "\(\sb{\text{8}}\)" "₈" :string)
(merge-rule "\(\sb{\text{9}}\)" "₉" :string)
(merge-rule "\(\alpha\)" "α" :string)
(merge-rule "\(\beta\)" "β" :string)
(merge-rule "\(\gamma\)" "γ" :string)
(merge-rule "\(\delta\)" "δ" :string)
(merge-rule "\(\epsilon\)" "ε" :string)
(merge-rule "\(\zeta\)" "ζ" :string)
(merge-rule "\(\eta\)" "η" :string)
(merge-rule "\(\theta\)" "θ" :string)
(merge-rule "\(\iota\)" "ι" :string)
(merge-rule "\(\kappa\)" "κ" :string)
(merge-rule "\(\lambda\)" "λ" :string)
(merge-rule "\(\mu\)" "μ" :string)
(merge-rule "\(\nu\)" "ν" :string)
(merge-rule "\(\xi\)" "ξ" :string)
(merge-rule "\(\pi\)" "π" :string)
(merge-rule "\(\rho\)" "ρ" :string)
(merge-rule "\(\sigma\)" "σ" :string)
(merge-rule "\(\tau\)" "τ" :string)
(merge-rule "\(\upsilon\)" "υ" :string)
(merge-rule "\(\phi\)" "φ" :string)
(merge-rule "\(\chi\)" "χ" :string)
(merge-rule "\(\psi\)" "ψ" :string)
(merge-rule "\(\omega\)" "ω" :string)
(merge-rule "\(\Gamma\)" "Γ" :string)
(merge-rule "\(\Delta\)" "Δ" :string)
(merge-rule "\(\Theta\)" "Θ" :string)
(merge-rule "\(\Lambda\)" "Λ" :string)
(merge-rule "\(\Xi\)" "Ξ" :string)
(merge-rule "\(\Pi\)" "Π" :string)
(merge-rule "\(\Sigma\)" "Σ" :string)
(merge-rule "\(\Upsilon\)" "Υ" :string)
(merge-rule "\(\Phi\)" "Φ" :string)
(merge-rule "\(\Psi\)" "Ψ" :string)
(merge-rule "\(\Omega\)" "Ω" :string)
(merge-rule "\IeC {\textalpha }" "α" :string)
(merge-rule "\IeC {\textbeta }" "β" :string)
(merge-rule "\IeC {\textgamma }" "γ" :string)
(merge-rule "\IeC {\textdelta }" "δ" :string)
(merge-rule "\IeC {\textepsilon }" "ε" :string)
(merge-rule "\IeC {\textzeta }" "ζ" :string)
(merge-rule "\IeC {\texteta }" "η" :string)
(merge-rule "\IeC {\texttheta }" "θ" :string)
(merge-rule "\IeC {\textiota }" "ι" :string)
(merge-rule "\IeC {\textkappa }" "κ" :string)
(merge-rule "\IeC {\textlambda }" "λ" :string)
(merge-rule "\IeC {\textmu }" "μ" :string)
(merge-rule "\IeC {\textnu }" "ν" :string)
(merge-rule "\IeC {\textxi }" "ξ" :string)
(merge-rule "\IeC {\textomicron }" "ο" :string)
(merge-rule "\IeC {\textpi }" "π" :string)
(merge-rule "\IeC {\textrho }" "ρ" :string)
(merge-rule "\IeC {\textsigma }" "σ" :string)
(merge-rule "\IeC {\texttau }" "τ" :string)
(merge-rule "\IeC {\textupsilon }" "υ" :string)
(merge-rule "\IeC {\textphi }" "φ" :string)
(merge-rule "\IeC {\textchi }" "χ" :string)
(merge-rule "\IeC {\textpsi }" "ψ" :string)
(merge-rule "\IeC {\textomega }" "ω" :string)
(merge-rule "\IeC {\textAlpha }" "Α" :string)
(merge-rule "\IeC {\textBeta }" "Β" :string)
(merge-rule "\IeC {\textGamma }" "Γ" :string)
(merge-rule "\IeC {\textDelta }" "Δ" :string)
(merge-rule "\IeC {\textEpsilon }" "Ε" :string)
(merge-rule "\IeC {\textZeta }" "Ζ" :string)
(merge-rule "\IeC {\textEta }" "Η" :string)
(merge-rule "\IeC {\textTheta }" "Θ" :string)
(merge-rule "\IeC {\textIota }" "Ι" :string)
(merge-rule "\IeC {\textKappa }" "Κ" :string)
(merge-rule "\IeC {\textLambda }" "Λ" :string)
(merge-rule "\IeC {\textMu }" "Μ" :string)
(merge-rule "\IeC {\textNu }" "Ν" :string)
(merge-rule "\IeC {\textTheta }" "Θ" :string)
(merge-rule "\IeC {\textIota }" "Ι" :string)
(merge-rule "\IeC {\textKappa }" "Κ" :string)
(merge-rule "\IeC {\textLambda }" "Λ" :string)
(merge-rule "\IeC {\textMu }" "Μ" :string)
(merge-rule "\IeC {\textNu }" "Ν" :string)
(merge-rule "\IeC {\textXi }" "Ξ" :string)
(merge-rule "\IeC {\textOmicron }" "Ο" :string)
(merge-rule "\IeC {\textPi }" "Π" :string)
(merge-rule "\IeC {\textRho }" "Ρ" :string)
(merge-rule "\IeC {\textSigma }" "Σ" :string)
(merge-rule "\IeC {\textTau }" "Τ" :string)
(merge-rule "\IeC {\textUpsilon }" "Υ" :string)
(merge-rule "\IeC {\textPhi }" "Φ" :string)
(merge-rule "\IeC {\textChi }" "Χ" :string)
(merge-rule "\IeC {\textPsi }" "Ψ" :string)
(merge-rule "\IeC {\textOmega }" "Ω" :string)
(merge-rule "\IeC {\textohm }" "Ω" :string)
;; This xindy module provides some basic support for "see"
(require "makeindex.xdy")

View File

@ -69,56 +69,8 @@ tex_replacements = [
('', r'\(\sb{\text{7}}\)'),
('', r'\(\sb{\text{8}}\)'),
('', r'\(\sb{\text{9}}\)'),
# map Greek alphabet
('α', r'\(\alpha\)'),
('β', r'\(\beta\)'),
('γ', r'\(\gamma\)'),
('δ', r'\(\delta\)'),
('ε', r'\(\epsilon\)'),
('ζ', r'\(\zeta\)'),
('η', r'\(\eta\)'),
('θ', r'\(\theta\)'),
('ι', r'\(\iota\)'),
('κ', r'\(\kappa\)'),
('λ', r'\(\lambda\)'),
('μ', r'\(\mu\)'),
('ν', r'\(\nu\)'),
('ξ', r'\(\xi\)'),
('ο', r'o'),
('π', r'\(\pi\)'),
('ρ', r'\(\rho\)'),
('σ', r'\(\sigma\)'),
('τ', r'\(\tau\)'),
('υ', '\\(\\upsilon\\)'),
('φ', r'\(\phi\)'),
('χ', r'\(\chi\)'),
('ψ', r'\(\psi\)'),
('ω', r'\(\omega\)'),
('Α', r'A'),
('Β', r'B'),
('Γ', r'\(\Gamma\)'),
('Δ', r'\(\Delta\)'),
('Ε', r'E'),
('Ζ', r'Z'),
('Η', r'H'),
('Θ', r'\(\Theta\)'),
('Ι', r'I'),
('Κ', r'K'),
('Λ', r'\(\Lambda\)'),
('Μ', r'M'),
('Ν', r'N'),
('Ξ', r'\(\Xi\)'),
('Ο', r'O'),
('Π', r'\(\Pi\)'),
('Ρ', r'P'),
('Σ', r'\(\Sigma\)'),
('Τ', r'T'),
('Υ', '\\(\\Upsilon\\)'),
('Φ', r'\(\Phi\)'),
('Χ', r'X'),
('Ψ', r'\(\Psi\)'),
('Ω', r'\(\Omega\)'),
('', r'\(\Omega\)'),
# Greek alphabet not escaped: pdflatex handles it via textalpha and inputenc
# OHM SIGN U+2126 is handled by LaTeX textcomp package
]
tex_escape_map = {} # type: Dict[int, unicode]

View File

@ -64,6 +64,23 @@ ENUMERATE_LIST_STYLE = defaultdict(lambda: r'\arabic',
'lowerroman': r'\roman',
'upperroman': r'\Roman',
}) # type: Dict[unicode, unicode]
PDFLATEX_DEFAULT_FONT_PKG = r'''
\usepackage{times}
\expandafter\ifx\csname T@LGR\endcsname\relax
\else
% LGR was declared as font encoding
\substitutefont{LGR}{\rmdefault}{artemisia} % gfsartemisia
\substitutefont{LGR}{\sfdefault}{neohellenic} % gfsneohellenic
\substitutefont{LGR}{\ttdefault}{cmtt} % cbfonts
\fi
\expandafter\ifx\csname T@T2A\endcsname\relax
\else
% T2A was declared as font encoding
\substitutefont{T2A}{\rmdefault}{fcm}
\substitutefont{T2A}{\sfdefault}{fcs}
\substitutefont{T2A}{\ttdefault}{fct}
\fi
'''
DEFAULT_SETTINGS = {
'latex_engine': 'pdflatex',
@ -86,7 +103,9 @@ DEFAULT_SETTINGS = {
'multilingual': '',
'babel': '\\usepackage{babel}',
'polyglossia': '',
'fontpkg': '\\usepackage{times}',
'fontpkg': PDFLATEX_DEFAULT_FONT_PKG,
'substitutefont': '',
'textgreek': '\\usepackage{textalpha}',
'fncychap': '\\usepackage[Bjarne]{fncychap}',
'hyperref': ('% Include hyperref last.\n'
'\\usepackage{hyperref}\n'
@ -121,21 +140,17 @@ ADDITIONAL_SETTINGS = {
'inputenc': '\\usepackage[utf8]{inputenc}',
'utf8extra': ('\\ifdefined\\DeclareUnicodeCharacter\n'
'% support both utf8 and utf8x syntaxes\n'
'\\edef\\sphinxdqmaybe{'
'\\ifdefined\\DeclareUnicodeCharacterAsOptional'
'\\string"\\fi}\n'
' \\DeclareUnicodeCharacter{\\sphinxdqmaybe00A0}'
'{\\nobreakspace}\n'
' \\DeclareUnicodeCharacter{\\sphinxdqmaybe2500}'
'{\\sphinxunichar{2500}}\n'
' \\DeclareUnicodeCharacter{\\sphinxdqmaybe2502}'
'{\\sphinxunichar{2502}}\n'
' \\DeclareUnicodeCharacter{\\sphinxdqmaybe2514}'
'{\\sphinxunichar{2514}}\n'
' \\DeclareUnicodeCharacter{\\sphinxdqmaybe251C}'
'{\\sphinxunichar{251C}}\n'
' \\DeclareUnicodeCharacter{\\sphinxdqmaybe2572}'
'{\\textbackslash}\n'
' \\ifdefined\\DeclareUnicodeCharacterAsOptional\n'
' \\def\\sphinxDUC#1{\\DeclareUnicodeCharacter{"#1}}\n'
' \\else\n'
' \\let\\sphinxDUC\\DeclareUnicodeCharacter\n'
' \\fi\n'
' \\sphinxDUC{00A0}{\\nobreakspace}\n'
' \\sphinxDUC{2500}{\\sphinxunichar{2500}}\n'
' \\sphinxDUC{2502}{\\sphinxunichar{2502}}\n'
' \\sphinxDUC{2514}{\\sphinxunichar{2514}}\n'
' \\sphinxDUC{251C}{\\sphinxunichar{251C}}\n'
' \\sphinxDUC{2572}{\\textbackslash}\n'
'\\fi'),
},
'xelatex': {
@ -143,7 +158,10 @@ ADDITIONAL_SETTINGS = {
'polyglossia': '\\usepackage{polyglossia}',
'babel': '',
'fontenc': '\\usepackage{fontspec}',
'fontpkg': '',
'fontpkg': ('\\setmainfont{CMU Serif}\n'
'\\setsansfont{CMU Sans Serif}\n'
'\\setmonofont{CMU Typewriter Text}'),
'textgreek': '',
'utf8extra': ('\\catcode`^^^^00a0\\active\\protected\\def^^^^00a0'
'{\\leavevmode\\nobreak\\ }'),
'fvset': '\\fvset{fontsize=auto}',
@ -153,7 +171,10 @@ ADDITIONAL_SETTINGS = {
'polyglossia': '\\usepackage{polyglossia}',
'babel': '',
'fontenc': '\\usepackage{fontspec}',
'fontpkg': '',
'fontpkg': ('\\setmainfont{CMU Serif}\n'
'\\setsansfont{CMU Sans Serif}\n'
'\\setmonofont{CMU Typewriter Text}'),
'textgreek': '',
'utf8extra': ('\\catcode`^^^^00a0\\active\\protected\\def^^^^00a0'
'{\\leavevmode\\nobreak\\ }'),
'fvset': '\\fvset{fontsize=auto}',
@ -162,6 +183,8 @@ ADDITIONAL_SETTINGS = {
'latex_engine': 'platex',
'babel': '',
'classoptions': ',dvipdfmx',
'fontpkg': '\\usepackage{times}',
'textgreek': '',
'fncychap': '',
'geometry': '\\usepackage[dvipdfm]{geometry}',
},
@ -552,6 +575,15 @@ class LaTeXTranslator(nodes.NodeVisitor):
builder.config.language)
# set up multilingual module...
if self.elements['latex_engine'] == 'pdflatex':
if ('T2A' in self.elements['fontenc'] and
not self.babel.uses_cyrillic()):
self.elements['substitutefont'] = '\\usepackage{substitutefont}'
self.elements['sphinxpkgoptions'] += ',cyrnocyr'
if 'LGR' in self.elements['fontenc']:
self.elements['substitutefont'] = '\\usepackage{substitutefont}'
else:
self.elements['textgreek'] = ''
# 'babel' key is public and user setting must be obeyed
if self.elements['babel']:
self.elements['classoptions'] += ',' + self.babel.get_language()

View File

@ -216,7 +216,7 @@ def get_verifier(verify, verify_re):
'verify',
u'Γ\\\\∞$',
None,
r'\(\Gamma\)\textbackslash{}\(\infty\)\$',
u'Γ\\textbackslash{}\\(\\infty\\)\\$',
),
(
# in verbatim code fragments
@ -225,7 +225,7 @@ def get_verifier(verify, verify_re):
None,
(u'\\fvset{hllines={, ,}}%\n'
u'\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]\n'
u'@\\(\\Gamma\\)\\PYGZbs{}\\(\\infty\\)\\PYGZdl{}\\PYGZob{}\\PYGZcb{}\n'
u'@Γ\\PYGZbs{}\\(\\infty\\)\\PYGZdl{}\\PYGZob{}\\PYGZcb{}\n'
u'\\end{sphinxVerbatim}'),
),
(