Skip to content

inkscape

Interface

1765918819.png

Installation (Archlinux)

sudo pacman -S inkscape texlive-bin texlive-latexextra
I installed texlive-bin for pdftolatex binary and texlive-latexextra because without it inkscape complains that standalone.cls is missing and fails to render LaTex equation.

Workflow

I use inkscape to create diagrams in the notes I type in markdown. The diagram creation process actually begins from neovim, with the keybinding <C-s> which copies svg template file (which is just an A4 landscape page created with inkscape itself) at ~/.config/inkscape/templates/A4_landscape.svg. The second tab below contains the code that creates the function and the binding.

~/.config/inkscape/templates/A4_landscape.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   width="297mm"
   height="210mm"
   viewBox="0 0 297 210"
   version="1.1"
   id="svg1"
   inkscape:version="1.4.3 (0d15f75042, 2025-12-25)"
   sodipodi:docname="A4_landscape.svg"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <sodipodi:namedview
     id="namedview1"
     pagecolor="#ffffff"
     bordercolor="#000000"
     borderopacity="0.25"
     inkscape:showpageshadow="2"
     inkscape:pageopacity="0.0"
     inkscape:pagecheckerboard="0"
     inkscape:deskcolor="#d1d1d1"
     inkscape:document-units="mm"
     inkscape:zoom="1.060115"
     inkscape:cx="561.25984"
     inkscape:cy="396.65507"
     inkscape:window-width="1918"
     inkscape:window-height="1059"
     inkscape:window-x="0"
     inkscape:window-y="0"
     inkscape:window-maximized="0"
     inkscape:current-layer="layer1" />
  <defs
     id="defs1" />
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1" />
</svg>
~/.config/nvim/lua/config/keymaps.lua
vim.keymap.set({ "i" }, "<C-s>", function()
  local dirpath = vim.fn.expand("%:p:h") .. "/img"
  local imgname = os.time() .. ".svg"

  -- A shell script to paste image from clipboard into subdir img
  local shell_script = string.format(
    [[
  DIRPATH=%s
  IMGFNAME=%s
  if ! [ -d $DIRPATH ]
  then
    mkdir $DIRPATH
  fi
  cp ~/.config/inkscape/templates/A4_landscape.svg $DIRPATH/$IMGFNAME
  ]],
    dirpath,
    imgname
  )
  vim.fn.system(shell_script)

  -- All this is just to insert markdown image link
  local row, col = unpack(vim.api.nvim_win_get_cursor(0))
  local lines = vim.api.nvim_buf_get_lines(0, row - 1, row, false)
  local markdown_link = string.format("![%s](img/%s)", imgname, imgname)
  -- Check if the 'lines' table is empty
  local line = ""
  if #lines ~= 0 then
    line = lines[1]:gsub("\n", " ")
  end
  local new_line = line .. markdown_link
  vim.api.nvim_buf_set_lines(0, row - 1, row, false, { new_line })
  vim.api.nvim_win_set_cursor(0, { row, col + #markdown_link })
end, { desc = "Copy SVG template into img directory" })

Document Properties

File > Document Properties

The document proerties is quite interesting:

1766474059.png

1766950017.png

Object

Two particularly important things to note:

  1. Object > Fill and Stroke
  2. Object > Align and Distribute

Bezier Tool

The bezier pen tool combined with node tool is how you create shapes. Prefer the Fill and Stroke (Object > Fill and Stroke) which appears on RHS for setting the colors and boundary appearance —whether you want it dotted, solid, dashed etc. Fill and Stroke enables you to specify exact color values in HSL/HSV/RGB.

1766729306.png

1766740444.png

LaTex Math Equations

First make sure texlive-bin, texlive-latexextra are installed. Now enter the equation in:

Extensions > Text > Formula (pdflatex)...

1767172948.svg


Comments