[WIP] Thesis I: Adding Images
Estimated reading time: ~2 minutes with ~413 words.
This post is on how I added images to my thesis. I drew all my figures using Goodnotes 5 on an iPad, and used inkscape and cairosvg on a Linux machine to convert it to something that could be included in LaTeX.
Step 1: Importing to Goodnotes
The easiest way for me to do this was:
-
On computer: Compile latex file upload pdf to a private discord server.
-
On iPad: download pdf from discord open it in Goodnotes.
Step 2: Drawing
There are two kinds of images that I have in my thesis. The first is a full page image that goes as a background for the entire page.
The second is on the margins to explain the text in the main body.
Since I only export a single page in Step 3, I usually collect many of these small figures into a single page before exporting.
Step 3: Exporting from Goodnotes
I click on “Export this page” including page background and annotation, with PDF Data Format as “Editable” sharing it to my private discord server.
Step 4: Importing to Inkscape
I download the pdf from my discord server into a temporary directory, which for me is ~/Downloads/, and import it into inkscape with whatever default options inkscape provides me.
Step 5: Editing on Inkscape
There are easy, medium, and difficult things that need to be done in this step.
[WIP] This might need its own post, so I’ll come back to this later.
-
full page drawings needs to be full page exported.
-
small ones need to be exported by themselves.
-
some items need to be “moved to back” and so on.
-
some things needs to be duplicated and mirror reflected for keeping it symmetric (can’t do this in goodnotes programatically).
-
export is svg.
At the end of this step, there should be a file called $PROJECT/figures/<chapter>/<image>.svg.
Step 6: Converting svg to pdf
One could have tried exporting as pdf in the last step directly from Inkscape. This fucks up the shading from the “highlighting” tool from Goodnotes, you can try and see how it goes. So I need to use cairo. I go to the corresponding folder and run
cairosvg "input.svg" -o "input.pdf"
Since I have many svgs, I have the following script saved as $PROJECT/figures/svg2pdf.
#!/bin/bash
FOLDER="$1"
if [ ! -d "$FOLDER" ]; then
echo "Error: Folder ’$FOLDER’ does not exist."
exit 1
fi
for f in "$FOLDER"/*.svg; do
pdf="${f%.svg}.pdf"
echo "Converting $f -> $pdf"
cairosvg "$f" -o "$pdf"
done
I call it as ./svg2pdf <chapter> and it converts all the svgs in the $PROJECT/figures/chapter/ subfolder to pdfs.
Step 7: Including the figure in latex
[WIP] I will explain what the commands do later, but here’s the gist. These commands implicitly add a .pdf to the end of the files.
I include the full page images like so.
\setpagebg{partridge}
And the margin images go like so.
\sidefigure[*-4]{neighboring}
The optional argument to sidefigure is an offset, so *-4 offsets it upwards by 4 times the \baselineskip.