Repository navigation
Description
Bug description
When generating HTML, PDF and DOCX formats from the same document which includes a SVG image, PDF generation fails. If generating only HTML and PDF, then all three outputs succeed.
Here is a minimal project which demonstrates the issue:
The archive contains three files: a simple _quarto.yml, a SVG image and a simple document which references the image. If you run quarto render in the directory where you extract this archive, PDF generation will fail with the following error:
ERROR:
compilation failed- error
Unable to load picture or PDF file 'quazz_files/mediabag/piechart.pdf'.
<to be read again>
}
l.169 ...eight]{quazz_files/mediabag/piechart.pdf}
see /Users/igor/Gliwa/tmp/quazz/quazz.log for more information.
ERROR: Error
at renderFiles (file:///Applications/quarto/bin/quarto.js:78081:29)
at eventLoopTick (ext:core/01_core.js:153:7)
at async renderProject (file:///Applications/quarto/bin/quarto.js:78479:25)
at async Command.actionHandler (file:///Applications/quarto/bin/quarto.js:83077:32)
at async Command.execute (file:///Applications/quarto/bin/quarto.js:8017:13)
at async Command.parseCommand (file:///Applications/quarto/bin/quarto.js:7907:20)
at async quarto (file:///Applications/quarto/bin/quarto.js:118224:9)
at async file:///Applications/quarto/bin/quarto.js:118244:9
at async mainRunner (file:///Applications/quarto/bin/quarto.js:118128:9)
at async file:///Applications/quarto/bin/quarto.js:118235:5
If you now modify _quarto.yml and remove DOCX from output formats (remove or comment out the docx: {} line), PDF generation will succeed. I haven't tested them all, but I think you can use any format instead of docx to demonstrate the issue.
What I believe happens here is that Quarto (or Pandoc) use rsvg-convert to convert the SVG image to PDF. This succeeds and the resulting image is placed in quazz_files/mediabag/piechart.pdf. Pandoc generates a Tex file referencing that image. Now Quarto manages to delete that file (in fact it deletes the entire mediabag subdirectory) before Latex processes Pandoc's output. Latex then fails to find the referenced PDF image.
This only happens with SVG images. PNG images for example go fine. It also only happens if more than HTML and PDF output formats are listed in _quarto.yml.
Rendering to PDF on its own with quarto render --to pdf will succeed even if extra formats are specified in _quarto.yml. Ony rendering them all together with quarto render fails.
Am I doing something wrong?
Steps to reproduce
To reproduce this without the archive attached above, follow these steps:
- Create a Quarto project with default type using
quarto create project default . quazz --no-open. This will generate two files in the current directory named_quarto.ymlandquazz.qmd. - Find any SVG image and save it as
piechart.svg. - Put this in
quazz.qmd:
---
title: "quazz"
---
This is a symbol of a pie chart in SVG:
{width=20%}
That is it.- Put this in
_quarto.yml:
project:
title: "quazz"
format:
html: {}
pdf: {}
docx: {}- Run
quarto render
Expected behavior
Expected is generation of three output documents as specified in _quarto.yml.
Actual behavior
PDF generation fails with an error.
Your environment
- IDE: VIM, but not relevant. Any text editor will do.
- OS: macOS Sequoia 15.0
Quarto check output
Quarto 1.5.57
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.2.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.5.57
Path: /Applications/quarto/bin
[✓] Checking tools....................OK
TinyTeX: v2024.09
Chromium: 869685
[✓] Checking LaTeX....................OK
Using: TinyTex
Path: /Users/igor/Library/TinyTeX/bin/universal-darwin
Version: 2024
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.12.6
Path: /usr/local/opt/[email protected]/bin/python3.12
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with python3 -m pip install jupyter
[✓] Checking R installation...........OK
Version: 4.4.1
Path: /Library/Frameworks/R.framework/Resources
LibPaths:
- /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/library
knitr: (None)
rmarkdown: (None)
The knitr package is not available in this R installation.
Install with install.packages("knitr")
The rmarkdown package is not available in this R installation.
Install with install.packages("rmarkdown")
Activity
mcanouil commentedon Sep 29, 2024
Where did you see the following?
That is quite not pretty.
You should use
defaultwhich is clearer than{}.This being said, I can reproduce using a simpler example.
Thanks for the report.
quarto render index.qmd --to allleads to an error.docx: default(or change the order) andquarto render index.qmd --to allworks.Somehow, the temporary files seems to be wrongly deleted or at least not at the right time.
The following with
docxas first format also works:zlatkig commentedon Oct 1, 2024
Sorry for the ugly curlies
{}. That was me in attempt to satisfy data type requirements in this particular example and not thinking in the process. In production I have actual options there overriding the defaults or adding to them.Changing the order and putting
pdfformat last leads to a working construct. That confirms that I didn't think far enough. I really should have been able to come up with that workaround on my own. This workaround solves my particular use case.Nevertheless, this led me to investigate the
typstformat. I found thattypstandpdfcannot be generated at the same time and that doesn't seem to be by design.The use case for that would be migration from LaTeX to Typst for PDF generation. Potentially complex LaTeX templates cannot be reused, new ones must be created from scratch. It would help to have both outputs available during transition to compare them.
The formats
typstandpdfhave the same output file by default and one of them must be renamed. I attempted to do this usingoutput-extoption. This leads to errors which are not observable without this option. Is that generally a wrong way and if not, would this be a topic for a separate issue report? I fail to find an issue already dealing with this and that is often a sign for me doing something wrong (or not searching deep enough).mcanouil commentedon Oct 1, 2024
Your last comment is unrelated to this thread in most parts.
Use
output-fileto have different file names.(There are several discussions about this, as revealjs/html also have the same issue of sharing the same file extension).
cderv commentedon Oct 1, 2024
I believe this issue is similar to others on mediabag cleaning happening to soon in the rendering process when multiple format.
This is a direct duplicate of:
and probably others, so I'll close this one and will follow up in the other.
Workaround for now. change the order. Doing docx before pdf will work.
cderv commentedon Oct 1, 2024
Duplicate of #8373