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
Figures go missing from latex pdf if their files have the same base name and they use a post transform #11110
Comments
I found a way to fix the issue, but I'm not savvy about this project so I have no idea if it would be a reasonable fix or not. Either way, here is the commit from my fork, in case someone here finds that helpful. |
Good catch! I could reproduce this issue with
with So this is a really long-standing issue... I will do some more testing. |
@aaron-cooper could you please make a PR with your patch? I used it in the diff --git a/sphinx/transforms/post_transforms/images.py b/sphinx/transforms/post_transforms/images.py
index 1871a0f9c..410de82f0 100644
--- a/sphinx/transforms/post_transforms/images.py
+++ b/sphinx/transforms/post_transforms/images.py
@@ -236,7 +236,7 @@ class ImageConverter(BaseImageConverter):
else:
srcpath = node['candidates']['*']
- filename = get_filename_for(srcpath, _to)
+ filename = get_filename_for(self.env.images[srcpath][1], _to)
ensuredir(self.imagedir)
destpath = os.path.join(self.imagedir, filename)
shape. It appears to work fine. Sadly I am not much familiar with this myself. Recently we have merged some changes with completely unrelated: in modifying a bit the test so that multiple
warning which is amply commented as a tex.sx question. There is no such warning with |
Describe the bug
I'm trying to build a pdf from a document that contains some svg images. The images have identical names, but reside in different directories. I use
sphinxcontrib.rsvgconverter
from sphinxcontrib-svg2pdfconverter to convert them from svg to pdf.When multiple svg images with the same base name are passed to
rsvgconverter.convert
, the destination path for both images is identical, therefore all but the last image is discarded when it is overwritten by a subsequent transformation.The result is that the final pdf will have the last converted svg repeated several times instead of each svg appearing when it is supposed to.
How to Reproduce
Here is a repo containing some code that reproduces the issue.
The file foo_expected.pdf (github doesn't show the full content of the pdf, remember to click "more pages" I guess...) shows what I would expect the output to be, and foo_actual.pdf shows what it actually is. Notice that the two identically named png files are shown correctly in foo_actual.pdf, but for the two svg's a red circle is shown twice, instead of a black circle and then a red circle.
Environment Information
Sphinx extensions
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: