Separate latexmk and pdflatex options for better control

This commit is contained in:
jfbu 2017-05-03 10:45:53 +02:00
parent af76149a2b
commit ca543eee23
4 changed files with 35 additions and 19 deletions

View File

@ -203,15 +203,29 @@ The builder's "name" must be given to the **-b** command-line option of
Use of ``latexmk`` on GNU/Linux or Mac OS X.
Since 1.6, ``make latexpdf`` (or ``make -C "<builddir>/latex"`` after a
run of ``sphinx-build``) uses ``latexmk`` (on GNU/Linux and Mac OS X)
and it invokes it with options ``-f --interaction=nonstopmode``. This
tries to force compilation to PDF even if some types of LaTeX errors
arise. It can be overridden by appending ``LATEXOPTS="<options>"`` to
the command, for example
``LATEXOPTS="--halt-on-error --interaction=nonstopmode"`` will halt on
first LaTeX error, but still report the copious console output from
LaTeX while e.g. ``LATEXOPTS="-silent --halt-on-error"`` would reduce
console output to a minimum.
``sphinx-build`` run) uses ``latexmk`` (on GNU/Linux and Mac OS X).
It invokes it with option ``-f`` which attempts to complete targets
even in case of LaTeX processing errors. This can be overridden via
``LATEXMKOPTS`` variable, for example:
.. code-block:: console
make latexpdf LATEXMKOPTS=""
The ``pdflatex`` calls themselves obey the ``LATEXOPTS`` variable whose
default is ``--interaction=nonstopmode`` (same as ``-interaction
nonstopmode``.) In order to stop the
compilation on first error one can use ``--halt-on-error``.
Example:
.. code-block:: console
make latexpdf LATEXMKOPTS="-silent" LATEXOPTS="--halt-on-error"
In case the first ``pdflatex`` run aborts with an error, this will stop
further ``latexmk`` processing (no ``-f`` option). The console output
will be kept to a bare minimum during target processing (``-silent``).
.. autoattribute:: name

View File

@ -14,8 +14,10 @@ ALLIMGS = $(wildcard *.png *.gif *.jpg *.jpeg)
# Prefix for archive names
ARCHIVEPRREFIX =
# Additional LaTeX options
LATEXOPTS = -f --interaction=nonstopmode
# Additional LaTeX options (used via latexmkrc/latexmkjarc file)
LATEXOPTS = --interaction=nonstopmode
# Additional latexmk options
LATEXMKOPTS = -f
# format: pdf or dvi
FMT = pdf
@ -40,11 +42,11 @@ PDFLATEX = $(LATEX)
{% if latex_engine == 'platex' -%}
%.dvi: %.tex $(ALLIMGS) FORCE_MAKE
for f in *.pdf; do extractbb "$$f"; done
$(LATEX) $(LATEXOPTS) '$<'
$(LATEX) $(LATEXMKOPTS) '$<'
{% elif latex_engine != 'xelatex' -%}
%.dvi: %.tex FORCE_MAKE
$(LATEX) $(LATEXOPTS) '$<'
$(LATEX) $(LATEXMKOPTS) '$<'
{% endif -%}
%.ps: %.dvi
@ -56,7 +58,7 @@ PDFLATEX = $(LATEX)
{%- else -%}
%.pdf: %.tex FORCE_MAKE
{%- endif %}
$(PDFLATEX) $(LATEXOPTS) '$<'
$(PDFLATEX) $(LATEXMKOPTS) '$<'
all: $(ALLPDF)

View File

@ -1,4 +1,4 @@
$latex = 'platex -kanji=utf8 %O %S';
$latex = 'platex $LATEXOPTS -kanji=utf8 %O %S';
$dvipdf = 'dvipdfmx %O -o %D %S';
$makeindex = 'rm -f %D; mendex -U -f -d %B.dic -s python.ist %S || echo "mendex exited with error code $? (ignoring)" && : >> %D';
add_cus_dep( "glo", "gls", 0, "makeglo" );

View File

@ -1,7 +1,7 @@
$latex = 'latex %O %S';
$pdflatex = 'pdflatex %O %S';
$lualatex = 'lualatex %O %S';
$xelatex = 'xelatex --no-pdf %O %S';
$latex = 'latex $LATEXOPTS %O %S';
$pdflatex = 'pdflatex $LATEXOPTS %O %S';
$lualatex = 'lualatex $LATEXOPTS %O %S';
$xelatex = 'xelatex --no-pdf $LATEXOPTS %O %S';
$makeindex = 'makeindex -s python.ist %O -o %D %S';
add_cus_dep( "glo", "gls", 0, "makeglo" );
sub makeglo {