[Tex/LaTex] Why is SVG not supported by the TeX backend

svgtex-core

I've always wondered why SVG is such a problem for many document creation tools. For example MS Office can't do it, Libre Office can only use very simple SVGs afaik and even in Latex we can't use them properly, but they have to be converted, either manually and then be used as bitmap graphics or automatically by external tools like InkScape. While I like InkScape, this is not satisfying.

Especially from Latex or TeX I'd have expected SVG support, since so many people in the academic world use it directly or indirectly and with so much attention to the detail, that it seems strange to have to go such a workaround way of including SVG in a work. It would be so nice to have a PDF with unlimited zoom and still sharp distinct lines in a diagram for example, instead of some pixelated line, because the SVG was converted before used in the PDF.

So how come we still don't have SVG support in the TeX backend? Would it be so very hard to implement?

I don't know much about the TeX backend, basically only that it exists and converts your stuff into a PDF file, so this question might be naive. On the other hand, you have SVG support in every browser and almost every image viewer software out there, so I think it should be possible to have that. Maybe it's about the PDF format itself not supporting inclusion of SVGs, so that it doesn't make sense to change the TeX backend to allow SVGs, until the PDF format changed?

Best Answer

Classically TeX does not deal with any graphics formats, the dvi file file just contains a pointer to a graphics file to be included by the dvi driver. TeX just needs to know the space to leave, which it can read from a BoundingBox comment or from optional arguments in \includegraphics.

It is (usually) much easier to include a graphics format if it is the format that you are generating for the document, as the dvi driver doesn't need to "understand them", just copy into the stream, so for example dvips can include EPS files as they are just copied literally to the output, similarly jpg files, and certain bitmap formats that can more or less trivially be converted to PostScript bitmaps.

The situation with pdftex is similar except that it can not handle EPS files but can handle PDF files again because it is much easier to handle PDf if you are writing PDF.

To handle EPS in pdftex you need an external EPS to PDF translation program, which may be called by shell-escape from TeX, but is conceptually (and in fact) quite separate.

The situation with SVG is just the same. If you are producing svg (eg dvisvgm dvi driver) it is easier to include SVG than EPS or PDF, if on the other hand you are producing PostScript or PDF then you need a conversion program, usually incscape, in the loop. Again this may be hidden behind a shell-escape and called from TeX if needed. You should however convert the SVG to a scalable format (PDF or EPS) not to a bitmap, if the final aim is to include into PDF document.

Related Question