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

imgmath failed to resolve image path for files in nested folder #10944

Closed
LesleyLai opened this issue Oct 29, 2022 · 4 comments · Fixed by #10965
Closed

imgmath failed to resolve image path for files in nested folder #10944

LesleyLai opened this issue Oct 29, 2022 · 4 comments · Fixed by #10965

Comments

@LesleyLai
Copy link

LesleyLai commented Oct 29, 2022

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.

@jschueller
Copy link
Contributor

jschueller commented Nov 10, 2022

this may be due to #10888
maybe worth adding to 6.0 @AA-Turner

jschueller added a commit to jschueller/sphinx that referenced this issue Nov 10, 2022
jschueller added a commit to jschueller/sphinx that referenced this issue Nov 10, 2022
@jschueller
Copy link
Contributor

jschueller commented Nov 10, 2022

the good news is that you can work around with imgmath_embed = True in conf.py

jschueller added a commit to jschueller/sphinx that referenced this issue Nov 14, 2022
jschueller added a commit to jschueller/sphinx that referenced this issue Dec 2, 2022
@jfbu jfbu added this to the 6.0.0 milestone Dec 2, 2022
@stefanv
Copy link

stefanv commented Dec 2, 2022

Confirmed on 5.3.0

stefanv pushed a commit to scipy-lectures/scientific-python-lectures that referenced this issue Dec 2, 2022
@AA-Turner AA-Turner modified the milestones: 6.0.0, 6.1.0 Dec 29, 2022
jfbu pushed a commit to jschueller/sphinx that referenced this issue Jan 4, 2023
AA-Turner pushed a commit to jschueller/sphinx that referenced this issue Jan 5, 2023
@AA-Turner
Copy link
Member

Fixed in Sphinx 6.0.1

A

akiyks added a commit to akiyks/linux that referenced this issue Jan 9, 2023
The imgmath extension had a regression reported at [1].

This regression is related to the new option: imgmath_embed added
in Sphinx 5.2.0. Enabling the option is an workaround to the issue.

The regression has been fixed since Sphinx 6.0.1, but it should be
reasonable to keep the option afterwards.

Link: [1] sphinx-doc/sphinx#10944
Signed-off-by: Akira Yokosawa <akiyks@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants