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
Release history Release notifications | RSS feed
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 based_latex-0.0.35.tar.gz.
File metadata
- Download URL: based_latex-0.0.35.tar.gz
- Upload date:
- Size: 4.5 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
988285ad5f431b9408955c040da23357b870af966a6199f96da2ab43bedcdedf
|
|
| MD5 |
acc9f082e7c6193e3677167f29c30b09
|
|
| BLAKE2b-256 |
6fffefedf369fa501de9b6c342535a141a3732ba1e38689b907f445e2d876a0e
|
File details
Details for the file based_latex-0.0.35-py3-none-any.whl.
File metadata
- Download URL: based_latex-0.0.35-py3-none-any.whl
- Upload date:
- Size: 5.8 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
706890f24f716a5112e2aa3ad36a4e320f82de456069fee98999133691f76f82
|
|
| MD5 |
81efc859d679bcfe9687dafa7964b041
|
|
| BLAKE2b-256 |
08f8fcf7381bf8e29b43cc9d72ce4aa92f9dc99c9d4a69e47518955766f2777f
|