GladTeX is a utility for creating images of mathematics equations. This page describes an outdated version of GladTeX for Windows created by Erik Neumann, first released September 2004. See also Displaying Math on the Web.
As of 2017, GladTeX development has resumed at https://github.com/humenda/gladtex. please see that page for the current version. There is a Windows version at https://github.com/humenda/GladTeX/releases.
This version of gladTeX is based on gladtex 0.3 by Martin G. Gulbrandsen copyright (C) 1999-2002. Please see the readme
file in gladtex 0.3 which spells out the GNU General Public License terms.
Here is an example of an equation produced by gladTeX. To see how this equation is created in gladTeX, see Displaying Math on the Web.
This version of gladTeX is different from gladTeX 0.3 in the following ways:
.tex
file in the same directory where the .png
file is created. When gladTeX is asked to render a certain LaTeX expression, it first scans all the available .tex
files to see if that expression has already been rendered. If so, it just uses the existing .png
file with the same name.
vertical-align
style attribute in the <IMG>
tag like this: <IMG style="vertical-align: -13px; margin: 0;" width="20" height="30">
alt
property to <img>
tags.alt
property specifies a text equivalent for an image, which is important for visually impaired users, or for display on alternate devices or text-only browsers. The alt
property is required under HTML 4.01. This version of GladTeX automatically adds the LaTeX form of the equation as the alt
property. You can see the alt
text by hovering your mouse over the equation image in many browsers.
grep
to search for existing files. Since Windows command-line arguments are wrapped in double-quotes, we pass the LaTeX expression wrapped in double-quotes. So, a double-quote in the LaTeX expression would break that part of the process. This is not a big problem since double-quotes are pretty much not used in LaTeX anyway! (LaTeX requires use of two single quotes like '' or back quotes `` instead). If you really need a double quote you can use \\symbol{34}
instead. (Note that this limitation could be eliminated by writing the search argument to a file instead of passing it via the command-line).
As of 2017, GladTeX development has resumed at
https://github.com/humenda/gladtex.
please see that page for the current version. There is a Windows version at
https://github.com/humenda/GladTeX/releases.
For archival purposes, you can access the outdated version of GladTeX. The rest of this page describes that outdated version.
Get the two files (that are part of this software release):
eqn2img.exe (compiled for Windows OS) gladtex.pl
and put them somewhere that can be found by the Windows command line. In addition you will need the following:
latex
and dvips
(I use MikTeX).grep
gswin32c
.With this version of gladTeX, libpng
is part of eqn2img.exe
, so you don't need to install libpng
on your own.
Before trying to use gladTeX, you should be able to run latex on a simple .tex
file, and turn it into a .dvi
file (try viewing it with a .dvi
viewer like Yap which is part of MikTeX). You should also be able to give the commands listed above (perl, latex, dvips, grep, gswin32c
) at the command line.
Put
<eq>...latex code here....</eq>
in your .html
file. But rename it to have the .htex
extension. Then invoke gladtex by:
perl gladtex.pl [options] myfile.htex
where [options]
are described in gladtex.pl
.
For inline equations use
<eq inline=1>...latex code here...</eq>
This will result in special processing so that the equation image lines up with the other text on the line.
I have some additional examples of GladTeX usage available. Please see the official gladTeX site for additional usage information.
The perl file gladtex.pl
is a perl text file. The source code for eqn2img.c
is provided here in case you want to try to build it yourself. There are some additional .h
and .c
files:
getopt.c
is code for a command line parser.direct.h
header is for directory operations like _chdir
(direct.h
comes with Visual C++ and is not included here)png.h
is the header for libpng
(comes with libpng
and is not included here).
You will need to obtain libpng
and zlib
if you want to compile eqn2img.c
. This is rather involved when using VisualC++ on Windows, see the accompanying file 'libpng notes.txt'
for more information.
I've made various changes to eqn2img.c
so that it compiles and works on Windows. In addition some other changes I made were:
-i
option to specify when an equation is inline with the text. Those equations are handled specially. They result in the <img>
tag having a style="vertical-align"
property so that they line up with the other text on that line. (In the old version of eqn2img
this was done by increasing the size of the image, so that align=middle
property would line it up, but that resulted in large spaces between lines of text).
-e
option to specify the equation on the command line.
.tex
file that is created. It is used by gladtex to see if a .png
image can be reused.
alt
text for the <img>
tag.
This web page was first published September 2004.