Description
Describe the bug
Hi. I am using the sphinx.ext.imgmath plugin to generate images for inline math. The images (of math) are correctly generated in build/html/_images
, but the generated HTML files do not contain correct link to them.
When there are nested files, instead of generating the link (to the image) relative to the file location, the generated links are instead relative to build/html
. For example, say I have a page source/foo/index.rst
that contains math. Instead of generating an image tag as <img src="../_images/math/..."
, Sphinx generate <img src="_images/math/..."
As a result, images of math are not displayed correctly.
This problem seems to be introduced in Sphinx v5.3.0. v5.2.3 does not have this behavior.
How to Reproduce
Create the following 3 files:
index.rst
.. toctree::
:maxdepth: 2
:caption: Contents:
:numbered:
foo/index
foo/index.rst
.. math::
1 + 1
conf.py
project = 'Test'
copyright = '2022, Lesley Lai'
author = 'Lesley Lai'
extensions = ['sphinx.ext.imgmath']
templates_path = ['_templates']
exclude_patterns = []
html_theme = 'alabaster'
html_static_path = ['_static']
Then run the following commands:
$ sphinx-build -M html . _build
$ # open _build/html/foo and see
Environment Information
Platform: win32; (Windows-10-10.0.22623-SP0)
Python version: 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)])
Python implementation: CPython
Sphinx version: 5.3.0
Docutils version: 0.16
Jinja2 version: 3.1.2
Sphinx extensions
sphinx.ext.imgmath
Additional context
To make sphinx.ext.imgmath
work correctly, latex needs to be installed in the system.