Giter VIP home page Giter VIP logo

inkscape-figures's Introduction

Inkscape figure manager.

A script I use to manage figures for my LaTeX documents. More information in this blog post.

Installation

You can install it using pip:

pip install inkscape-figures

You'll also need rofi.

This script only works on Linux. If you're interested in porting it to Windows/OSX, feel free to make a pull request.

Setup

Add the following code to the preamble of your LateX document.

\usepackage{import}
\usepackage{xifthen}
\usepackage{pdfpages}
\usepackage{transparent}

\newcommand{\incfig}[1]{%
    \def\svgwidth{\columnwidth}
    \import{./figures/}{#1.pdf_tex}
}
\pdfsuppresswarningpagegroup=1

This assumes 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.svg as 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>

Now, to add a figure, type the title on a new line, and press Ctrl+F in insert mode. This does the following:

  1. 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.
  2. Check if there exists a figure with the same name. If there exists one, do nothing; if not, go on.
  3. Copy the figure template to the directory containing the figures.
  4. In Vim: replace the current line โ€“ the line containing figure title โ€“ with the LaTeX code for including the figure.
  5. Open the newly created figure in Inkscape.
  6. 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.

inkscape-figures's People

Contributors

gillescastel avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.