Skip to content

Vector Graphics with Inkscape

Wilhelm Burger edited this page Jan 11, 2023 · 10 revisions

What?

Inkscape is a good and free alternative for creating vector graphics. Inkscape's default format is SVG, but after exporting to PDF, such pictures can be inserted into LaTeX the usual way with \includegraphics[..]{..}.

An interesting option is automatically replacing text within the graphic with LaTeX. This way, the same (TeX) fonts as in the body text and replaced mathematical elements are used in the finished graphic.

How?

Download and install the latest version of Inkscape and generate your desired image.

The original Inkscape graphic, e.g., inkscape-template.svg, contains text that LaTeX should replace, such as mathematical expressions.

The original Inkscape image with text that is to be replaced.
The original image created in Inkscape. The font and mathematical expressions will be replaced later.

To export a file that can be included in LaTeX, call Save a Copy... (as PDF) in Inkscape and use the following settings:

The settings for exporting a PDF file in Inkscape.
The settings for exporting a PDF file in Inkscape.

This generates the following two files (note that both files are required):

  • inkscape-template.pdf: a PDF file of the graphic without text,
  • inkscape-template.pdf_tex: a LaTeX file with all relevant information.

Finally, include the image in your document with \input{images/inkscape-template.pdf_tex}. This will produce the following result:

The image as rendered in LaTeX.
The final image, as displayed in the LaTeX document.

Where?

Replaced images will occur in your regular chapter documents. Place the two files exported by Inkscape in your images folder or create a separate directory if you expect many such files. The original SVG file is not needed when generating the LaTeX document.

Package Information

Creating images with Inkscape does not require any additional LaTeX packages. More details can be found in this document.

Supplemental Materials

Try out this feature in a sample document on Overleaf: https://www.overleaf.com/read/gvctwpcyrfpm

Clone this wiki locally