Using Inkscape for LaTeX Documents

This tutorial shows you how to use Inkscape for editing or creating .eps or .ps graphics that can then be imported into your LaTeX Document. You will need:

  1. Inkscape 0.46 (you may try other versions too)
  2. TexText 0.4.4 (Inkscape LaTeX plugin), can be found in this site.
  3. Python 2.5 (or higher) that is used by TexText. TexText can still be used without Python, but it will apparently have limited functionality.
  4. MikTeX and all other LaTeX necessities

First let me explain a little why we are using Inkscape. Inkscape edit’s and creates svg documents. SVG format for Inkscape is an XML-based vector-graphic format and it has the following advantage:

  1. Diffing and merging different versions of .svg is easier than a binary format like .jpg (so if you use a repository like svn, you can easily differentiate the different versions of your graphics)
  2. Resolution of svg graphics is transform-invariant. This means, unless the svg file has a binary picture imbedded into it, the graphic resolution (for both printing and viewing) is unaffected from scaling, shearing, and other form of transformation.
  3. Inkscape has the ability to save as .ps and .eps which are format used in LaTeX to include graphics

Having said that, here is a simple example on how you can use Inkscape in a LaTeX document:

  1. Install all the necessary programs
  2. Do your Vector-Graphic drawing.
  3. If you need to import a .jpg or other binary image go to File->Import and choose the image
    • Note: There are two ways images can be embedded into an .svg file. One is by being referenced in the .svg file itself. The reference in the .svg file will then look like this:
      <image
             y="191.29076"
             x="260"
             id="image5237"
             height="345"
             width="360"
             sodipodi:absref="C:\Documents and Settings\jcapco\Desktop\work\sauggreifer.jpg"
             xlink:href="sauggreifer.jpg" />
      

      Another is by being embedded internally. If .svg are versioned (i.e. constantly being updated), it is recommended to have it embedded as a reference. You can have the image embedded into your svg by going into Effects -> Images -> Embed All Images.. Then the svg is saved without a referencing, it will still be a XML-based (text) file. But for the image we have a base-64 encoding:

      <image
             xlink:href="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4QAMTmVvR2VvCAAAWv/bAEMAAwICAwICAwMDAwQDAwQFCAUF
      BAQFCgcHBggMCgwMCwoLCw0OEhANDhEOCwsQFhARExQVFRUMDxcYFhQYEhQVFP/bAEMBAwQEBQQF
      CQUFCRQNCw0UFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU
      FP/AABEIAVkBaAMBIgACEQEDEQH/xAAcAAEAAQUBAQAAAAAAAAAAAAAABgECBAUHCAP/xAA/EAAC
      AQMCAwUFBgQGAgIDAAAAAQIDBBEFBhIhMQcTQVFhFCJxgZEjMkJSobEIwdHhFSQzU2LwQ2Ny8SWC
      ...
      ...
             width="360"
             height="345"
             id="image5237"
             x="260"
             y="191.29076" />
      
  4. You may also want to insert some mathematical formulae in labeling some drawings. To do this (you must have installed TexText for this), you will have to choose Effects –> Tex Text
    • Caution: You should not forget the $ signs when typing any mathematical symbol (see the figure). Usually a scale factor of 1.0 is sufficient, you may scale or transform the LaTeX output using the Inkscape transform parameters (Shift+Ctrl+M or Object –> Transform …)

    Here is a sample using TexText:

  5. After you have finished doing your drawing and labelling you may save the result
  6. Save the result also as .ps (not .eps), using File –> Save as… and select “PostScript via Cairo (*.ps)” for the format.
  7. You may leave the default option of Cairo PS Output as it is when saving (Postscript level 3, 80 DPI) or you may want play with this settings if you are familiar with them.

  8. You may then insert the .ps into your LaTeX document using graphic or graphicx includegraphics (see any LaTeX graphics tutorial) or any other package that imports graphics (like pstricks, pictex.. etc.)
    \includegraphics[width=30mm]{inkscape-latex.ps}
    

    Here is an example of a .ps image included in LaTeX after having created it in inkscape:

Advertisements
This entry was posted in LaTeX. Bookmark the permalink.

One Response to Using Inkscape for LaTeX Documents

  1. Lots of people find ways to incorporate their love of horseback riding with
    their daily job or social life.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s