Inkscape figure manager.
A script I use to manage figures for my LaTeX documents. More information in this blog post.
Requirements
You need Python >= 3.7, as well as a picker. Current supported pickers are:
Installation
You can install it using pip:
pip3 install inkscape-figures
This package currently works on Linux and MacOS. If you're interested in porting it to Windows, feel free to make a pull request.
Setup
Add the following code to the preamble of your LateX document.
\usepackage{import}
\usepackage{pdfpages}
\usepackage{transparent}
\usepackage{xcolor}
\newcommand{\incfig}[2][1]{%
\def\svgwidth{#1\columnwidth}
\import{./figures/}{#2.pdf_tex}
}
\pdfsuppresswarningpagegroup=1
This defines a command \incfig which can be used to include Inkscape figures.
By 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}.
The settings above assume the following directory structure:
master.tex
figures/
figure1.pdf_tex
figure1.svg
figure1.pdf
figure2.pdf_tex
figure2.svg
figure2.pdf
Usage
- Watch for figures:
inkscape-figures watch. - Creating a figure:
inkscape-figures create 'title'. This uses~/.config/inkscape-figures/template.svgas a template. - Creating a figure in a specific directory:
inkscape-figures create 'title' path/to/figures/. - Select figure and edit it:
inkscape-figures edit. - Select figure in a specific directory and edit it:
inkscape-figures edit path/to/figures/.
Vim mappings
This assumes that you use VimTeX.
inoremap <C-f> <Esc>: silent exec '.!inkscape-figures create "'.getline('.').'" "'.b:vimtex.root.'/figures/"'<CR><CR>:w<CR>
nnoremap <C-f> : silent exec '!inkscape-figures edit "'.b:vimtex.root.'/figures/" > /dev/null 2>&1 &'<CR><CR>:redraw!<CR>
First, run inkscape-figures watch in a terminal to setup the file watcher.
Now, to add a figure, type the title on a new line, and press Ctrl+F in insert mode.
This does the following:
- 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. - Check if there exists a figure with the same name. If there exists one, do nothing; if not, go on.
- Copy the figure template to the directory containing the figures.
- In Vim: replace the current line – the line containing figure title – with the LaTeX code for including the figure.
- Open the newly created figure in Inkscape.
- Set up a file watcher such that whenever the figure is saved as an svg file by pressing Ctrl + S, it also gets saved as pdf+LaTeX.
To edit figures, press Ctrl+F in command mode, and a fuzzy search selection dialog will popup allowing you to select the figure you want to edit.
Configuration
You can change the default LaTeX template by creating ~/.config/inkscape-figures/config.py and adding something along the lines of the following:
def latex_template(name, title):
return '\n'.join((r"\begin{figure}[ht]",
r" This is a custom LaTeX template!",
r" \centering",
rf" \incfig[1]{{{name}}}",
rf" \caption{{{title}}}",
rf" \label{{fig:{name}}}",
r"\end{figure}"))
Metadata
Release files for inkscape-figures 1.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| inkscape-figures-1.0.8.tar.gz | 9.2 kB | Without provenance | Details for inkscape-figures-1.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| inkscape_figures-1.0.8-py3-none-any.whl | Python 3 | none | any | Details for inkscape_figures-1.0.8-py3-none-any.whl |
Total release size: 18.9 kB
Release files / inkscape-figures-1.0.8.tar.gz
| Download URL | inkscape-figures-1.0.8.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
49ced7335a64f2dba4ff3f57f24a7ebd792674395631a248e0edcbe8e6196f32
|
|
BLAKE2b-256 checksum How to use checksums |
63eda95713ecf19da5a0985993947296f6baaba492c5adb9bdc4e2ca9a9e0b91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.9
|
Release files / inkscape_figures-1.0.8-py3-none-any.whl
| Download URL | inkscape_figures-1.0.8-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8cd698dec82d7b8f99a8ea9da0b2451a8242e1871264b2e7b371eee17a7fbd74
|
|
BLAKE2b-256 checksum How to use checksums |
e333bea17670536e50455383d2a3e1e358ee0130e74a0b0aad7fe61b1e84bf83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.6.9
|
Security for inkscape-figures 1.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.