Skip to content

Commit 679b4bc

Browse files
akiyksJonathan Corbet
authored andcommitted
docs/doc-guide: Add documentation on SPHINX_IMGMATH
Now that building html docs with math expressions does not need texlive packages, remove the note on the requirement in the "Sphinx Install" section. Instead, add sections of "Math Expressions in HTML" and "Choice of Math Renderer". Describe the effect of setting SPHINX_IMGMATH in the latter section. Signed-off-by: Akira Yokosawa <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Cc: Randy Dunlap <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Corbet <[email protected]>
1 parent 2f99350 commit 679b4bc

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

Documentation/doc-guide/sphinx.rst

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ or ``virtualenv``, depending on how your distribution packaged Python 3.
4848
on the Sphinx version, it should be installed separately,
4949
with ``pip install sphinx_rtd_theme``.
5050

51-
#) Some ReST pages contain math expressions. Due to the way Sphinx works,
52-
those expressions are written using LaTeX notation. It needs texlive
53-
installed with amsfonts and amsmath in order to evaluate them.
54-
5551
In summary, if you want to install Sphinx version 2.4.4, you should do::
5652

5753
$ virtualenv sphinx_2.4.4
@@ -86,6 +82,27 @@ Depending on the distribution, you may also need to install a series of
8682
``texlive`` packages that provide the minimal set of functionalities
8783
required for ``XeLaTeX`` to work.
8884

85+
Math Expressions in HTML
86+
------------------------
87+
88+
Some ReST pages contain math expressions. Due to the way Sphinx works,
89+
those expressions are written using LaTeX notation.
90+
There are two options for Sphinx to render math expressions in html output.
91+
One is an extension called `imgmath`_ which converts math expressions into
92+
images and embeds them in html pages.
93+
The other is an extension called `mathjax`_ which delegates math rendering
94+
to JavaScript capable web browsers.
95+
The former was the only option for pre-6.1 kernel documentation and it
96+
requires quite a few texlive packages including amsfonts and amsmath among
97+
others.
98+
99+
Since kernel release 6.1, html pages with math expressions can be built
100+
without installing any texlive packages. See `Choice of Math Renderer`_ for
101+
further info.
102+
103+
.. _imgmath: https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.imgmath
104+
.. _mathjax: https://www.sphinx-doc.org/en/master/usage/extensions/math.html#module-sphinx.ext.mathjax
105+
89106
.. _sphinx-pre-install:
90107

91108
Checking for Sphinx dependencies
@@ -164,6 +181,38 @@ To remove the generated documentation, run ``make cleandocs``.
164181
as well would improve the quality of images embedded in PDF
165182
documents, especially for kernel releases 5.18 and later.
166183
184+
Choice of Math Renderer
185+
-----------------------
186+
187+
Since kernel release 6.1, mathjax works as a fallback math renderer for
188+
html output.\ [#sph1_8]_
189+
190+
Math renderer is chosen depending on available commands as shown below:
191+
192+
.. table:: Math Renderer Choices for HTML
193+
194+
============= ================= ============
195+
Math renderer Required commands Image format
196+
============= ================= ============
197+
imgmath latex, dvipng PNG (raster)
198+
mathjax
199+
============= ================= ============
200+
201+
The choice can be overridden by setting an environment variable
202+
``SPHINX_IMGMATH`` as shown below:
203+
204+
.. table:: Effect of Setting ``SPHINX_IMGMATH``
205+
206+
====================== ========
207+
Setting Renderer
208+
====================== ========
209+
``SPHINX_IMGMATH=yes`` imgmath
210+
``SPHINX_IMGMATH=no`` mathjax
211+
====================== ========
212+
213+
.. [#sph1_8] Fallback of math renderer requires Sphinx >=1.8.
214+
215+
167216
Writing Documentation
168217
=====================
169218

0 commit comments

Comments
 (0)