Skip to content
  • Beautiful Graphs: How to turn an Inkscape drawing into an editable LaTeX document

    Posted on May 24, 2013
    Yetish Joshi photo

    Guest post by Yetish Joshi

    I'm a PhD student and recently had to write a couple of papers for a conference. Despite emailing the pdfs for review to my supervisors, after submitting things still got missed.

    I'm hoping writeLaTeX will enable a more collaborative means to write documents and ensure the latest version is worked upon.

    I use pdf_tex files for my graphs, and since the writeLaTeX team added support so I could use them in my documents here, I wanted to share how this style of graph is achieved so others can produce beautiful vector based graphics.

    Beautiful graphs with pdf_tex

    The pdf_tex file is a tex wrapper produced by Inkscape as a means to strip out text from an SVG diagram when saving PDF. Hence, the graphic is stored in the PDF and the text is rendered by latex. Click on the example below to open in the writeLaTeX editor. You can see in the files menu the two uploaded files which make up the figure.

    pdf_tex screenshot

    Step-by-step guide

    Let's say you have your data. One could analyse it with R, preferably with a front-end like R studio. However, as I have lots of data I prefer filtering down to a subset, and need the ability to have interactive flexibility other than R`s script based manner.

    Hence, for my graphs I use Veusz -- it's a great mulit-platform free tool by Jeremy Sanders (see his twenty minute video if you've got some time!). Remember you have to think a bit differently to spreadsheet based graphs but the flexibility is great. However, after you first install it please note that within Preferences you need to tick a check box to enable save text as text for SVG. Then you're safe to save as SVG and thus use Inkscape`s PDF+LaTeX option.

    Now something different (well slightly at least). There is an extension for Inkscape to save as tikz, which is actually quite cool. I believe it to be multi-platform, only used it in Windows and Ubuntu, Ubuntu may be a bit odd, but it gets there.

    The reason for this other workflow of tikz export is to use tikz (and possibly PGF) to draw line drawings, see e.g. the examples at TeXample.net. Let say you use something like yED (just watch the video -- 90 seconds and you're in love). It's a cross of VB6 and Visio -- weird but it works. Best of all its free and supports SVG. Equally you can use a web based solution like draw.io, which is very cool.

    Personally, I look at the code produced by tikz export extension for length/complexity, and for line diagrams/flowcharts it is nice.

    Below is the output using the tikz export extension from Inkscape -- click to open in the writeLaTeX editor.

    tikz inkscape screenshot

    The file can be tidied up by including the picture as an attachment, rather than directly in the main tex file. Click to open in writeLaTeX -- you can still scale the figure as required with commands in the main tex file, and add captions.

    tikz inkscape screenshot 2

    Either way, the lines are pin sharp.

    If you would like diagram software with native support for tex then look no further than classic Dia, it is a bit of a pain, but its support is great, however it is the only one to support isometric graph-guidelines, which can aid to create a 3D diagram. Dia -> Diagram Properties -> Hex Grid.

    Below is a Cube (3D) drawn in Dia and exported as tex with PGF -- click to open in writeLaTeX. For scaling within the this file I play with \setlength{\du}{15\unitlength}, while for scaling I play with \pgfsetlinewidth{0.100000\du}.

    tikz inkscape screenshot 2

    Finally, tables. These can be a bit of a nightmare, and a simple solution is to produce them in LibreOffice Calc then open them in gnumeric and save as Latex Table Fragment.

    I hope this helps! Thanks for reading -- Yetish Joshi

Sign up for a free account and receive regular updates

Registrarse

Popular Tags


Start writing now!

Create A New Paper

Overleaf is Gratis

New to LaTeX?
Start with a template

Company