This question is now almost ten years old and a lot has changed since it was asked. The canonical – and easiest – way to include
svg drawings in LaTeX nowadays is the
svg package. This has been mentioned in previous answers, but the information there is outdated or incomplete. I will try to give a concise summary of the necessary setup and process here.
svg package relies on Inkscape as a backend to convert the
svg drawing into a
pdf file containing everything but text and a
tex file (with the file extension
pdf_tex) with code to include all the pages in the
pdf and place the omitted text on the picture. Instead of
\includegraphics you use
\includesvg to place the drawing in your document. When you do, the package checks if the
pdf_tex files need to be (re)generated (if they don't exist or if the drawing has been modified since they were last generated). If so, it automatically calls Inkscape, generated the files and includes them. (In order not to clutter your directory, the
svg package creates a folder called
svg-inkscape for these files.) In effect, this places the current version of your drawing in the document.
There are two prerequisits for this to work:
- Inkscape needs to be installed and in the system path.
- LaTeX needs to be run with shell escape enabled.
Enabling shell escape
Enabling shell escape (also known as
\write18) allows TeX to call external programs (cf. this question). You enable it by calling LaTeX with the option
--shell-escape. If your editor calls LaTeX for you, you have to add this option in the editor's preferences. (Note that doing so comes with a certain risk if you run foreign documents on your machine.)
If you use TeXstudio, you can also enable shell escape for single documents (and mitigate the aforementioned risk) using magic comments. For example, insert
% !TeX TXS-program:compile = txs:///pdflatex/[--shell-escape]
at the top of your document in order to compile it with
pdflatex and shell escape enabled. TeXstudio will prompt you the first time you compile after this and you can allow it for that document only.
Getting Inkscape into the search path
On Linux (and MacOS, I think), Inkscape is automatically added to the system's search path during installation. On Windows, you have to do this manually. You can check if Inkscape is in the path by opening a command line (e.g. by right-clicking on the Windows button and selecting
Windows PowerShell) and executing
inkscape (type it and press enter). If Inkscape is in the path, it will open, otherwise you will get an error.
Ok, so how do you add Inkscape to the search path? First, you have to finde the directory where the Inkscape executable is located. By default, this is
C:\Program Files\Inkscape. Then you have to add this directory to the path variable. Open the Windows Settings and navigate to
System info →
Advanced system settings →
Environment Variables. Now double click on
Path in the list of System variables (for all users) or User variables (just for you). Click
New, paste the directory of the Inkscape executable and press enter. Then press
OK on the three open dialogues. Done.
You may have to restart your LaTeX editor or command line for the change to take effect.
You can test if your setup works with this MWE
provided you have a
drawing.svg in the document's directory, for example this one:
<?xml version="1.0" encoding="UTF-8"?>
<svg width="96.725mm" height="50.327mm" version="1.1" viewBox="0 0 96.725 50.327" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<g transform="translate(-27.689 -45.179)">
<path d="m100.09 88.093-6.259-9.7729-10.235 5.4701 3.7384-10.987-10.658-4.5917 10.921-3.9274-3.0554-11.196 9.8795 6.0894 6.8483-9.3694 1.3988 11.521 11.595-0.48748-8.1351 8.2767 7.6106 8.7615-11.543-1.1998z" fill="#ff0808"/>
<text x="83.593781" y="83.789787" fill="#000000" font-family="'CMU Serif'" font-size="12.7px" letter-spacing="0px" stroke-width=".26458" text-align="end" text-anchor="end" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="83.593781" y="83.789787" font-size="3.8806px" stroke-width=".26458" text-align="end" text-anchor="end">This is a test for testing.</tspan></text>