The command-line Inkscape eXporter, Makefile and LaTeX friendly
Project description
ScapeX — The command-line Inkscape eXporter, Makefile and LaTeX friendly
This is a Python utility that take an SVG draw to export it in PDF. The export can be configured such as:
- The fonts can be rendered by Inkscape during the export of by LaTeX during the compilation of the document,
- The figure can be exported entirely (full mode) or in multiple fragments depending on layers identifiers.
The fragment export feature allows to create animated slides, e.g., using Beamer.
Features
- Command-line interface
- Optional per-figure TOML configuration file
- Two different exportation mode, full or fragments
- Project-wide or system-wide installation
- Out-of-tree exportation
Usage
Command-line
The source file (INFILE) should be an SVG.
If --inkscape-fonts is not passed, the SVG which will be exported in two files:
- An output file excluding text (OUTFILE).
- An sidecar TeX file including text (OUTFILE_tex). The figure can be included into LaTex using the '\input{OUTFILE.pdf_tex}' command.
If --inkscape-fonts is passed, the SVG which will be exported in one file:
- An output file including text (OUTFILE). The figure can be included into LaTex using the '\includegraphics{OUTFILE.(pdf}' command.
Optionnaly:
- The script can export multiple layer combinations of the input.
- The supported filetypes for the output is PDF. pdf: Portable Document Format (PDF) Support transparancy and page area export.
Makefile
ScapeX is also suitable to be used inside a Makefile. It allows automatic exportation and dependency handling, and to be included inside any LaTeX build system. See the self-documented example under examples/Makefile.
Installation
PipX
pipx install scapex
In order to setup the Zsh autocompletion, add the following in your ~/.zshrc:
[!WARNING] This should be added before the very first call to
compinit(which initialize the autocompletion system)
which scapex >/dev/null && fpath+=($(scapex --completions-zsh unexisting.svg))
DEPRECATED
[!NOTE] In the following code snippets, remplace the installation directory by the one of your choice.
Project-wide
ScapeX can be installed as a git submodule for a self-contained project.
Here is an example installing it into TOPLEVEL_PROJECT/modules/scapex:
cd TOPLEVEL_PROJECT && mkdir modules
git submodule add https://github.com/pierreay/scapex modules/scapex
You have then to add scapex/bin into your $PATH using your preferred method.
Here is an exemple:
cat << EOF > .env
export PATH="${PATH}${PATH+:}$(realpath modules/scapex/bin)"
EOF
The .env file should be sourced in the current shell, using a plugin (e.g, using dotenv or direnv) or either manually:
source .env
System-wide
ScapeX can be installed system-wide for a single user.
Here is an example installing it into ~/.local/src/scapex:
mkdir ~/.local/src && cd ~/.local/src
git clone https://github.com/pierreay/scapex
You have then to add scapex/bin into your $PATH using your preferred method.
Here is an exemple for Bash:
cat << EOF >> ~/.bashrc
export PATH="${PATH}${PATH+:}${HOME}/.local/src/scapex/bin"
EOF
Usage
Command-line interface
ScapeX can be used as the following:
$ scapex --help
Usage: scapex [-l LAYERFILE.json] [--inkscape-fonts] INFILE.svg OUTFILE.(pdf | eps)
Export an Inkscape source file for LaTeX.
The source file (INFILE) should be an SVG.
If --inkscape-fonts is not passed, the SVG which will be exported in two files:
- An output file excluding text (OUTFILE).
- An sidecar TeX file including text (OUTFILE_tex).
The figure can be included into LaTex using the '\input{OUTFILE.(pdf | eps)_tex}' command.
If --inkscape-fonts is passed, the SVG which will be exported in one file:
- An output file including text (OUTFILE).
The figure can be included into LaTex using the '\includegraphics{OUTFILE.(pdf | eps)}' command.
Optionnaly:
- The script can export multiple layer combinations of the input.
- The supported filetypes for the output are PDF and EPS.
eps: Encapsulated PostScript (EPS)
Do not support transparancy or page aera export.
pdf: Portable Document Format (PDF)
Support transparancy and page aera export.
Dependencies:
- inkscape
- jq
- bc
Options:
-l LAYERFILE: Path to a JSON layer file.
--inkscape-fonts: Font rendered by Inkscape intead of LaTeX.
Examples:
$ scapex -l utils/layers.json gfx/inkscape/drawing.svg build/gfx/inkscape/drawing.pdf
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scapex-0.2.0.tar.gz.
File metadata
- Download URL: scapex-0.2.0.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e87b04802f933d38aea2d14216a05553b869b058c0398fb7baf24b688d6ceec6
|
|
| MD5 |
1ea575a8426bbae2961232723773a9f1
|
|
| BLAKE2b-256 |
67fd0c1c7dc057de0465cc851af7e2b621b2b4af4301debcbab7407a66bc0b5f
|
File details
Details for the file scapex-0.2.0-py3-none-any.whl.
File metadata
- Download URL: scapex-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3992310afb7591429cd934225251b624e561b334f44f27c9fb0138eb70dda602
|
|
| MD5 |
71d738ab2ba5bc3eb7dcc63942b857ed
|
|
| BLAKE2b-256 |
58387dea3cf96b4900ca681d5450318f0cbb2fdf28bcd5b5779cc3a96361bbdd
|