Select best image format using pandoc
Asked Answered
E

1

7

Pandoc can easily render the same source file to html or LaTeX and then pdf. In many cases, I'd like to use different versions of the same image file depending on which backend is being used: When the original "image" is a vector figure, possibly containing text (e.g. PostScript, PDF, maybe SVG), I'd like to use that version to generate LaTeX and PDF, so there's not loss of quality. But browsers don't generally render those well, so I'd like to generate and use a raster (e.g. PNG) image when generating HTML.

Is there any way to do this in Pandoc? What I was hoping would "just work" was something like the \includegraphics{} LaTeX macro where, if you provide the filename with no extension, it identifies all the image files matching that stem and applies some heuristic to pick the best option.

Ellaelladine answered 12/12, 2017 at 21:26 Comment(1)
modern browsers render SVG just fine... see also github.com/jgm/pandoc/wiki/Pandoc-Filters#written-filters (e.g. the pandoc-svg filter)Purslane
F
3

You could call pandoc with --default-image-extension=png when generating html, and --default-image-extension=pdf (or whichever other extension you use) when generating the pdf. See

https://pandoc.org/MANUAL.html#reader-options

Filmdom answered 20/6, 2021 at 8:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.