Skip to main content

Tiny package to quickly add LaTeX text to your favorite vector graphics package.

Project description

TeXSnip

A small single-module Python package to generate LaTeX text and equations for your favorite vector graphics tool, with no dependencies required! Except LaTeX, of course.

To get started, simply run:

pip install texsnip

With a few lines of Python code, you can create .pdf files that you can then drag'n'drop into Inkscape, Illustrator, Corel Draw, or most other vector graphics programms.

from texsnip import Snip

# Here, you can modify the LaTeX preamble, for example to configure fonts.
# We use the 'libertine' package, the fonts for the current ACM SIGGRAPH template.
preamble = r"\usepackage{libertine}"

# Write the rendering equation to a file called 'rendering-equation.pdf'
Snip("rendering-equation", 8,
    r"$L_o = L_e + \int_\Omega L_i f \cos\theta_i \,\mathrm{d}\omega_i$"
).generate(preamble)

If .pdfs are not supported, don't worry: the script allows you to easily create .png files as well.

Snip("rendering-equation", 8,
    r"$L_o = L_e + \int_\Omega L_i f \cos\theta_i \,\mathrm{d}\omega_i$"
).generate_png(preamble)

If you are using these in presentation slides, you can assemble a list of Snips in a .pptx file (uses .png conversion)

from texsnip import Snip, pptx_snips

# Here, you can modify the LaTeX preamble, for example to configure fonts.
# We use the 'libertine' package, the fonts for the current ACM SIGGRAPH template.
preamble = r"\usepackage{libertine}"

snips = [
    # Write the rendering equation to a file called 'rendering-equation.pdf'
    Snip("rendering-equation", 14,
        r"$L_o = L_e + \int_\Omega L_i f \cos\theta_i \,\mathrm{d}\omega_i$"
    ),

    # Sometimes, you need individual terms
    Snip("omega_i", 14,
        r"$\omega_i$"
    ),

    # Or you might want captions for your illustrations with LaTeX typesetting
    Snip("a-caption", 14,
        r"\textsf{a) Some \textcolor[RGB]{200,110,5}{cool} illustration}"
    )
]

# Lets create a snips.pptx with all these snips in it
# This will also create the corresponding .pdf and .png files for use in other applications
pptx_snips(snips, preamble=preamble)

Dependencies

  • Python >= 3.6
  • LaTeX with xcolor, graphicx, inputenc, fontenc

To generate .png images, you will additionally need:

pip install pdf2image

which requires Poppler to be installed and in the path.

To generate .pptx files, you will need the .png dependencies and also:

pip install python-pptx PyPDF2

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

texsnip-1.0.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

texsnip-1.0.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file texsnip-1.0.0.tar.gz.

File metadata

  • Download URL: texsnip-1.0.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6rc1

File hashes

Hashes for texsnip-1.0.0.tar.gz
Algorithm Hash digest
SHA256 beadf48c1b48a4c39e830c20414f2f6ce9e30a0dcf995b188c027f1a6e24c50e
MD5 75cd122cffe7d47c54eec189ab43da68
BLAKE2b-256 dece1ab6a56b43c89617c5d3b1271e92db2b25b31abe08d236bb0a8e05f34f75

See more details on using hashes here.

File details

Details for the file texsnip-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: texsnip-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6rc1

File hashes

Hashes for texsnip-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c92f0833937746c6d373e8179d8d3fb3c0e0b2242684928016aa472b9fe1c34
MD5 20446f07421f7ba2e9d89de2b95b8d73
BLAKE2b-256 a28b7fd4f0a8aa828b304414057d46f1aa21da596cbad21577787729ab91bf89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page