I need to convert a latex equation to image format. The better if i can find a DLL (i found a mention of such possibility here: https://stackoverflow.com/questions/10137105/delphi-component-or-library-to-display-mathematical-expressions/10140214 but can not find DLL) that take a latex equation string and return any image format. If it not possible what is a minimum set of files that can do such task, the TeX distributive is large enough, the conversion need only for equations.

  • Are you looking for something like LaTeXIt ?
    – user30471
    Commented Nov 10, 2016 at 23:07
  • Only part that convert latex to image format, no other. The better if they will have a smaller size as possible. Commented Nov 10, 2016 at 23:14

2 Answers 2


If you're willing to move your equation into a separate file, you can use the tools provided by your TeX distribution and need nothing else. I assume you're using TeXlive.

First, you need a file containing your equation with no page numbers, e.g.:




Run pdflatex on this file (say, temp.tex).

Next, run pdfcrop on the generated temp.pdf getting temp-crop.pdf.

Last, run ghostscript on temp-crop.pdf to generate an image file. ghostscript is shipped with TeXlive and the binary is called rungs. A sample invocation can be like this:

rungs -q -dBATCH -dNOPAUSE -dTextAlphaBits=4 -dGraphicsAlphaBits=4
-sDEVICE=png256 -r600x600 -sOutputFile=temp.png temp-crop.pdf

Check this link for usage options and this one for devices/formats.

  • The TeX distribution is very large. I need a simple and rather small solution, like a latex2png.com but in DLL and in-memory transform without using files. Commented Nov 11, 2016 at 16:45

There are lighter TeX distributions, and you could probably strip those down further. Or MikTeX can install packages as required, meaning you could start with a minimum installation. These would still all use an executable with file I/O rather than calling a function in a DLL, because TeX works in a Unix-style way, where passing through files is the norm. It also was developed for systems with very little memory.

Defining the minimum set of files required isn't simple -- it depends what you need in your equations. Do you, for example, need blackboard bold numerals, or triangle symbols, and the ability to combine them. Both of these arbitrary examples would require the ability to add \usepackage to the preamble. You could dump all of the classes except standalone, many of the fonts, TikZ (probably) etc. and save a lot of disk space, but disk space is cheap.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .