How to use render.py #136
-
Here is my dataset demo(200 equations), I call the file use The shell hasn't any error output, but nothing rendered at folder 200. I wrote a small demo for render and it works fine with these data, but I think your code can make more variability for equations, such as font. so I wonder how to use it. import os
from tqdm.std import tqdm
from handytools import op
current_dir = op.parent_dir(__file__)
os.chdir(current_dir)
os.makedirs(os.path.join(current_dir, 'rendered'), exist_ok=True)
formulas = op.readlines("/mnt/d/data/NLP/wikipedia/latex_1024_200.lst")
formulas = [_ for _ in formulas if len(_) != 0]
for i, formula in enumerate(tqdm(formulas, total=len(formulas))):
latex_code = """\\documentclass[preview]{standalone}\n\\begin{document}\n\\[ %s \\]\n\\end{document}""" % formula
op.savelist(
[latex_code], "%s/temp_simple.tex" % current_dir)
os.system('latex2png -d 1080 %s/temp_simple.tex' % current_dir)
os.system("cp -r %s/temp_simple.png %s/rendered/%s.png" %
(current_dir, current_dir, str(i))) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 17 replies
-
The command worked fine for me. My guess is that your there are missing some packages for the latex to compile? \documentclass[varwidth]{standalone}
\usepackage{fontspec,unicode-math}
\usepackage[active,tightpage,displaymath,textmath]{preview}
\setmathfont{%s}
\begin{document}
\thispagestyle{empty}
%s
\end{document} Try to compile it and see if it throws errors. You also need to install some of the fonts used Also what is the |
Beta Was this translation helpful? Give feedback.
The command worked fine for me. My guess is that your there are missing some packages for the latex to compile?
This is my template
Try to compile it and see if it throws errors. You also need to install some of the fonts used
'GFSNeohellenicMath.otf', 'Asana Math', 'XITS Math', 'Cambria Math'
. These are all I could find online. I'd love to have even more though. Because I think this is one of the main reasons why this repo works much better with images found in the wild in comparison t…