Skip to main content

Generates properly baselined images and HTML code from LaTeX formulas.

Project description

based_latex

Generates properly baselined images and HTML code from LaTeX formulas.

Installation

pip install based_latex

Requirements

This package requires a LaTeX distribution, as well as Inkscape and the ImageMagick package (this last requirement may be soon removed).

Usage

Use the function based_latex.save_latex_image(expression, path) to save a LaTeX image of the formula in expression at path. This function also returns two variables prefix and suffix with which you can construct the proper HTML code to embed the image, by simply concatenating prefix + image_url + suffix

import based_latex
prefix, suffix = based_latex.save_latex_image("\\frac{n^2+1}{n!}", "formula.png")
# Image is now saved at formula.png
print(prefix + "formula.png" + suffix)
# <span class="latex" style="position:relative;display:inline-block;vertical-align:0;width:2.125em;height:1.1406em;margin-bottom:0.4062em;"><img style="position:absolute;top:0;left:0;width:100%;height:200%;margin:0;padding:0;border-style:none;border:0;" src="formula.png"/></span>

Some optional parameters of based_latex.save_latex_image, with their respective default elements, are:

density = 512

This parameter is used by ImageMagick's convert command, and is proportional to the generated image's resolution.

factor = 1

HTML code is normally generated to match the element's font, multiplied by factor.

class_name = "latex"

The wrapping <span> element has this css class.

include_static_style = True

(Documentation coming soon)

process_timeout = 2

This is the timeout of the pdflatex and convert (from ImageMagick) commands. After this timeout, the function will raise an exception if, for example, your formula happens to have a syntax error.

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

based_latex-0.0.48.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.

based_latex-0.0.48-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file based_latex-0.0.48.tar.gz.

File metadata

  • Download URL: based_latex-0.0.48.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for based_latex-0.0.48.tar.gz
Algorithm Hash digest
SHA256 5716182412af81a1770dcbd4511edde382162eb0abc0d4526c893888126c8a58
MD5 2868f8f4150921f906854438142fc6e7
BLAKE2b-256 5090f354a8e06208a833508f83bcdf24bcf5059b4bdd001ffcbc521df11afe2b

See more details on using hashes here.

File details

Details for the file based_latex-0.0.48-py3-none-any.whl.

File metadata

  • Download URL: based_latex-0.0.48-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for based_latex-0.0.48-py3-none-any.whl
Algorithm Hash digest
SHA256 40b2b9b5f7cd4c4079db50641ae6d0aa852bb36048774197a05b86d6a8186a8d
MD5 51ef9e6ef96413ac4775e0bdd098edf6
BLAKE2b-256 829558d59c6432fd1a88b5e85eec251dfe0b3930e30c5b0d6eddda78d4e6c0c0

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