seebk / LaTeXText

Inkscape extension to render text as Latex
GNU General Public License v3.0
140 stars 19 forks source link

Introduction

This Inkscape extension searches all text elements in a document and renders them with PdfLatex. The rendered text will appear at the same position as the original text and may contain Latex commands and math formula. Modifications of the source text will be considered when the extension is executed again.

As the rendered text is added to a new layer, the original document content is not touched and you can always wipe out all modifications from this extension by simply deleting the created layer.

Installation

Linux

Required packages on Debian-based distributions:

In other distributions the packages may be named differently, e.g the PyGObject bindings on OpenSuse are in the python2-gobject-Gdk package.

When the dependencies are installed, just run the install.sh script to copy the extension into the Inkscape extension folder in the current user home directory (~/.config/inkscape/extensions/).

Windows

Required Software:

Simply download the installer package from the latest release and run it.

NOTE: You need at least Inkscape 0.92.2. Prior versions used a different build environment on Windows and are not compatible with this extension.

Mac OS X

Required Software:

Instructions:

  1. Open a command terminal and check if you can execute pdflatex. If it is not found verify if MacTex is up-to-date and properly installed.

  2. Install pdf2svg from Macports.

     $ sudo port install pdf2svg
  3. Install the required Python modules.

     $ sudo port install py27-gobject3
     $ sudo port install py27-lxml
  4. Macports does not install the Python modules into the default Apple Python environment and the official Inkscape OS X installer will not use Python from Macports. So we have to install Inkscape from Macports, too.

     $ sudo port install inkscape

    As this pulls quite a lot of dependencies, the download and compilation may take a long time. Take a coffee ;)

  5. Run the install.sh script to copy the extension into the Inkscape extension folder in the current user home directory (~/.config/inkscape/extensions/).

If there is an easier way to install and use the extension on OS X, in particular in combination with the official Inkscape installer, feel free to send updated instructions.

Usage

Inkscape extension

Step-by-step animation

General instructions:

NOTE: There may be two different entries in the Inkscape extension menu: a standard Inkscape extension and a 'GTK3' GUI variant. The latter is the recommended one as it can remember and restore previous settings per document and has a more comfortable UI. The other extension is only there to be used as a fallback if GTK3 is not available.

Options

Commandline mode

You can directly run the extension in the commandline outside of Inkscape, too.

Usage: latextext.py [options] SVGfile(s)

Options:
-h, --help            show this help message and exit
-o FILE, --outfile=FILE
                    write to output file or directory
-p FILE, --preamble=FILE
                    latex preamble file
-f FONTSIZE, --fontsize=FONTSIZE
                    latex base font size
-s SCALE, --scale=SCALE
                    apply additional scaling
-d DEPTH, --depth=DEPTH
                    maximum search depth for grouped text elements
-n, --newline         insert  ewline at every line break
-m, --math            encapsulate all text in math mode
-c, --clean           remove all renderings
-v, --verbose      

Credits

Some of the code is based on the textext extension from Pauli Virtanen.

License

This software is licensed under the GPLv3 license. A copy of the license can be found in LICENSE.txt