Introduction to Skencil

Skencil is an excellent, little known, open source package for vector graphics. Vector graphics formats such as postscript, scale with size whilst preserving figure integrity. Vector graphics (e.g. postscript) scale with size properly.

I use it frequently for functional and aesthetic postscript figure creation and annotation for latex documents (theses, papers, etc).

For a complete introduction and tutorials for skencil, please see this document. Highly Recommended!!

Installing Skencil

You can get skencil from its website skencil.org.
Make sure to install the skLatex plugin too!
You'll want skencil version 0.6.17 NOT the development version!

Creating Postscript Figures

Say you want to create a nice figure for your shiny new paper: "Proof that the Answer to everything is 42."
I've created a simple figure you may want to load here: 42.sk.
It's very simple. To create arrows you simply use the "Draw Poly-Line" button . Then click and drag in the canvas and then click the arrow button - you should now have a single line. Right click on the line and choose "Line..." or just type "F7" to bring up the line properties dialog. This is where you can add the arrowhead, change the colour, thickness, etc.

To create your postscript figure from skencil you can choose either the "File->Save as Postscript" or "File->Print" menu item and choose EPS. Have a look at what you get here: 42.ps.

Notice that skencil trimmed most of the whitespace. Later I'll cover some tricks at using skencil to actually trim figures you make...

This figure is now ready for your latex document 42-paper.tex. Notice the use of scale in the includegraphics statement to control the size of the figure, this is much easier then specifying width or height. To rotate an image you would have scale=0.5,angle=270 for example.

Adding formulae to your postscript figure using the skLatex plugin

One of the best things about skencil is the skLatex plugin!
This lets you add standard latex to your skencil documents, not just maths but also tables, etc, the whole works (well except for figures I think...).

Say we want to add the following equation: "\[\int\int y^2 x^2 \mathrm{d}x \mathrm{d}y = 42\]" to our 42.sk document.
. Load up the skLatex panel using the "Edit->Create->skLatex..." menu item. Put the above text (without quotes) into the main section of the panel and press the "Apply" button. Now, if you installed everything correctly, you should get in the main skencil window a little selection that you must click somewhere to "anchor" the latex formula. Grab one of the corners and scale the formula (hold control to keep the aspect). The formula is in vector format, so scale to however big you want, it will still be fine in the final product. You can see the results here: 42-latex.sk and 42-latex.ps.

Importing other postscript figures

Say you wanted to add an equation to a non-sklatex generated postscript figure?
Or if you wanted to embed another postscript figure within another postscript figure?

How would you do it?

With skencil, it is trivial! The key is the postscript/graphic import button "Load EPS/Raster Image..." .
Importing in this way the postscript figure is given a bitmap "preview" that you can position within a document. You can resize the postscript figure however you want, rotate it, etc. (to rotate click on an object to select, then click on it again, then drag the circular arrows till you get the desired effect - again, holding down control will snap the rotation to 15 degree bits)
The idea here is that when you print the skencil document, as a postscript document, the emdedded postscript is added or kept in the output as postscript.

As an example, say we want to alter aaomega_huge_sa_alloc.ps (PGPLOT generated) in the following way: Normally, this would be difficult with some other package and you may or may not get postscript quality output!

Start a new skencil document, import the figure using .
Rotate the figure so that it appears upright. Then add your components as usual (see above).
This is what we get: embed.sk and embed.ps.
Notice that the figure is now portrait format and has some cool additions whilst the underlying figure is preserved!
Another thing you can do is create a coloured rectangle, or even import a bitmap image, to be used as a background. You can then import on this background a postscript figure. The postscript details will be imprinted cleanly onto the background. An example: background.sk uses aaomega_huge_sa_alloc.ps with output background.ps.


In a similar fashion you can add another postscript figure instead of a skencil object (circle, latex formula, etc). All that is required is to import the figures as before using and then re-sizing, orienting, etc, the figures till you are happy. An example can be found here: aaomega_huge_sa_comp.sk (you'll need aaomega_huge_sa.ps). The output can be found here aaomega_huge_sa_comp.ps.

Note again how the postscript figures are preserved as postscript!

Cropping existing postscript figures

One of the more complex things I have done with skencil is use it to "blank out" areas of a postscript figure in order to crop it.

You will need the postscript utility ps2epsi
Say I wanted to crop aaomega_huge_sa.ps to just show the bottom left quadrant.
I have no idea how you might achieve this normally!! (say within latex or some other graphics package), but with skencil and ps2epsi it is possible...
  1. We simply import the above postscript figure we want to crop as usual and lay two large white rectangles on top of the regions we don't want in the final figure. Make sure you right click on the rectangles and choose "No Line". You should have something like crop.sk. You'll notice that the printed version crop.ps is not ideal for use yet - you can still see the original figure using gv when the figure is drawn on the screen. To improve the situation we need to crop the whitespace from the image...
  2. Run this: ps2epsi crop.ps to get crop.epsi. Note that if you include crop.epsi in a latex document, you will still see some of the original figure (weird), even though it looks fine in gv.
  3. Import crop.epsi into a new sklatex document crop2.sk and then print it as usual to get crop2.ps. This figure should now work perfectly in a latex document!
The complex procedure above generally, as I see it, crops whitespace and fixes the bounding box, etc, in a systematic way to reduce the image. There may be a simpler procedure (email me if you find one), but this has worked for me many times. See if you can try and crop aaomega_huge_sa.ps to just show the central AAOmega logo...

Happy Skencilling!



Back to my homepage