From 1d9eeedde306cfb013850b4621c32cdd47e46bff Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 29 Nov 2020 14:49:44 +0900 Subject: [PATCH] Fix #8508: LaTeX: uplatex becomes a default setting of latex_engine for Japanese Since v2.3, Sphinx supports uplatex as an alternative of latex_engine for Japanese docs (refs: #4186, #6841). uplatex is able to build a document without conversion character encoding internally. It allows using unicode characters in documents. Additionally, uplatex is compatible with platex (current default latex_engine for Japanese docs). This changes the default latex_engine for Japanese document to uplatex. --- CHANGES | 2 ++ doc/usage/configuration.rst | 8 ++++++-- sphinx/builders/latex/__init__.py | 2 +- tests/test_build_latex.py | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 1386ff49057..1cee5375d3c 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,8 @@ Incompatible changes :confval:`man_make_section_directory`) * #8380: html search: search results are wrapped with ``

`` instead of ``

`` +* #8508: LaTeX: uplatex becomes a default setting of latex_engine for Japanese + documents Deprecated ---------- diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 13dd6623ca8..f69aa529bc6 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -1903,8 +1903,8 @@ These options influence LaTeX output. * ``'pdflatex'`` -- PDFLaTeX (default) * ``'xelatex'`` -- XeLaTeX * ``'lualatex'`` -- LuaLaTeX - * ``'platex'`` -- pLaTeX (default if :confval:`language` is ``'ja'``) - * ``'uplatex'`` -- upLaTeX (experimental) + * ``'platex'`` -- pLaTeX + * ``'uplatex'`` -- upLaTeX (default if :confval:`language` is ``'ja'``) ``'pdflatex'``\ 's support for Unicode characters is limited. @@ -1934,6 +1934,10 @@ These options influence LaTeX output. Add ``uplatex`` support. + .. versionchanged:: 4.0 + + ``uplatex`` becomes the default setting of Japanese documents. + Contrarily to :ref:`MathJaX math rendering in HTML output `, LaTeX requires some extra configuration to support Unicode literals in :rst:dir:`math`: the only comprehensive solution (as far as we know) is to diff --git a/sphinx/builders/latex/__init__.py b/sphinx/builders/latex/__init__.py index f034e552b7b..5d19d5e7bf2 100644 --- a/sphinx/builders/latex/__init__.py +++ b/sphinx/builders/latex/__init__.py @@ -482,7 +482,7 @@ def install_packages_for_ja(app: Sphinx) -> None: def default_latex_engine(config: Config) -> str: """ Better default latex_engine settings for specific languages. """ if config.language == 'ja': - return 'platex' + return 'uplatex' elif (config.language or '').startswith('zh'): return 'xelatex' elif config.language == 'el': diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py index 5dfc3b7a85a..6c753d6c1c1 100644 --- a/tests/test_build_latex.py +++ b/tests/test_build_latex.py @@ -197,7 +197,7 @@ def test_latex_basic_manual_ja(app, status, warning): app.builder.build_all() result = (app.outdir / 'test.tex').read_text(encoding='utf8') print(result) - assert r'\def\sphinxdocclass{jsbook}' in result + assert r'\def\sphinxdocclass{ujbook}' in result assert r'\documentclass[letterpaper,10pt,dvipdfmx]{sphinxmanual}' in result @@ -210,7 +210,7 @@ def test_latex_basic_howto_ja(app, status, warning): app.builder.build_all() result = (app.outdir / 'test.tex').read_text(encoding='utf8') print(result) - assert r'\def\sphinxdocclass{jreport}' in result + assert r'\def\sphinxdocclass{ujreport}' in result assert r'\documentclass[letterpaper,10pt,dvipdfmx]{sphinxhowto}' in result