2022-07-15 12:40 UTC
  • Xyne


Description: Convert TeX and LaTeX to PNG images.
Latest Version: 2014.12.28
Source Code: src/
  • any
  • texlive-bin
  • texlive-latexextra
Arch Repositories:
  • [xyne-any]
  • [xyne-i686]
  • [xyne-x86_64]
AUR Page: tex2png
Arch Forum Thread: 97433


tex2png easily converts \mbox{\TeX} and \mbox{\LaTeX} to PNG images. It is a simple wrapper around “latex” and “divpng” that was originally written for the backend of this website to enable easy insertion of mathematical formulae. Using the options “-i” (inline) and “-T” (tight), images can be generated automatically and inserted into web pages using scripts to generate the correct HTML/CSS from the reported image depth and height.

When using the “-T” option, single-page images of arbitrary size can be created.


The equation \phi_n(\kappa) = \frac{1}{4\pi^2\kappa^2} \int_0^\infty \frac{\sin(\kappa R)}{\kappa R} \frac{\partial}{\partial R} \left[R^2\frac{\partial D_n(R)}{\partial R}\right]\,dR was generated from

$\phi_n(\kappa) =
 \frac{1}{4\pi^2\kappa^2} \int_0^\infty
 \frac{\sin(\kappa R)}{\kappa R}
 \frac{\partial}{\partial R}
 \left[R^2\frac{\partial D_n(R)}{\partial R}\right]\,dR$

with tex2png and inserted automatically into this page using a script. As you can see, the image is vertically aligned to its context. Simpler examples include x^2 and \gamma.

Help Message

$ tex2png --help

  tex2png - convert (La)TeX to PNG images

  tex2png [options] [-- <dvi2png args>]

  A (La)Tex string can be passed either as a command-line parameter or via
  STDIN. When manually entered via STDIN, use ctrl+d to terminate input.

  -b <color spec>
    The background color to pass to dvipng's "--bg" option. It should be given
    in TeX color \special syntax, e.g. "rgb 0.2 0.2 0.2". "Transparent" and
    "transparent" are also accepted. See the dvipng help message for more
    details. Default: 'transparent'

  -c <string>
    The (La)TeX string.

  -d <path>
    The output directory. See below.

  -D <int>
    The dpi argument passed to "dvipng". Default is 100. Increase this to
    increase font size.

    Specify the full input document. By default, tex2png provides its own
    headers and wraps the input in document tags. This option enables the user
    to provide a full (La)TeX document with custom headers.

    Inline mode. This will include the height and depth in the output, which can
    be used for vertical alignment in web pages, e.g. This should only be used
    when the tex contains mathematics.

    Display this help message.

  -o <path>
    The image path. See below.

  -p <int>
    Page number to render. Default is 1.

  -t <path>
    The temporary working directory. A random directory is created with "mktemp"
    by default.

    Crop whitespace around the content (dvipng -T tight).

  If the image path is set then it is the full path to the image. If it is not
  set then the image name will be the sha256 digest of the (La)Tex input string
  with the ".png" extension. If the output directory has been set then the image
  will be saved there, otherwise it will be saved in the current directory.

  All arguments following "--" will be passed directly to dvi2png. See the
  dvi2png man page for details.
echo xyne.archlinux.org | sed 's/\./@/'
XHTML 1.0 Strict CSS level 3 Atom 1.0