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

svg links work in HTML but not in PDF #12096

Open
fabern opened this issue Feb 15, 2025 · 5 comments
Open

svg links work in HTML but not in PDF #12096

fabern opened this issue Feb 15, 2025 · 5 comments
Labels
enhancement New feature or request latex LaTeX engines related libraries and technologies needs-discussion Issues that require a team-wide discussion before proceeding further
Milestone

Comments

@fabern
Copy link

fabern commented Feb 15, 2025

Bug description

A badge in SVG format works in our book when rendering as HTML, but not when rendering as PDF.
Since version 1.3 quarto automatically transform SVG images for PDF output.
This however, appears to work only with local files and no links.

Steps to reproduce

With the following *.qmd file:

---
title: "title"
subtitle: "subtitle"
author: "me, & them"
nocite: |
  @*
format:
  pdf:
    toc: true
    toc-depth: 2
    number-sections: true
    number-depth: 2
    use-rsvg-convert: true
    output-file: "test"
    output-ext:  "pdf"
    # resource-path: ["book/figures/"]
    # linkcolor: RSSblue
    # urlcolor: RSSblue
    # include-in-header: 
    #    - "_styles.tex"
editor: source
---

![DOI](https://zenodo.org/badge/569245031.svg) <!-- NOTE THAT THIS DOES NOT WORK-->
![DOI](book/figures/zenodo.7740560.svg)        <!-- This works -->

Actual behavior

Error message:
Package svg Error: File `569245031_svg-tex.pdf' is missing.

Expected behavior

No response

Your environment

No response

Quarto check output

Quarto 1.4.555
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.11: OK
      Dart Sass version 1.69.5: OK
      Deno version 1.37.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.4.555
      Path: /usr/lib/rstudio/resources/app/bin/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2025.02
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /home/fabian/.TinyTeX/bin/x86_64-linux
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.3
      Path: /usr/bin/python3
      Jupyter: 5.3.2
      Kernels: python3

(|) Checking Jupyter engine render....Traceback (most recent call last):
  File "/usr/lib/rstudio/resources/app/bin/quarto/share/jupyter/jupyter.py", line 21, in <module>
    from notebook import notebook_execute, RestartKernel
  File "/usr/lib/rstudio/resources/app/bin/quarto/share/jupyter/notebook.py", line 18, in <module>
    from nbclient import NotebookClient
ModuleNotFoundError: No module named 'nbclient'
[✓] Checking Jupyter engine render....OK
@fabern fabern added the bug Something isn't working label Feb 15, 2025
@mcanouil
Copy link
Collaborator

mcanouil commented Feb 15, 2025

You are using a pretty old version of Quarto.
Please ensure you have the latest stable version to confirm the issue has been not resolved already?

Side note: if not all the options you've set are not required to reproduce, please don't include them. Only include what's required. This avoid users or us to have to remove them to check the issue does not come from them.
edit: the following seems quite enough, could you confirm on latest Quarto CLI?

---
format: pdf
---

![DOI](https://zenodo.org/badge/569245031.svg) <!-- NOTE THAT THIS DOES NOT WORK-->
![DOI](book/figures/zenodo.7740560.svg)        <!-- This works -->

@fabern
Copy link
Author

fabern commented Feb 15, 2025

Thanks for your answer, so when trying with the stripped down MWE:

---
format: pdf
---

![DOI](https://zenodo.org/badge/569245031.svg) <!-- NOTE THAT THIS DOES NOT WORK-->
![DOI](book/figures/zenodo.7740560.svg)        <!-- This works -->

I get the same error with Quarto 1.5.57 (included in current RStudio), as well as with in the Terminal with the most recent Quarto 1.6.40:

ERROR: 
compilation failed- error
Package svg Error: File `569245031_svg-tex.pdf' is missing.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.160 ...atio]{test_files/mediabag/569245031.svg}}
                                                   

see test.log for more information.

@mcanouil mcanouil added the latex LaTeX engines related libraries and technologies label Feb 15, 2025
@cscheid
Copy link
Collaborator

cscheid commented Feb 19, 2025

Thanks for the report.

I'm not sure I want to fix this, because of reproducibility reasons.

An external image in HTML is something we more or less cannot avoid (even though this is what people call "hot linking" and it's sometimes frowned upon by web admins, since you're technically using their servers to host an image for your document). In a .qmd file that is supposed to render to PDFs, though, I believe we can and should avoid it. The presence of such a link means that the document won't necessarily render consistently from one run to another.

I think the appropriate solution here is for us to warn about such images in the PDF format, and encourage users to write either a project script that downloads the assets as needed, or to do the same thing in a filter.

@cscheid cscheid added needs-discussion Issues that require a team-wide discussion before proceeding further and removed bug Something isn't working labels Feb 19, 2025
@cscheid cscheid added this to the Future milestone Feb 19, 2025
@mcanouil mcanouil added the enhancement New feature or request label Feb 19, 2025
@fabern
Copy link
Author

fabern commented Feb 19, 2025

Thanks for the clarifications! These arguments totally make sense to me.

I solved my rendering by using a local copy. Feel free to close this issue when appropriate.

Note: I assume this affects any image format that is hot linked, not only SVGs.

@cscheid
Copy link
Collaborator

cscheid commented Feb 21, 2025

To make things a bit more complicated, let me note that I recently learned/realized that Quarto does actually fetch .png and .jpg images during a PDF render.

I wish it didn't for the same reasons that I argued above, but the current situation is more fragmented than I thought.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request latex LaTeX engines related libraries and technologies needs-discussion Issues that require a team-wide discussion before proceeding further
Projects
None yet
Development

No branches or pull requests

3 participants