{"id":13545423,"url":"https://github.com/gillescastel/inkscape-figures","last_synced_at":"2025-05-16T12:08:17.642Z","repository":{"id":34797043,"uuid":"183228818","full_name":"gillescastel/inkscape-figures","owner":"gillescastel","description":"Inkscape figure manager","archived":false,"fork":false,"pushed_at":"2022-01-28T18:04:50.000Z","size":45,"stargazers_count":604,"open_issues_count":12,"forks_count":126,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-02T03:19:20.591Z","etag":null,"topics":["inkscape","latex","linux","vim"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gillescastel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-24T12:54:38.000Z","updated_at":"2025-04-01T17:53:22.000Z","dependencies_parsed_at":"2022-08-09T08:46:57.398Z","dependency_job_id":null,"html_url":"https://github.com/gillescastel/inkscape-figures","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gillescastel%2Finkscape-figures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gillescastel%2Finkscape-figures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gillescastel%2Finkscape-figures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gillescastel%2Finkscape-figures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gillescastel","download_url":"https://codeload.github.com/gillescastel/inkscape-figures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980836,"owners_count":21027808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["inkscape","latex","linux","vim"],"created_at":"2024-08-01T11:01:02.485Z","updated_at":"2025-04-09T05:07:34.505Z","avatar_url":"https://github.com/gillescastel.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Inkscape figure manager.\n\nA script I use to manage figures for my LaTeX documents.\nMore information in this [blog post](https://castel.dev/post/lecture-notes-2/).\n\n## Requirements\n\nYou need Python \u003e= 3.7, as well as a picker. Current supported pickers are:\n\n* [rofi](https://github.com/davatorium/rofi) on Linux systems\n* [choose](https://github.com/chipsenkbeil/choose) on MacOS\n\n## Installation\n\nYou can install it using pip:\n\n```\npip3 install inkscape-figures\n```\n\nThis package currently works on Linux and MacOS. If you're interested in porting it to Windows, feel free to make a pull request.\n\n## Setup\n\nAdd the following code to the preamble of your LateX document.\n\n```tex\n\\usepackage{import}\n\\usepackage{pdfpages}\n\\usepackage{transparent}\n\\usepackage{xcolor}\n\n\\newcommand{\\incfig}[2][1]{%\n    \\def\\svgwidth{#1\\columnwidth}\n    \\import{./figures/}{#2.pdf_tex}\n}\n\n\\pdfsuppresswarningpagegroup=1\n```\nThis defines a command `\\incfig` which can be used to include Inkscape figures.\nBy default, `\\incfig{figure-name}` make the figure as wide as the page, but it's also possible to change the width by providing an optional argument: `\\incfig[0.3]{figure-name}`.\n\nThe settings above assume the following directory structure:\n\n```\nmaster.tex\nfigures/\n    figure1.pdf_tex\n    figure1.svg\n    figure1.pdf\n    figure2.pdf_tex\n    figure2.svg\n    figure2.pdf\n```\n\n## Usage\n\n* Watch for figures: `inkscape-figures watch`.\n* Creating a figure: `inkscape-figures create 'title'`. This uses `~/.config/inkscape-figures/template.svg` as a template.\n* Creating a figure in a specific directory: `inkscape-figures create 'title' path/to/figures/`.\n* Select figure and edit it: `inkscape-figures edit`.\n* Select figure in a specific directory and edit it: `inkscape-figures edit path/to/figures/`.\n\n## Vim mappings\n\nThis assumes that you use [VimTeX](https://github.com/lervag/vimtex).\n\n```vim\ninoremap \u003cC-f\u003e \u003cEsc\u003e: silent exec '.!inkscape-figures create \"'.getline('.').'\" \"'.b:vimtex.root.'/figures/\"'\u003cCR\u003e\u003cCR\u003e:w\u003cCR\u003e\nnnoremap \u003cC-f\u003e : silent exec '!inkscape-figures edit \"'.b:vimtex.root.'/figures/\" \u003e /dev/null 2\u003e\u00261 \u0026'\u003cCR\u003e\u003cCR\u003e:redraw!\u003cCR\u003e\n```\n\nFirst, run `inkscape-figures watch` in a terminal to setup the file watcher.\nNow, to add a figure, type the title on a new line, and press \u003ckbd\u003eCtrl+F\u003c/kbd\u003e in insert mode.\nThis does the following:\n\n1. Find the directory where figures should be saved depending on which file you're editing and where the main LaTeX file is located, using `b:vimtex.root`.\n1. Check if there exists a figure with the same name. If there exists one, do nothing; if not, go on.\n1. Copy the figure template to the directory containing the figures.\n1. In Vim: replace the current line – the line containing figure title – with the LaTeX code for including the figure.\n1. Open the newly created figure in Inkscape.\n1. Set up a file watcher such that whenever the figure is saved as an svg file by pressing \u003ckbd\u003eCtrl + S\u003c/kbd\u003e, it also gets saved as pdf+LaTeX.\n\nTo edit figures, press \u003ckbd\u003eCtrl+F\u003c/kbd\u003e in command mode, and a fuzzy search selection dialog will popup allowing you to select the figure you want to edit.\n\n\n## Configuration\n\nYou can change the default LaTeX template by creating `~/.config/inkscape-figures/config.py` and adding something along the lines of the following:\n\n```python\ndef latex_template(name, title):\n    return '\\n'.join((r\"\\begin{figure}[ht]\",\n                      r\"    This is a custom LaTeX template!\",\n                      r\"    \\centering\",\n                      rf\"    \\incfig[1]{{{name}}}\",\n                      rf\"    \\caption{{{title}}}\",\n                      rf\"    \\label{{fig:{name}}}\",\n                      r\"\\end{figure}\"))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgillescastel%2Finkscape-figures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgillescastel%2Finkscape-figures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgillescastel%2Finkscape-figures/lists"}