Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
LaTeX to PNG on Windows

LaTeX to PNG on Windows


Workaround 1: imgconvert command

imgconvert is not installed by default Chocolatey installer. So, you must create batch file on PATH as follows:

REM imgconvert.bat
magick convert %*

NOTE: On Unix System, convert is used by default. (On Windows, name of convert is registered by legacy name of drive manager)

Workaround 2: gswin32c command

choco install --x86 DOES NOT add executables into PATH. Therefore, must add them by your hands.

If you already have x64 binaries and don't want to additionally install x86, the following workaround may work: (not tested)

REM gswin32c.bat
REM Workaround: Bypassing to x64 binaries
gswin64c %*

Or, use gsexe option.

the Ghostscript executable is usually named ‘gs’ under Linux/U-nix and ‘gswin32c’ under MS Windows and configured this way by default, butthis may be changed using the gsexe setting (5.6.2 Conversion Software)

Step 1: Write code

  $f(t) = 4k(\frac{t}{D})^{3}$
  • border can used as "padding"
  • density affects its output resolution

Step 2: Compile

pdflatex --shell-escape --enable-write18 file.tex

The above command should produce file.pdf and file.png.


  • In modern pdflatex seems to enable --enable-write18 by default. So this may be not mandatory.
  • NOTE: that options must be preceding by filename. eg. pdflatex file.tex --shell-escape ... goes failed.

Injecting command line option into Image Magick

According to 5.6.3 Conversion process Table 2: Advanced Conversion Options, pre-expansion command line template as follows:

command=\unexpanded{{\convertexe\space -density \density\space
\infile\space \ifx\size\empty\else
-resize \size\fi\space -quality 90 \outfile}}

Therefore, \density can be used as good placeholder command line options. eg.

    density=300 -alpha off -background #ffffff,

See Also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment