gladtex(1) generate html with LaTeX equations embedded as images

## SYNOPSIS

gladtex [options] <FILE1> [<FILE2> ...]

## DESCRIPTION

Reads a 'htex' file (html with LaTeX maths embedded in <EQ></EQ>) and produces html with equations substituted by images.

## QUICK START

Write HTML code as usual, but use LaTeX equations within the tags <EQ>..</EQ>. Don't use .html extension, .htex is recommended. Now, run:

   gladtex -v myfile.htex


Or, to process multiple files:

   gladtex -v *htex


The -v option is not mandatory, but gives you more feedback. If there are no LaTeX errors, this will generate the file myfile.html (or similar) and numerous eqn???.png files, which contain images of your equations. The HTML file generated is a copy of yours, but the equations are substituted by links to the image files.

If you prefer gif files, add the option -f gif''.

gladTeX tries to avoid regenerating identical image files. To achieve this, a cache file (gladtex.cache) is used, containing the equations used for generating each image. If you delete the image files before rerunning gladTeX, you should also delete the cache file (gladTeX never deletes an image file).

If your HTML contains more than a couple of equations, it is a good idea to place equation images in a separate directory with the -d option. With this option turned on, the cache file is also moved to that directory.

## OPTIONS

You can optain the command-line help using gladTeX without options.
-a
Save text alternatives for images which are too long for the alt attribute into a single separate file and link images to it. In <img alt/>-attributes, you can only have up to 255 characters. Since equations with line breaks / long equations don't fit in there, this switch allows outsourcing in a file called desc.html in the directory specified with -d or the current directory by default.
-b colour
Set background colour in RGB manner. This option can also be set indivdually for each equation by writing <EQ BGCOLOR=...''> in the htex file. For PNG format with transparency on, this option has no effect. For GIF format (which does not support alpha channel, as far as I know), antialiasing is done from the foreground color (-c option) to the background colour, so the background colour should be set even with transparency on.
-c colour
Set foreground colour in RGB manner. For instance -c 00FFFF'' gives yellow text. This option can also be set indivdually for each equation by writing <EQ COLOR=...''> in the htex file. See also -b option.
-d path
Store image files in the path given. The image links in the generated html file(s) will be made relative. If you need absolute links, use the -u option in addition.
-e env
Use the specified LaTeX environment instead of displaymath'' when generating the image. This option can also be set individually for each equation by writing <EQ ENV=env''>.
-f format
Use the specified image format in output files. Formats supported may depend on compile-time decisions. At the time of writing, png and gif are the ones supported.
-i class
Assign the specified CSS class name to images whose environment is math''. Defaults to inlinemath''.
-l class
Assign the specified CSS class name to images whose environment is displaymath''. Defaults to displaymath''.
-p string
Add this string to the LaTeX preamble when generating the equations. For example, string'' may be a \usepackage{} command. Note that if you need this for only a few equations, you can also write <EQ PREAMBLE=...''> in the htex file.
-r dpi
Set resolution of output images, larger numbers produce larger images. 100 dpi is default. This is most often a bit larger than surrounding text, but as LaTeX output is really intended for hires output, details will often disappear at lower resolutions. Do some experimenting. This option can also be set indivdually for each equation by writing <EQ DPI=...''> in the htex file.
-s n
Set oversampling factor. Larger values will increase antialiasing verbosity, but is slower. The default is 4. A value of 1 turns off antialiasing, which I don't recommend.
-t
Disable transparent background. With this option, the background colour (-b option) is solid.
-u url
Set absolute url to the image files folder. Use this together with -d option if you can't use relative links for some reason.
-v
Verbose mode, give extra feedback. Gladtex is pretty silent without.

## eqn2img UTILITY

The gladTeX script just parses your html-code and feeds the equations to the C program eqn2img. This takes care of running LaTeX, dvi2ps and ghostscript. Furthermore, it finds the baseline of the equation (guided by a dot that is inserted into the equation), antialiases and writes the image in the final format. All this is independent from the gladTeX script, for instance you may write

   echo '\sqrt{2}' | eqn2img > sqrt.png


to produce an image of the squareroot of two. For normal operation of gladTeX, you never use this utility directly, but in any case, here are (some of) the options.

-f format
Use the specified image format in output files. If format'' is just a question sign ?'', eqn2img will print a list of supported formats and quit.
-s n
Set oversampling factor (see description of same option for gladTeX).
-o name
Set output filename. Without this option, the image is written to stdout.
-c colour
Set foreground colour in RGB manner.
-b colour
Set background colour in RGB manner.
-t
Turn transparency off.
-v
Verbose mode, give some feedback.

All messages are written to stderr. Furthermore, a text string specifying the dimensions is written to stdout, unless the image is being written to stdout. In this case, the dimension string is written to stderr.

Note that eqn2img will only process one file at a time.

## PARSING DETAILS

Gladtex is not case sensitive, so <eQ> is allright. Any <eq> tag must be closed by a </eq>. Whitespace between <eq'' and >'' is allowed. Certain options (such as COLOR=...'') may be present in the tag, see the Options section above. Whitespace is not allowed anywhere else, so < eq>'', < /eq>'' and </eq >'' are all illegal. I'm not quite sure how this agrees with html standards/conventions.

## THANKS

I am grateful to all users who have provided feedback. The current version of gladTeX incorporates suggestions from a number of helpful users.