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:
- Select the tool and create an object using that tool.
- Change the properties to get the desired object.
- Ensure the object is selected.
- Right-click on the tool and select "Open tool preferences".
- Under "Style of new objects", check "This tool's own style" and then click the "Take from selection" button.
- 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:
- Create a new Inkscape document.
-
Edit the document's properties
(Ctrl+Shift+d, or navigate to
File > Document Properties
). - 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.
- Set the orientation to portrait.
-
Set the "Page", "Border" and "Desk" colours to
e5e5e5
,808080
and404040
, 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. - Exit the document properties window.
-
Navigate to
File > Save Template
, provide a template name at a minimum -
Check "Set as default template" and click "Save". This will save the
template as
filename.svg
under.config/inkscape/templates
and create a duplicate calleddefault.svg
. Whatever file is calleddefault.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:
- Open a graph template.
- Select the bounding box.
- Open the Function Plotter extension and enter a function with its domain and range.
- 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:
- Create a box using the rectangle tool (R) that will eventually hold the function to be generated.
- Select the newly created box and then launch the extension (Alt+F, or the shortcut you setup).
-
Set the starting and ending
X
values that will be used to compute theY
-values of the input function. -
Define where you want the rectangle's bottom and top be located relative
to the computed
Y
-values. - Uncheck "Isotropic scaling" and "Use polar coordinates" (leave them checked if you know you need these).
- Input the function to be used to create the graph.
- Uncheck "Calculate first derivative numerically".
-
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
andY
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. - Check "Remove rectangle".
- 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 | % |