Skip to content

Commit

Permalink
Merge pull request #6841 from tk0miya/4186_uplatex
Browse files Browse the repository at this point in the history
Fix #4186: LaTeX: Support upLaTeX as a new latex_engine (experimental)
  • Loading branch information
tk0miya committed Nov 20, 2019
2 parents c9236df + c6f0eb2 commit cba9ff9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Features added
* #1331: Add new config variable: :confval:`user_agent`
* #6000: LaTeX: have backslash also be an inline literal word wrap break
character
* #4186: LaTeX: Support upLaTeX as a new :confval:`latex_engine` (experimental)
* #6812: Improve a warning message when extensions are not parallel safe
* #6818: Improve Intersphinx performance for multiple remote inventories.
* #2546: apidoc: .so file support
Expand Down
5 changes: 5 additions & 0 deletions doc/usage/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@ These options influence LaTeX output.
* ``'xelatex'`` -- XeLaTeX
* ``'lualatex'`` -- LuaLaTeX
* ``'platex'`` -- pLaTeX (default if :confval:`language` is ``'ja'``)
* ``'uplatex'`` -- upLaTeX (experimental)

``'pdflatex'``\ 's support for Unicode characters is limited.

Expand All @@ -1861,6 +1862,10 @@ These options influence LaTeX output.

Use ``xelatex`` by default for Greek documents.

.. versionchanged:: 2.3

Add ``uplatex`` support.

Contrarily to :ref:`MathJaX math rendering in HTML output <math-support>`,
LaTeX requires some extra configuration to support Unicode literals in
:rst:dir:`math`: the only comprehensive solution (as far as we know) is to
Expand Down
10 changes: 7 additions & 3 deletions sphinx/builders/latex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,12 @@ def default_latex_engine(config: Config) -> str:
def default_latex_docclass(config: Config) -> Dict[str, str]:
""" Better default latex_docclass settings for specific languages. """
if config.language == 'ja':
return {'manual': 'jsbook',
'howto': 'jreport'}
if config.latex_engine == 'uplatex':
return {'manual': 'ujbook',
'howto': 'ujreport'}
else:
return {'manual': 'jsbook',
'howto': 'jreport'}
else:
return {}

Expand Down Expand Up @@ -456,7 +460,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.connect('config-inited', validate_config_values)

app.add_config_value('latex_engine', default_latex_engine, None,
ENUM('pdflatex', 'xelatex', 'lualatex', 'platex'))
ENUM('pdflatex', 'xelatex', 'lualatex', 'platex', 'uplatex'))
app.add_config_value('latex_documents', default_latex_documents, None)
app.add_config_value('latex_logo', None, None, [str])
app.add_config_value('latex_appendices', [], None)
Expand Down
6 changes: 3 additions & 3 deletions sphinx/texinputs/Makefile_t
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ XINDYOPTS += -M LatinRules.xdy
# format: pdf or dvi (used only by archive targets)
FMT = pdf

{% if latex_engine == 'platex' -%}
{% if latex_engine in ('platex', 'uplatex') -%}
# latexmkrc is read then overridden by latexmkjarc
LATEX = latexmk -r latexmkjarc -dvi
PDFLATEX = latexmk -r latexmkjarc -pdfdvi -dvi- -ps-
Expand All @@ -49,7 +49,7 @@ PDFLATEX = latexmk -pdf -dvi- -ps-
%.png %.gif %.jpg %.jpeg: FORCE_MAKE
extractbb '$@'

{% if latex_engine == 'platex' -%}
{% if latex_engine in ('platex', 'uplatex') -%}
%.dvi: %.tex $(ALLIMGS) FORCE_MAKE
for f in *.pdf; do extractbb "$$f"; done
$(LATEX) $(LATEXMKOPTS) '$<'
Expand All @@ -62,7 +62,7 @@ PDFLATEX = latexmk -pdf -dvi- -ps-
%.ps: %.dvi
dvips '$<'

{% if latex_engine == 'platex' -%}
{% if latex_engine in ('platex', 'uplatex') -%}
%.pdf: %.tex $(ALLIMGS) FORCE_MAKE
for f in *.pdf; do extractbb "$$f"; done
{%- else -%}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$latex = 'platex ' . $ENV{'LATEXOPTS'} . ' -kanji=utf8 %O %S';
$latex = '{{ latex_engine }} ' . $ENV{'LATEXOPTS'} . ' -kanji=utf8 %O %S';
$dvipdf = 'dvipdfmx %O -o %D %S';
$makeindex = 'internal mendex %S %B %D';
sub mendex {
Expand Down
9 changes: 9 additions & 0 deletions sphinx/writers/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,15 @@
'fncychap': '',
'geometry': '\\usepackage[dvipdfm]{geometry}',
},
'uplatex': {
'latex_engine': 'uplatex',
'babel': '',
'classoptions': ',dvipdfmx',
'fontpkg': '\\usepackage{times}',
'textgreek': '',
'fncychap': '',
'geometry': '\\usepackage[dvipdfm]{geometry}',
},

# special settings for latex_engine + language_code
('xelatex', 'fr'): {
Expand Down

0 comments on commit cba9ff9

Please sign in to comment.