I'm not particularly fluent with LaTeX, but I need to generate a bunch of SVG files given the raw input LaTeX code. One way I found to do that was by using a Python script called "latex2svg", located here: https://github.com/tuxu/latex2svg.
I am able to do this successfully in Linux, but not in Windows, and I don't understand why. In Ubuntu, if I run:
sudo apt-get install texlive-full
to install LaTeX, and then create the following Python script (located in the same directory as latex2svg.py):
from latex2svg import latex2svg
myeq1 = r'e^{i\pi}+1=0'
myeq2 = r'\mathbb{Q}'
myeq3 = r'\int_{-\infty}^{\infty}{\frac{e^{\frac{-x^2}{2}}}{\sqrt{2\pi}}}\ dx=1'
eqs = [myeq1, myeq2, myeq3]
for ii, eq in enumerate(eqs):
myeq = r'\( ' + eq + r' \)'
out = latex2svg(myeq)
with open('out{}.svg'.format(ii), 'w') as f:
f.write(out['svg'])
Everything works perfectly, and it generates the SVG files correctly (see them here):
However, on Windows 10, with MikTeX installed, if I run that exact same Python script, I get a warning Warning: libgs not found
, but the script continues and outputs some half-broken SVGs (see them here). I tried to install libgs with pip, but I get this horrible error and have no idea what to do about it.
What do I need to do to get this to work on Windows? Although I have it working on Ubuntu, I would like to understand the issue to get it working in Windows.
I figured it out, even though it took me forever. The issue was that I didn't have the package listed here in the "latex2svg.py" file:
\usepackage[libertine]{newtxmath}
If you remove that line, it renders OK. I'm not sure how to install it on Windows yet but that was the crux of the issue.