Skip to content

Commit 6f71c7b

Browse files
committed
ext/imgmath: batch LaTeX compilation via pre-rendering
Add ``imgmath_batch_size`` config option (default 1). When greater than 1, equations are collected on ``env-updated`` and compiled into multi-page DVI documents before writing, reducing N LaTeX processes to ceil(N/B), then split via ``dvipng -pp`` / ``dvisvgm --page``. Filenames, embed mode, depth handling, and error reporting match single-equation mode. Batching is disabled when a custom ``template.tex``/``preview.tex`` template is detected.
1 parent e44a40e commit 6f71c7b

3 files changed

Lines changed: 414 additions & 5 deletions

File tree

doc/usage/extensions/math.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ are built:
190190

191191
.. versionadded:: 5.2
192192

193+
.. confval:: imgmath_batch_size
194+
:type: :code-py:`int`
195+
:default: :code-py:`1`
196+
197+
Number of math expressions to compile in a single LaTeX invocation.
198+
When greater than 1, equations are collected after reading and
199+
compiled into multi-page DVI documents before writing,
200+
reducing *N* LaTeX processes to *ceil(N / batch_size)*.
201+
Batching is disabled when a custom ``template.tex``/``preview.tex``
202+
template is detected.
203+
204+
.. versionadded:: 9.2
205+
193206
:mod:`sphinx.ext.mathjax` -- Render math via JavaScript
194207
-------------------------------------------------------
195208

0 commit comments

Comments
 (0)