Skip to content

figures.ahk

bloodbornebi edited this page Dec 4, 2020 · 4 revisions

Requirements

This one requires Inkscape. It also requires you to have a bit more patience with configuration. It is recommended you read the original article because it has some important information re. packages, etc.

Organization set-up

This script requires you to have a very specific organization set-up for your notes. Because of issues with how AHK pulls a directory, I wasn't able to get it to look at the directory of the file you're writing. So it expects a file structure like this:

..\notes\
|--- figures\
|    |--- template.svg
|--- math.tex
|--- math2.tex

Which is definitely awkward. (On the other hand, this does let you reuse figures, etc., so maybe it's not terrible?)

Configuration

You'll need to check all of the directories to make sure they're correct, since they're mostly hard-coded in. Additionally, this one requires the same code that Castel has in his preamble.

Set-up

Load into AHK, change requisite files and run script. If you're unsure of exactly how to do that, I wrote more detailed instructions here. You'll also need to find the directories (mine all start with C:, and yours probably do too) and replace them with your personal directories.

Usage

This is run with two separate hotkeys: first, alt p starts the figure process, then once you're done with the figure in Inkscape, alt s saves it, then recompiles your latex document. So your workflow should look like this:

  1. alt p
  2. type your file name (you won't see it, but it will be recorded).
  3. tab
  4. wait for inkscape to load
  5. make figure
  6. alt s
  7. back to writing

The alt s command is always active in Inkscape, so if you (for some reason) are using alt s to mean something else sometimes, make sure you end this script when you're not writing. You can also use enter instead of tab, but I suggest sticking with tab, as it causes fewer issues. enter is more there as a failsafe.

Differences

Most importantly, you can only use one-word file names. I don't plan on making a workaround for that one, sorry. I'm not nearly good enough at RegEx to get it to work, and be editable, and not break anything else.

You can't search your figures in the same way here. I'm working on something that will let you easily pull up figures to edit them, etc., but it will probably be under a different hotkey. (Probably alt shift p.) There also aren't any of the drawing commands/text commands yet (those will come, probably in a separate file).

Also, it's just generally a little less elegant. Part of that is my limitations, part of that is the medium. Either way, it's a little rough around the edges. So just expect to see more screen flickering than you might expect.

Issues

If you're getting issues, first, make sure the directories are right. That was what gave me the biggest trouble when I was writing this.

After that, the saving code for Inkscape is the buggiest part. If it's really giving you trouble in the moment, just manually save - you don't break anything by not hitting alt s, since it's two different hotkeys.

I'm not 100% sure if the fact that it uses PowerShell will cause issues for anyone. It works fine for me, but there's the off-chance it will break.

Clone this wiki locally