mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
LaTeX: font choices for Greek and Cyrillic support, and (Xe|Lua)LaTeX
This commit is contained in:
parent
6283324b1a
commit
1edf2a45b9
52
CHANGES
52
CHANGES
@ -5,43 +5,16 @@ 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
|
* LaTeX builder (with ``'pdflatex'`` :confval:`latex_engine`) will process
|
||||||
(with ``'pdflatex'`` :confval:`latex_engine`):
|
Unicode Greek letters in text (not in math mark-up) via the text font and
|
||||||
|
will not escape them to math mark-up. See the discussion of the
|
||||||
.. list-table:: Requirements
|
``'fontenc'`` key of :confval:`latex_elements`; such (optional) support for
|
||||||
:header-rows: 1
|
Greek adds, for example on Ubuntu xenial, the ``texlive-lang-greek`` and (if
|
||||||
|
default font set-up is not modified) ``cm-super(-minimal)`` as additional
|
||||||
* - LaTeX package (CTAN)
|
Sphinx LaTeX requirements.
|
||||||
- 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.
|
|
||||||
* LaTeX builder with :confval:`latex_engine` set to ``'xelatex'`` or to
|
* LaTeX builder with :confval:`latex_engine` set to ``'xelatex'`` or to
|
||||||
``'lualatex'`` requires (by default) the ``Computer Modern Unicode`` fonts,
|
``'lualatex'`` requires (by default) the ``FreeFont`` fonts,
|
||||||
which in Ubuntu xenial are in ``texlive-fonts-extra``.
|
which in Ubuntu xenial are provided by package ``fonts-freefont-otf``.
|
||||||
|
|
||||||
Incompatible changes
|
Incompatible changes
|
||||||
--------------------
|
--------------------
|
||||||
@ -53,10 +26,9 @@ Incompatible changes
|
|||||||
* LaTeX: Move message resources to ``sphinxmessage.sty``
|
* LaTeX: Move message resources to ``sphinxmessage.sty``
|
||||||
* LaTeX: Stop using ``\captions<lang>`` macro for some labels
|
* LaTeX: Stop using ``\captions<lang>`` macro for some labels
|
||||||
* LaTeX: Greek letters in text are not escaped to math mode mark-up, and they
|
* 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
|
will use the text font not the math font. The ``LGR`` font encoding must be
|
||||||
contains such Greek Unicode letters *and* the :confval:`latex_engine` is
|
added to the ``'fontenc'`` key of :confval:`latex_elements` for this to work
|
||||||
``'pdflatex'`` then the :confval:`latex_elements`.\ ``'fontenc'`` key
|
(only if it is needed by the document, of course).
|
||||||
**must** be used to declare usage of the ``LGR`` font encoding.
|
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
12
doc/conf.py
12
doc/conf.py
@ -56,17 +56,17 @@ latex_documents = [('contents', 'sphinx.tex', 'Sphinx Documentation',
|
|||||||
'Georg Brandl', 'manual', 1)]
|
'Georg Brandl', 'manual', 1)]
|
||||||
latex_logo = '_static/sphinx.png'
|
latex_logo = '_static/sphinx.png'
|
||||||
latex_elements = {
|
latex_elements = {
|
||||||
'fontenc': r'\usepackage[LGR,T2A,T1]{fontenc}',
|
'fontenc': r'\usepackage[LGR,X2,T1]{fontenc}',
|
||||||
'fontpkg': r'''
|
'fontpkg': r'''
|
||||||
\usepackage[sc]{mathpazo}
|
\usepackage[sc]{mathpazo}
|
||||||
\usepackage[scaled]{helvet}
|
\usepackage[scaled]{helvet}
|
||||||
\usepackage{courier}
|
\usepackage{courier}
|
||||||
\substitutefont{LGR}{\rmdefault}{udidot}
|
\substitutefont{LGR}{\rmdefault}{cmr}
|
||||||
\substitutefont{LGR}{\sfdefault}{neohellenic}
|
\substitutefont{LGR}{\sfdefault}{cmss}
|
||||||
\substitutefont{LGR}{\ttdefault}{cmtt}
|
\substitutefont{LGR}{\ttdefault}{cmtt}
|
||||||
\substitutefont{T2A}{\rmdefault}{fcm}
|
\substitutefont{X2}{\rmdefault}{cmr}
|
||||||
\substitutefont{T2A}{\sfdefault}{fcs}
|
\substitutefont{X2}{\sfdefault}{cmss}
|
||||||
\substitutefont{T2A}{\ttdefault}{fct}
|
\substitutefont{X2}{\ttdefault}{cmtt}
|
||||||
''',
|
''',
|
||||||
'passoptionstopackages': '\\PassOptionsToPackage{svgnames}{xcolor}',
|
'passoptionstopackages': '\\PassOptionsToPackage{svgnames}{xcolor}',
|
||||||
'preamble': '\\DeclareUnicodeCharacter{229E}{\\ensuremath{\\boxplus}}',
|
'preamble': '\\DeclareUnicodeCharacter{229E}{\\ensuremath{\\boxplus}}',
|
||||||
|
@ -158,20 +158,34 @@ The builder's "name" must be given to the **-b** command-line option of
|
|||||||
chapter :ref:`latex-options` for details.
|
chapter :ref:`latex-options` for details.
|
||||||
|
|
||||||
The produced LaTeX file uses several LaTeX packages that may not be present
|
The produced LaTeX file uses several LaTeX packages that may not be present
|
||||||
in a "minimal" TeX distribution installation. For example, on Ubuntu, the
|
in a "minimal" TeX distribution installation.
|
||||||
following packages need to be installed for successful PDF builds:
|
|
||||||
|
On Ubuntu xenial, the following packages need to be installed for
|
||||||
|
successful PDF builds:
|
||||||
|
|
||||||
* ``texlive-latex-recommended``
|
* ``texlive-latex-recommended``
|
||||||
* ``texlive-fonts-recommended``
|
* ``texlive-fonts-recommended``
|
||||||
* ``texlive-latex-extra``
|
* ``texlive-latex-extra``
|
||||||
* ``texlive-fonts-extra``, ``texlive-lang-greek`` (if needed to
|
* ``latexmk`` (this is a Sphinx requirement on GNU/Linux and MacOS X
|
||||||
support Greek or Cyrillic letters in non-cyrillic document)
|
for functioning of ``make latexpdf``)
|
||||||
* ``latexmk`` (for ``make latexpdf`` on GNU/Linux and MacOS X)
|
|
||||||
* ``texlive-luatex``, ``texlive-xetex``, ``texlive-fonts-extra``
|
|
||||||
(if :confval:`latex_engine` is set to ``'xelatex'`` or ``'lualatex'``)
|
|
||||||
|
|
||||||
The testing of Sphinx LaTeX is done on Ubuntu xenial with the above mentioned
|
Additional packages are needed in some circumstances (see the discussion of
|
||||||
packages, which are from a TeXLive 2015 snapshot dated March 2016.
|
the ``'fontpkg'`` key of :confval:`latex_elements` for more information):
|
||||||
|
|
||||||
|
* to support occasional Cyrillic letters or words, and a fortiori if
|
||||||
|
:confval:`language` is set to a Cyrillic language, the package
|
||||||
|
``texlive-lang-cyrillic`` is required, and, with unmodified ``'fontpkg'``,
|
||||||
|
also ``cm-super`` or ``cm-super-minimal``,
|
||||||
|
* to support occasional Greek letters or words (in text, not in
|
||||||
|
:rst:dir:`math` directive contents), ``texlive-lang-greek`` is required,
|
||||||
|
and, with unmodified ``'fontpkg'``, also ``cm-super`` or
|
||||||
|
``cm-super-minimal``,
|
||||||
|
* for ``'xelatex'`` or ``'lualatex'`` (see :confval:`latex_engine`),
|
||||||
|
``texlive-xetex`` resp. ``texlive-luatex``, and, if leaving unchanged
|
||||||
|
``'fontpkg'``, ``fonts-freefont-otf``.
|
||||||
|
|
||||||
|
The testing of Sphinx LaTeX is done on Ubuntu xenial whose TeX distribution
|
||||||
|
is based on a TeXLive 2015 snapshot dated March 2016.
|
||||||
|
|
||||||
.. versionchanged:: 1.6
|
.. versionchanged:: 1.6
|
||||||
Formerly, testing had been done on Ubuntu precise (TeXLive 2009).
|
Formerly, testing had been done on Ubuntu precise (TeXLive 2009).
|
||||||
@ -194,20 +208,16 @@ The builder's "name" must be given to the **-b** command-line option of
|
|||||||
|
|
||||||
reduces console output to a minimum.
|
reduces console output to a minimum.
|
||||||
|
|
||||||
Also, if ``latexmk`` version is 4.52b or higher (Jan 17)
|
Also, if ``latexmk`` is at version 4.52b or higher (January 2017)
|
||||||
``LATEXMKOPTS="-xelatex"`` will speed up PDF builds via XeLateX in case
|
``LATEXMKOPTS="-xelatex"`` speeds up PDF builds via XeLateX in case
|
||||||
of numerous graphics inclusions.
|
of numerous graphics inclusions.
|
||||||
|
|
||||||
.. code-block:: console
|
To pass options directly to the ``(pdf|xe|lua)latex`` binary, use
|
||||||
|
variable ``LATEXOPTS``, for example:
|
||||||
make latexpdf LATEXMKOPTS="-xelatex"
|
|
||||||
|
|
||||||
To pass options directly to the ``(pdf|xe|lua)latex`` executable, use
|
|
||||||
variable ``LATEXOPTS``.
|
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
make latexpdf LATEXOPTS="--interaction=nonstopmode"
|
make latexpdf LATEXOPTS="--halt-on-error"
|
||||||
|
|
||||||
.. autoattribute:: name
|
.. autoattribute:: name
|
||||||
|
|
||||||
|
@ -1796,42 +1796,18 @@ information.
|
|||||||
* ``'lualatex'`` -- LuaLaTeX
|
* ``'lualatex'`` -- LuaLaTeX
|
||||||
* ``'platex'`` -- pLaTeX (default if :confval:`language` is ``'ja'``)
|
* ``'platex'`` -- pLaTeX (default if :confval:`language` is ``'ja'``)
|
||||||
|
|
||||||
PDFLaTeX's support for Unicode characters covers those from the document
|
``'pdflatex'``\ 's support for Unicode characters is limited.
|
||||||
language (the LaTeX ``babel`` and ``inputenc`` packages map them to glyph
|
|
||||||
slots in the document font, at various encodings allowing each only 256
|
|
||||||
characters; Sphinx uses by default (except for Cyrillic languages) the
|
|
||||||
``times`` package), but stray characters from other scripts or special
|
|
||||||
symbols may require adding extra LaTeX packages or macros to the LaTeX
|
|
||||||
preamble.
|
|
||||||
|
|
||||||
If your project uses such extra Unicode characters, switching the engine to
|
If your project uses Unicode characters, setting the engine to
|
||||||
XeLaTeX or LuaLaTeX and setting up the document to use an OpenType font
|
``'xelatex'`` or ``'lualatex'`` and making sure to use an OpenType font
|
||||||
with wide-enough glyph coverage is often easier than sticking with PDFLaTeX
|
with wide-enough glyph coverage (since Sphinx 2.0, the default font is the
|
||||||
and trying to get it to work with the Unicode characters.
|
FreeFont family) is often easier than trying to make
|
||||||
|
``'pdflatex'`` work with the extra Unicode characters.
|
||||||
|
|
||||||
The :confval:`latex_elements` ``'fontpkg'`` key allows to set up the
|
.. note::
|
||||||
document fonts, see :ref:`this example <latex-basic>`. Currently, for
|
|
||||||
XeLaTeX and LuaLaTeX, Sphinx leaves this key empty and LaTeX then defaults
|
|
||||||
to the `Latin Modern`_ font family (from the TeX distribution fonts). This
|
|
||||||
font family provides good coverage of Latin scripts (European languages,
|
|
||||||
Vietnamese) but Cyrillic requires some other OpenType font; for example
|
|
||||||
Computer Modern Unicode (see `babel-russian`_ documentation on how to load
|
|
||||||
it in the LaTeX document). In future, it is planned Sphinx will provide
|
|
||||||
another default choice of OpenType font than `Latin Modern`_, perhaps
|
|
||||||
`Libertinus`_, which is included in recent TeX distributions and supports
|
|
||||||
Latin and Cyrillic and also has an accompanying math font.
|
|
||||||
|
|
||||||
With XeLaTeX and LuaLaTeX, Sphinx configures the LaTeX document to use
|
2.0 adds to ``'pdflatex'`` automatic support in Latin language document
|
||||||
`polyglossia`_. For some languages the `babel`_ support appears
|
of occasional Cyrillic or Greek letters or words.
|
||||||
preferable; Sphinx uses currently `babel`_ for French and perhaps will also
|
|
||||||
for some more languages in future. One can use the
|
|
||||||
:confval:`latex_elements` ``'babel'`` key to override Sphinx's default.
|
|
||||||
|
|
||||||
.. _`Latin Modern`: http://www.gust.org.pl/projects/e-foundry/latin-modern
|
|
||||||
.. _`polyglossia`: https://ctan.org/pkg/polyglossia
|
|
||||||
.. _`babel`: https://ctan.org/pkg/babel
|
|
||||||
.. _`babel-russian`: https://ctan.org/pkg/babel-russian
|
|
||||||
.. _`Libertinus`: https://ctan.org/pkg/libertinus
|
|
||||||
|
|
||||||
.. confval:: latex_documents
|
.. confval:: latex_documents
|
||||||
|
|
||||||
@ -2033,6 +2009,20 @@ information.
|
|||||||
``english`` is used if no language.) For Japanese documents, the
|
``english`` is used if no language.) For Japanese documents, the
|
||||||
default is the empty string.
|
default is the empty string.
|
||||||
|
|
||||||
|
With XeLaTeX and LuaLaTeX, Sphinx configures the LaTeX document to use
|
||||||
|
`polyglossia`_, but one should be aware that current `babel`_ has
|
||||||
|
improved its support for Unicode engines in recent years and for some
|
||||||
|
languages it may make sense to prefer ``babel`` over ``polyglossia``.
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
|
||||||
|
After modifiying a core LaTeX key like this one, clean up the LaTeX
|
||||||
|
build repertory before next PDF build, else left-over auxiliary
|
||||||
|
files are likely to break the build.
|
||||||
|
|
||||||
|
.. _`polyglossia`: https://ctan.org/pkg/polyglossia
|
||||||
|
.. _`babel`: https://ctan.org/pkg/babel
|
||||||
|
|
||||||
.. versionchanged:: 1.5
|
.. versionchanged:: 1.5
|
||||||
For :confval:`latex_engine` set to ``'xelatex'``, the default
|
For :confval:`latex_engine` set to ``'xelatex'``, the default
|
||||||
is ``'\\usepackage{polyglossia}\n\\setmainlanguage{<language>}'``.
|
is ``'\\usepackage{polyglossia}\n\\setmainlanguage{<language>}'``.
|
||||||
@ -2060,28 +2050,38 @@ information.
|
|||||||
|
|
||||||
.. code-block:: latex
|
.. code-block:: latex
|
||||||
|
|
||||||
\substitutefont{LGR}{\rmdefault}{artemisia}
|
\substitutefont{LGR}{\rmdefault}{cmr}
|
||||||
\substitutefont{LGR}{\sfdefault}{neohellenic}
|
\substitutefont{LGR}{\sfdefault}{cmss}
|
||||||
\substitutefont{LGR}{\ttdefault}{cmtt}
|
\substitutefont{LGR}{\ttdefault}{cmtt}
|
||||||
\substitutefont{T2A}{\rmdefault}{fcm}
|
\substitutefont{X2}{\rmdefault}{cmr}
|
||||||
\substitutefont{T2A}{\sfdefault}{fcs}
|
\substitutefont{X2}{\sfdefault}{cmss}
|
||||||
\substitutefont{T2A}{\ttdefault}{fct}
|
\substitutefont{X2}{\ttdefault}{cmtt}
|
||||||
|
|
||||||
For this however, the ``'fontenc'`` key must be used to tell
|
but this is activated only under the condition that the
|
||||||
LaTeX to load the ``LGR`` (Greek) or ``T2A`` (partial Cyrillic)
|
``'fontenc'`` key is configured to load the ``LGR`` (Greek)
|
||||||
font encoding. If ``'fontenc'`` is not modified the above lines
|
and/or ``X2`` (Cyrillic) pdflatex-font encodings (if the
|
||||||
are not executed.
|
:confval:`language` is set to a Cyrillic language, this
|
||||||
|
``'fontpkg'`` key must be used as "times" package has no direct
|
||||||
|
support for it; then keep only ``LGR`` lines from the above,
|
||||||
|
if support is needed for Greek in the text).
|
||||||
|
|
||||||
In a custom ``'fontpkg'`` setting, do not use ``\substitutefont``
|
The ``\substitutefont`` command is from the eponymous LaTeX
|
||||||
with a font encoding not also declared via ``'fontenc'``.
|
package, which is loaded by Sphinx if needed (on Ubuntu xenial it
|
||||||
|
is part of ``texlive-latex-extra`` which is a Sphinx
|
||||||
|
requirement).
|
||||||
|
|
||||||
- For ``'xelatex'`` and ``'lualatex'``, the default is
|
Only if the document actually does contain Unicode Greek letters
|
||||||
``'\\setmainfont{CMU Serif}'`` (and similar for sans
|
(in text) or Cyrillic letters, will the above default set-up
|
||||||
serif and monospace) . This OpenType font family supports
|
cause additional requirements for the PDF build. On Ubuntu
|
||||||
both Cyrillic and Greek scripts (contrarily to the
|
xenial, ``texlive-lang-greek``, ``texlive-lang-cyrillic``, and
|
||||||
default font configured by LaTeX for ``xelatex/lualatex``
|
(with the above choice of fonts) the ``cm-super`` (or
|
||||||
if ``'fontpkg'`` is left to empty string, as was the case
|
``cm-super-minimal``) package.
|
||||||
prior to 2.0).
|
|
||||||
|
- For ``'xelatex'`` and ``'lualatex'``, the default is to
|
||||||
|
use the FreeFont family: this OpenType font family
|
||||||
|
supports both Cyrillic and Greek scripts and is available as
|
||||||
|
separate Ubuntu xenial package ``fonts-freefont-otf``, it is not
|
||||||
|
needed to install the big package ``texlive-fonts-extra``.
|
||||||
|
|
||||||
- ``'platex'`` (Japanese documents) engine supports individual
|
- ``'platex'`` (Japanese documents) engine supports individual
|
||||||
Cyrillic and Greek letters with no need of extra user set-up.
|
Cyrillic and Greek letters with no need of extra user set-up.
|
||||||
@ -2164,24 +2164,45 @@ information.
|
|||||||
"fontenc" package inclusion, defaults to
|
"fontenc" package inclusion, defaults to
|
||||||
``'\\usepackage[T1]{fontenc}'``.
|
``'\\usepackage[T1]{fontenc}'``.
|
||||||
|
|
||||||
|
One can (``'pdflatex'`` only) add ``LGR`` for support of Greek letters
|
||||||
|
or words in the document, and ``X2`` (or ``T2A``) for Cyrillic ones:
|
||||||
|
|
||||||
|
.. code-block:: latex
|
||||||
|
|
||||||
|
r'\usepackage[LGR,X2,T1]{fontenc}'
|
||||||
|
|
||||||
|
(A Cyrillic document will naturally use ``T2A`` or ``X2`` in last
|
||||||
|
position, as it has then to be the main encoding for the document
|
||||||
|
fonts).
|
||||||
|
|
||||||
|
.. attention::
|
||||||
|
|
||||||
|
Prior to 2.0, Unicode Greek letters were escaped to use LaTeX math
|
||||||
|
mark-up. This is not the case anymore, thus if such Greek letters
|
||||||
|
are used in the text (we are not discussing here Greek letters
|
||||||
|
using the math font, from math markup ``\alpha`` etc...) it is then
|
||||||
|
mandatory to declare the ``LGR`` font encoding, i.e.
|
||||||
|
``r'\usepackage[LGR,T1]{fontenc}'`` if no support for Cyrillic is
|
||||||
|
needed. On Ubuntu xenial, package ``texlive-lang-greek`` is then
|
||||||
|
required (and also ``cm-super`` if the ``'fontpkg'`` setting is not
|
||||||
|
modified).
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
|
||||||
|
Ubuntu package ``cm-super-minimal`` requires that the LaTeX
|
||||||
|
document executes ``\usepackage[10pt]{type1ec}`` before loading
|
||||||
|
``fontenc``. Thus, use this key with this extra at its start.
|
||||||
|
|
||||||
.. versionchanged:: 1.5
|
.. versionchanged:: 1.5
|
||||||
Defaults to ``'\\usepackage{fontspec}'`` when
|
Defaults to ``'\\usepackage{fontspec}'`` when
|
||||||
:confval:`latex_engine` is ``'xelatex'``.
|
:confval:`latex_engine` is ``'xelatex'``.
|
||||||
.. versionchanged:: 1.6
|
.. versionchanged:: 1.6
|
||||||
``'lualatex'`` also uses ``fontspec`` per default.
|
``'lualatex'`` also uses ``fontspec`` per default.
|
||||||
.. versionchanged:: 2.0
|
.. versionchanged:: 2.0
|
||||||
With ``'pdflatex'`` you can add ``LGR`` and/or ``T2A``
|
Detection of ``LGR``, ``T2A``, ``X2`` to trigger support of
|
||||||
(before ``T1`` which should remain the last) to trigger
|
occasional Greek or Cyrillic (``'pdflatex'`` only, as this support
|
||||||
automatic support of occasional Greek and Cyrillic letters
|
is provided natively by ``'platex'`` and only requires suitable
|
||||||
in text.
|
font with ``'xelatex'/'lualatex'``).
|
||||||
|
|
||||||
.. 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'``
|
``'textgreek'``
|
||||||
The default (``'pdflatex'`` only) is
|
The default (``'pdflatex'`` only) is
|
||||||
@ -2190,41 +2211,13 @@ information.
|
|||||||
value will be forced to be empty string.
|
value will be forced to be empty string.
|
||||||
|
|
||||||
This is needed for ``pdfLaTeX`` to support Unicode input of Greek
|
This is needed for ``pdfLaTeX`` to support Unicode input of Greek
|
||||||
letters such as φύσις. Expert users may want to load the ``textalpha``
|
letters such as φύσις. Expert users may want to load the ``textalpha``
|
||||||
package with its option ``normalize-symbols``.
|
package with its option ``normalize-symbols``.
|
||||||
|
|
||||||
.. note::
|
With ``'platex'`` (Japanese), ``'xelatex'`` or ``'lualatex'``, this
|
||||||
|
key is ignored.
|
||||||
- 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
|
.. versionadded:: 2.0
|
||||||
|
|
||||||
``'geometry'``
|
``'geometry'``
|
||||||
"geometry" package inclusion, the default definition is:
|
"geometry" package inclusion, the default definition is:
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
<%= amsmath %>
|
<%= amsmath %>
|
||||||
<%= multilingual %>
|
<%= multilingual %>
|
||||||
<%= substitutefont %>
|
<%= substitutefont %>
|
||||||
|
<%= textcyrillic %>
|
||||||
<%= fontpkg %>
|
<%= fontpkg %>
|
||||||
<%= textgreek %>
|
<%= textgreek %>
|
||||||
<%= fncychap %>
|
<%= fncychap %>
|
||||||
|
@ -247,8 +247,6 @@
|
|||||||
\DeclareStringOption[\inv@mag in]{vmargin}
|
\DeclareStringOption[\inv@mag in]{vmargin}
|
||||||
\DeclareStringOption[.5\dimexpr\inv@mag in\relax]{marginpar}
|
\DeclareStringOption[.5\dimexpr\inv@mag in\relax]{marginpar}
|
||||||
\fi
|
\fi
|
||||||
% Allow Cyrillic letters in non-Cyrillic document (needed for pdflatex only)
|
|
||||||
\DeclareBoolOption[false]{cyrnocyr}
|
|
||||||
|
|
||||||
\DeclareStringOption[0]{maxlistdepth}% \newcommand*\spx@opt@maxlistdepth{0}
|
\DeclareStringOption[0]{maxlistdepth}% \newcommand*\spx@opt@maxlistdepth{0}
|
||||||
\DeclareStringOption[-1]{numfigreset}
|
\DeclareStringOption[-1]{numfigreset}
|
||||||
@ -363,28 +361,6 @@
|
|||||||
\newcommand\sphinxsetup[1]{\setkeys{sphinx}{#1}}
|
\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
|
%% MAXLISTDEPTH
|
||||||
%
|
%
|
||||||
% remove LaTeX's cap on nesting depth if 'maxlistdepth' key used.
|
% remove LaTeX's cap on nesting depth if 'maxlistdepth' key used.
|
||||||
|
@ -64,23 +64,54 @@ ENUMERATE_LIST_STYLE = defaultdict(lambda: r'\arabic',
|
|||||||
'lowerroman': r'\roman',
|
'lowerroman': r'\roman',
|
||||||
'upperroman': r'\Roman',
|
'upperroman': r'\Roman',
|
||||||
}) # type: Dict[unicode, unicode]
|
}) # type: Dict[unicode, unicode]
|
||||||
PDFLATEX_DEFAULT_FONT_PKG = r'''
|
PDFLATEX_DEFAULT_FONTPKG = r'''
|
||||||
\usepackage{times}
|
\usepackage{times}
|
||||||
\expandafter\ifx\csname T@LGR\endcsname\relax
|
\expandafter\ifx\csname T@LGR\endcsname\relax
|
||||||
\else
|
\else
|
||||||
% LGR was declared as font encoding
|
% LGR was declared as font encoding
|
||||||
\substitutefont{LGR}{\rmdefault}{artemisia} % gfsartemisia
|
\substitutefont{LGR}{\rmdefault}{cmr}
|
||||||
\substitutefont{LGR}{\sfdefault}{neohellenic} % gfsneohellenic
|
\substitutefont{LGR}{\sfdefault}{cmss}
|
||||||
\substitutefont{LGR}{\ttdefault}{cmtt} % cbfonts
|
\substitutefont{LGR}{\ttdefault}{cmtt}
|
||||||
\fi
|
\fi
|
||||||
\expandafter\ifx\csname T@T2A\endcsname\relax
|
\expandafter\ifx\csname T@X2\endcsname\relax
|
||||||
|
\expandafter\ifx\csname T@T2A\endcsname\relax
|
||||||
|
\else
|
||||||
|
% T2A was declared as font encoding
|
||||||
|
\substitutefont{T2A}{\rmdefault}{cmr}
|
||||||
|
\substitutefont{T2A}{\sfdefault}{cmss}
|
||||||
|
\substitutefont{T2A}{\ttdefault}{cmtt}
|
||||||
|
\fi
|
||||||
\else
|
\else
|
||||||
% T2A was declared as font encoding
|
% X2 was declared as font encoding
|
||||||
\substitutefont{T2A}{\rmdefault}{fcm}
|
\substitutefont{X2}{\rmdefault}{cmr}
|
||||||
\substitutefont{T2A}{\sfdefault}{fcs}
|
\substitutefont{X2}{\sfdefault}{cmss}
|
||||||
\substitutefont{T2A}{\ttdefault}{fct}
|
\substitutefont{X2}{\ttdefault}{cmtt}
|
||||||
\fi
|
\fi
|
||||||
'''
|
'''
|
||||||
|
XELATEX_DEFAULT_FONTPKG = r'''
|
||||||
|
\setmainfont{FreeSerif}[
|
||||||
|
Extension = .otf,
|
||||||
|
UprightFont = *,
|
||||||
|
ItalicFont = *Italic,
|
||||||
|
BoldFont = *Bold,
|
||||||
|
BoldItalicFont = *BoldItalic
|
||||||
|
]
|
||||||
|
\setsansfont{FreeSans}[
|
||||||
|
Extension = .otf,
|
||||||
|
UprightFont = *,
|
||||||
|
ItalicFont = *Oblique,
|
||||||
|
BoldFont = *Bold,
|
||||||
|
BoldItalicFont = *BoldOblique,
|
||||||
|
]
|
||||||
|
\setmonofont{FreeMono}[
|
||||||
|
Extension = .otf,
|
||||||
|
UprightFont = *,
|
||||||
|
ItalicFont = *Oblique,
|
||||||
|
BoldFont = *Bold,
|
||||||
|
BoldItalicFont = *BoldOblique,
|
||||||
|
]
|
||||||
|
'''
|
||||||
|
LUALATEX_DEFAULT_FONTPKG = XELATEX_DEFAULT_FONTPKG
|
||||||
|
|
||||||
DEFAULT_SETTINGS = {
|
DEFAULT_SETTINGS = {
|
||||||
'latex_engine': 'pdflatex',
|
'latex_engine': 'pdflatex',
|
||||||
@ -103,8 +134,9 @@ DEFAULT_SETTINGS = {
|
|||||||
'multilingual': '',
|
'multilingual': '',
|
||||||
'babel': '\\usepackage{babel}',
|
'babel': '\\usepackage{babel}',
|
||||||
'polyglossia': '',
|
'polyglossia': '',
|
||||||
'fontpkg': PDFLATEX_DEFAULT_FONT_PKG,
|
'fontpkg': PDFLATEX_DEFAULT_FONTPKG,
|
||||||
'substitutefont': '',
|
'substitutefont': '',
|
||||||
|
'textcyrillic': '',
|
||||||
'textgreek': '\\usepackage{textalpha}',
|
'textgreek': '\\usepackage{textalpha}',
|
||||||
'fncychap': '\\usepackage[Bjarne]{fncychap}',
|
'fncychap': '\\usepackage[Bjarne]{fncychap}',
|
||||||
'hyperref': ('% Include hyperref last.\n'
|
'hyperref': ('% Include hyperref last.\n'
|
||||||
@ -158,18 +190,7 @@ ADDITIONAL_SETTINGS = {
|
|||||||
'polyglossia': '\\usepackage{polyglossia}',
|
'polyglossia': '\\usepackage{polyglossia}',
|
||||||
'babel': '',
|
'babel': '',
|
||||||
'fontenc': '\\usepackage{fontspec}',
|
'fontenc': '\\usepackage{fontspec}',
|
||||||
'fontpkg': ('\\setmainfont{cmunrm.otf}[\n'
|
'fontpkg': XELATEX_DEFAULT_FONTPKG,
|
||||||
' BoldFont = cmunbx.otf,\n'
|
|
||||||
' ItalicFont = cmunti.otf,\n'
|
|
||||||
' BoldItalicFont = cmunbi.otf]\n'
|
|
||||||
'\\setsansfont{cmunss.otf}[\n'
|
|
||||||
' BoldFont = cmunsx.otf,\n'
|
|
||||||
' ItalicFont = cmunsi.otf,\n'
|
|
||||||
' BoldItalicFont = cmunso.otf]\n'
|
|
||||||
'\\setmonofont{cmuntt.otf}[\n'
|
|
||||||
' BoldFont = cmuntb.otf,\n'
|
|
||||||
' ItalicFont = cmunit.otf,\n'
|
|
||||||
' BoldItalicFont = cmuntx.otf]'),
|
|
||||||
'textgreek': '',
|
'textgreek': '',
|
||||||
'utf8extra': ('\\catcode`^^^^00a0\\active\\protected\\def^^^^00a0'
|
'utf8extra': ('\\catcode`^^^^00a0\\active\\protected\\def^^^^00a0'
|
||||||
'{\\leavevmode\\nobreak\\ }'),
|
'{\\leavevmode\\nobreak\\ }'),
|
||||||
@ -180,9 +201,7 @@ ADDITIONAL_SETTINGS = {
|
|||||||
'polyglossia': '\\usepackage{polyglossia}',
|
'polyglossia': '\\usepackage{polyglossia}',
|
||||||
'babel': '',
|
'babel': '',
|
||||||
'fontenc': '\\usepackage{fontspec}',
|
'fontenc': '\\usepackage{fontspec}',
|
||||||
'fontpkg': ('\\setmainfont{CMU Serif}\n'
|
'fontpkg': LUALATEX_DEFAULT_FONTPKG,
|
||||||
'\\setsansfont{CMU Sans Serif}\n'
|
|
||||||
'\\setmonofont{CMU Typewriter Text}'),
|
|
||||||
'textgreek': '',
|
'textgreek': '',
|
||||||
'utf8extra': ('\\catcode`^^^^00a0\\active\\protected\\def^^^^00a0'
|
'utf8extra': ('\\catcode`^^^^00a0\\active\\protected\\def^^^^00a0'
|
||||||
'{\\leavevmode\\nobreak\\ }'),
|
'{\\leavevmode\\nobreak\\ }'),
|
||||||
@ -585,9 +604,15 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
# set up multilingual module...
|
# set up multilingual module...
|
||||||
if self.elements['latex_engine'] == 'pdflatex':
|
if self.elements['latex_engine'] == 'pdflatex':
|
||||||
if 'T2A' in self.elements['fontenc'] and not self.babel.uses_cyrillic():
|
if not self.babel.uses_cyrillic():
|
||||||
self.elements['substitutefont'] = '\\usepackage{substitutefont}'
|
if 'X2' in self.elements['fontenc']:
|
||||||
self.elements['sphinxpkgoptions'] += ',cyrnocyr'
|
self.elements['substitutefont'] = '\\usepackage{substitutefont}'
|
||||||
|
self.elements['textcyrillic'] = ('\\usepackage[Xtwo]'
|
||||||
|
'{sphinxcyrillic}')
|
||||||
|
elif 'T2A' in self.elements['fontenc']:
|
||||||
|
self.elements['substitutefont'] = '\\usepackage{substitutefont}'
|
||||||
|
self.elements['textcyrillic'] = ('\\usepackage[TtwoA]'
|
||||||
|
'{sphinxcyrillic}')
|
||||||
if 'LGR' in self.elements['fontenc']:
|
if 'LGR' in self.elements['fontenc']:
|
||||||
self.elements['substitutefont'] = '\\usepackage{substitutefont}'
|
self.elements['substitutefont'] = '\\usepackage{substitutefont}'
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user