{"action":"created","issue":{"url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/1907","labels_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/1907/labels{/name}","comments_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/1907/comments","events_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/1907/events","html_url":"https://github.com/sphinx-doc/sphinx/issues/1907","id":81965156,"number":1907,"title":"no SVG support in PDFs","user":{"login":"anarcat","id":796623,"avatar_url":"https://avatars.githubusercontent.com/u/796623?v=3","gravatar_id":"","url":"https://api.github.com/users/anarcat","html_url":"https://github.com/anarcat","followers_url":"https://api.github.com/users/anarcat/followers","following_url":"https://api.github.com/users/anarcat/following{/other_user}","gists_url":"https://api.github.com/users/anarcat/gists{/gist_id}","starred_url":"https://api.github.com/users/anarcat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anarcat/subscriptions","organizations_url":"https://api.github.com/users/anarcat/orgs","repos_url":"https://api.github.com/users/anarcat/repos","events_url":"https://api.github.com/users/anarcat/events{/privacy}","received_events_url":"https://api.github.com/users/anarcat/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-28T14:52:08Z","updated_at":"2015-12-11T10:21:55Z","closed_at":null,"body":"Coming from https://github.com/rtfd/readthedocs.org/issues/905 here... it looks like Sphinx doesn't support SVGs properly. Or, more accurately, the LaTeX file it generates asumes that `\\includegraphics` can deal with SVG files: it can't.\r\n\r\nIn LaTeX, SVG images are special: they need to be first converted into another format using Inkscape, and the SVG package. More information about this is available in [this TeX stackexchange question](http://tex.stackexchange.com/questions/122871/include-svg-images-with-the-svg-package), but basically, if a `.svg` file extension is detected, sphinx should generate the following, in the preambule:\r\n\r\n```\r\n\\usepackage{svg}\r\n```\r\n\r\nand instead of `\\includegraphics`, use:\r\n\r\n```\r\n\\includesvg{file}\r\n```\r\n\r\nNotice how the `.svg` file extension should *not* be provided. It may be possible to hack up something to replace the `\\includegraphics{}` directive so it calls `\\includesvg` when there's a `.svg` extension, but i would recommend against that confusing tactic and generate the right directive straight from Sphinx.\r\n\r\nOf course, [Inkscape](http://inkscape.org) needs to be available (in the path, or the path can be specified in the preambule, with `\\usepackage[inkscape={/opt/bin/inkscap‌​e -z -C}]{svg}`) and `--shell-escape` must be passed on the commandline. It may be interesting to allow inkscape parameters to be overridable from the `conf.py` of course.\r\n\r\nA workaround is to generate a PNG file by hand on the side, then include the right file depending on the ouput format:\r\n\r\n```\r\n.. only:: latex\r\n\r\n  .. image:: file.png\r\n\r\n.. only:: html\r\n\r\n  .. image:: file.svg\r\n```\r\n\r\nThen, to generate `file.png`, one could add this to the makefile:\r\n\r\n```\r\n%.pdf: %.svg\r\n    inkscape --without-gui --export-area-drawing --file=$< --export-pdf=$@\r\n```\r\n\r\nYou could also add targets to the makefile to make sure those images are built automatically:\r\n\r\n```\r\nSOURCEDIR     = source\r\n#IMAGEDIRS can be a list of directories that contain SVG files and are relative to the SOURCEDIR\r\nIMAGEDIRS      = _images _images2 ...\r\n\r\nPDFs := $(foreach dir, $(IMAGEDIRS), $(patsubst %.svg,%.pdf,$(wildcard $(SOURCEDIR)/$(dir)/*.svg)))\r\n\r\nimages: $(PDFs)\r\n\r\n# make sure PDFs are cleaned\r\nclean:\r\n    -rm -rf $(BUILDDIR)/*\r\n    -rm $(PDFs)\r\n\r\nlatex: images\r\n    # [...]\r\nlatexpdf: images\r\n    # [...]\r\n```\r\n\r\n(Inspired in part by [this tutorial](https://sites.google.com/site/nickfolse/home/sphinx-latexpdf-output-with-svg-images).)\r\n\r\nBut that's kind of a horrible hack that shouldn't be necessary."},"comment":{"url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/comments/163902622","html_url":"https://github.com/sphinx-doc/sphinx/issues/1907#issuecomment-163902622","issue_url":"https://api.github.com/repos/sphinx-doc/sphinx/issues/1907","id":163902622,"user":{"login":"xuhdev","id":325476,"avatar_url":"https://avatars.githubusercontent.com/u/325476?v=3","gravatar_id":"","url":"https://api.github.com/users/xuhdev","html_url":"https://github.com/xuhdev","followers_url":"https://api.github.com/users/xuhdev/followers","following_url":"https://api.github.com/users/xuhdev/following{/other_user}","gists_url":"https://api.github.com/users/xuhdev/gists{/gist_id}","starred_url":"https://api.github.com/users/xuhdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xuhdev/subscriptions","organizations_url":"https://api.github.com/users/xuhdev/orgs","repos_url":"https://api.github.com/users/xuhdev/repos","events_url":"https://api.github.com/users/xuhdev/events{/privacy}","received_events_url":"https://api.github.com/users/xuhdev/received_events","type":"User","site_admin":false},"created_at":"2015-12-11T10:21:55Z","updated_at":"2015-12-11T10:21:55Z","body":"I've made a PR #2166 to solve this issue. Please check it out if you are interested :)"}}