This isn’t really programming related at all, but here’s a way to do this:
- Use the class
standalone
in your LaTeX source file. This will produce a document that is exactly as large as needed, and no larger.
- Produce a PDF file using
pdflatex
…
- Convert to JPEG using
convert
(from ImageMagick).
Minimal example:
\documentclass{standalone}
\begin{document}
\[
\sum_{i=1}^n i
\]
\end{document}
convert
with appropriate resolution:
convert -density 400 file.pdf -scale 2000x1000 file.jpg
Caveat: standalone
has some issues determining the size of the document. I don’t actually like the results it produces. You may require loading the geometry
package and setting the document dimensions manually. This requires a bit of fiddling but the results are much better.