another latex converter 2 pictures
Project description
Another Latex Converter 2 Image
This is a simple converter from latex to pillow images. The main function is latex_to_image. The input packages_and_commands must include all packages and custom enviroments, custom commands. Just write it as normal latex. In packages_and_commands do not use \begin{document} just simple usepacke stuff and commands! The content argument is the content that should be visualized. This literally can be annything. We are using a real latexcompiler in the backend. out_file_name is a string or None if you don't want a file to bewritten. dpi is the resolution. Higher is better but with more storage.
The output type is a pillow image so you can convert it to a numpy array with np.array(pillow_image) and then go from there. Also ofcourse you can safe it as png with pillow_image.save().
import easylatex2image
from easylatex2image import latex_to_image
packages_and_commands = r"""\usepackage[parfill]{parskip}
\usepackage[german]{varioref}
\usepackage{url}
\usepackage{amsmath}
\usepackage{dcolumn}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{intersections}
\usepackage[all,cmtip]{xy}
"""
content = r"""
\xymatrix{M \ar[d]_\kappa \ar[r]^f & A\\ K \ar[ur]_{f_K}}
"""
pillow_image = latex_to_image(packages_and_commands,content,"output.jpg",dpi=500,img_type="JPEG")
Also with the r before the string you can just pass the latex code as it is without \n or something like that.
Installation
The libary needs miktex (link: https://miktex.org) to be installed. If you have AVast installed miktex might not work. A possible solution would to
- go to menu
- go to settings.
- go to execptions.
- add pdflatex command as execption. Avast also might ask you if you want to make an execptions if you reboot.
Alternative Solution: Use Linux :)
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
Hashes for easylatex2image-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7d07f9c2b7427e804d6200fc7cfddf9cd79b78f9e115f685a37ffb14b5aa3c9 |
|
MD5 | 65626f941b785f4749bb5be368757659 |
|
BLAKE2b-256 | e5b55e13567c0794c524d8d7e48c668f1d26e3e7858d14af770eff58bbdc447f |