Inkscape for LaTeX Figures

Creating a Custom Colour Palette

Create a document containing squares filled with the colours one wants to add to a palette. Use colours that are easily distinguishable from each other and highly visible on white-page backgrounds like the ones list in the table below. Also include black, three shades of grey and white. Sort the squares from left-to-right and top-to-bottom in the order in which one wants the colours to appear in the colour palette.

Colour Hexadecimal
Blue 2038c0
Blue (lighter) 0f7be6
Orange c6600b
Orange (lighter) f18e04
Green 0c4f11
Green (lighter) 068e14
Purple 4e129b
Purple (lighter) 8b1fd6
Red ab1212
Red (lighter) ec0e0e

Once the colours have been added, save it as palette.svg in the .config/inkscape/templates so you can easily amend or expand it at a later date.

Download the generate_palette.inx, generate_palette.py and info.svg files from the olibia/inkscape-generate-palette repository and add them to the .config/inkscape/extensions directory.

Restart Inkscape if it is already open, then run the extension by clicking Extensions > Palette > Generate. Give the palette a name, set the colour property to "Fill Colour", check "Replace existing palette", and sort the colours by "xY location". Click "Apply" and then restart Inkscape. One can then select the custom palette via the palette tool-bar.

Setting up Default Tool Properties

Set the properties of tools to the values you use most frequently. For example, if text is commonly set to a dark coloured fill and stroke, then set the text tool's properties to this. To change a specific tool's properties:

  1. Select the tool and create an object using that tool.
  2. Change the properties to get the desired object.
  3. Ensure the object is selected.
  4. Right-click on the tool and select "Open tool preferences".
  5. Under "Style of new objects", check "This tool's own style" and then click the "Take from selection" button.
  6. Exit the tool preferences window. Next time the tool is selected and used it will default to the properties of the object selected prior.

Setting up a Default Template

Default templates lead to efficiency and consistency. To setup one:

  1. Create a new Inkscape document.
  2. Edit the document's properties (Ctrl+Shift+d, or navigate to File > Document Properties).
  3. Set the page width and height. 121mm x 193mm is the default text-block area for A4 page in LaTeX. Setting the page size to this will allow you to work right up to the canvas borders while still knowing that the scale of the content will be similar when including the figure within a single page.
  4. Set the orientation to portrait.
  5. Set the "Page", "Border" and "Desk" colours to e5e5e5, 808080 and 404040, respectively. In HSL, the aforementioned hexadecimal values correspond 0 hue and saturation, with 90, 50 and 20 luminance, respectively. These values still integrate with dark themes but the almost white canvas provides better visibility for darker colours that will inevitably be used for LaTeX figures that end up on white pages.
  6. Exit the document properties window.
  7. Navigate to File > Save Template, provide a template name at a minimum
  8. Check "Set as default template" and click "Save". This will save the template as filename.svg under .config/inkscape/templates and create a duplicate called default.svg. Whatever file is called default.svg in this templates folder will be the template used upon starting Inkscape.

Creating Graphs

After setting things up as described below, creating consistent, high-quality graphs will only require a few steps:

  1. Open a graph template.
  2. Select the bounding box.
  3. Open the Function Plotter extension and enter a function with its domain and range.
  4. Generate the function, save and exit.

Graph Templates

To facilitate the quick creation of different graphs, create graph templates and store them in the .config/inkscape/templates. Each template should have axes, axes labels, ticks, points, a function label and a function bounding box that will be used with the Function Plotter extension described in Function Plotter Extension section.

Function Plotter Extension

Inkscape provides the Function Plotter extension under Extensions > Render > Function Plotter.

It is recommended to map this extension to a keyboard shortcut like Alt+F (think "F" for function). Shortcuts are set in Edit > Preferences > Interfaces > Keyboard. Once at this menu, search for "Function Plotter" and then click on the cell corresponding to the "Shortcut" column and "Function Plotter" row. The text "New accelerator" will display in this cell and you can press the desired keys to set a mapping.

To use the extension:

  1. Create a box using the rectangle tool (R) that will eventually hold the function to be generated.
  2. Select the newly created box and then launch the extension (Alt+F, or the shortcut you setup).
  3. Set the starting and ending X values that will be used to compute the Y-values of the input function.
  4. Define where you want the rectangle's bottom and top be located relative to the computed Y-values.
  5. Uncheck "Isotropic scaling" and "Use polar coordinates" (leave them checked if you know you need these).
  6. Input the function to be used to create the graph.
  7. Uncheck "Calculate first derivative numerically".
  8. Check "Clip with rectangle". This will ensure that the function will stay inside the box no matter its size after generation. However, in doing this, you must ensure that the X and Y values have been set appropriate such that the box functions as the "window" through which you want to view the important parts of the function.
  9. Check "Remove rectangle".
  10. Uncheck "Draw axes" and "Add x-axis endpoints".

Useful Inkscape Shortcuts

Tool Selection

Action Shortcut
Selector tool s

Moving Objects

Action Shortcut
Large movement Shift+<arrow key>
Micro movement Alt+<arrow key>
Raise object to top Home
Raise object one step Page Up
Lower object to bottom End
Lower object one step Page Down

Miscellaneous

Action Shortcut
Toggle snapping %