Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Latexmk in a more efficient way for 'xelatex' as latex_engine #12636

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ Deprecated
Features added
--------------

* #12636: LaTeX: possibly faster builds with ``'xelatex'`` from modernized
invocation of :program:`Latexmk` (backward compatible).

Bugs fixed
----------

Expand Down
4 changes: 0 additions & 4 deletions doc/usage/builders/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ The most common builders are:

reduces console output to a minimum.

Also, if ``latexmk`` is at version 4.52b or higher (January 2017)
``LATEXMKOPTS="-xelatex"`` speeds up PDF builds via XeLateX in case
of numerous graphics inclusions.

To pass options directly to the ``(pdf|xe|lua)latex`` binary, use
variable ``LATEXOPTS``, for example:

Expand Down
21 changes: 16 additions & 5 deletions sphinx/texinputs/Makefile.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ALLDOCS = $(basename $(wildcard *.tex))
ALLPDF = $(addsuffix .pdf,$(ALLDOCS))
{% if latex_engine == 'xelatex' -%}
ALLDVI =
# but we do not know a way to let Latexmk produce the .xdv files
# as final targets, only as left-overs from a .pdf build
ALLXDV = $(addsuffix .xdv,$(ALLDOCS))
{% else -%}
ALLDVI = $(addsuffix .dvi,$(ALLDOCS))
Expand All @@ -16,10 +18,6 @@ ARCHIVEPREFIX =
# Additional LaTeX options (passed via variables in latexmkrc/latexmkjarc file)
export LATEXOPTS ?=
# Additional latexmk options
{% if latex_engine == 'xelatex' -%}
# with latexmk version 4.52b or higher set LATEXMKOPTS to -xelatex either here
# or on command line for faster builds.
{% endif -%}
LATEXMKOPTS ?=
{% if xindy_use -%}
export XINDYOPTS = {{ xindy_lang_option }} -M sphinx.xdy
Expand All @@ -40,9 +38,22 @@ FMT = pdf
# latexmkrc is read then overridden by latexmkjarc
LATEX = latexmk -r latexmkjarc -dvi
PDFLATEX = latexmk -r latexmkjarc -pdfdvi -dvi- -ps-
{% else -%}
{% endif -%}
{% if latex_engine == 'pdflatex' -%}
LATEX = latexmk -dvi
PDFLATEX = latexmk -pdf -dvi- -ps-
{% endif -%}
{% if latex_engine == 'xelatex' -%}
# No LATEX as it is used for .dvi targets which xelatex can't produce.
# The -pdf is not needed with current (2024) Latexmk but may have been
# in the distant past. It doesn't hurt.
PDFLATEX = latexmk -pdf -xelatex
{% endif -%}
{% if latex_engine == 'lualatex' -%}
LATEX = latexmk -dvilua
# The -pdf is not needed with current (2024) Latexmk but may have been
# in the distant past. It doesn't hurt.
PDFLATEX = latexmk -pdf -lualatex
{% endif %}

{% if latex_engine != 'xelatex' -%}
Expand Down