Description
Explain the problem.
Firstly, I just want to mention this is not an issue with pandoc's internal translation of svgs to pdf. That works fine! The issue here is when svgs are outputted into 'latex'.
Consider the following one line markdown document, using this svg:

If we build this by doing:
pandoc pan.md --to latex -o pan.tex -s
pdflatex --shell-escape pan.tex
(--shell-escape is required as we have an svg inside the tex file. The latex svg package will invoke inkscape to render the svg).
Then the output is badly corrupted.
This happens (I think) because the SVG needs to be resized, and the resizing doesn't work correctly due to the setting of Gin
in the \setkeys{Gin}{...}
line of the latex template. I raised this issue with the svg
latex package here: mrpiggi/svg#60 , where I was told setting Gin
in this way isn't supported.
The reason the bad rendering happens at all is by default the latex svg
package extracts text from the svg and renders it using the latex engine. The resizing is messing up the placement of this text.
This could be fixed by setting inkscapelatex
in the svg
package to false. This makes the svg latex package just render the svg to a single PDF and everything works fine. This would stop text in SVGs being rendered as latex, if anyone was using that functionality (they can of course get it back by editing the template).
The other option would be to disable auto-resizing, but that would effect all images (not just svg), and be much worse (as large pictures would overflow the page).
This problem was originally found as an issue in quarto, which does this two-step pass of using pandoc to turn markdown -> tex, then compiling the resulting tex.
Pandoc version?
Ubuntu 23.04
pandoc 3.1.13
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/caj/.local/share/pandoc