Typesetting Math Equations
Poking around online, I found references to
MathType and
MathEdit. MathType has a 30-day evaluation version that can be used after the evaluation period expires, a lot of people use this. Most, however, still stated that LaTeX (or at least TeX) was preferred. At first, I couldn't find an easy way to get a rasterized image from a LaTeX file in windows. Eventually, though, I found dvipng, which converts a dvi file to a png or gif (dvi is the standard output format of TeX). It also turns out that it is one of the programs included in MiKTeX. So, here's a quick tutorial on laying out equations using TeX:
TeX Installation, etc.
Windows
The
TeX User's Group recommends
proTeXt (based on MiKTeX), a complete windows-based TeX installation. It's pretty big, though (~540 mb). I tried the TeX libraries from Cygwin to see how they work (in the Publishing package), but didn't have any luck.
Math TeX
Converting to a rasterized image (PNG or GIF)
First, you'll need to convert your .tex file to a dvi file with latex, something like:
latex MySample.tex
The program
dvipng is available for windows and linux, and can convert a dvi output from TeX to a PNG or GIF. A basic run will look like:
dvipng -T tight MySample.dvi
Minimal Document
For a simple math graphic, the following TeX boilerplate can be used:
\documentclass{article} % I tried 'minimal', but it borked some formatting
\pagestyle{empty} % make sure page numbers aren't added
\usepackage{amsmath} % if necessary, or whatever packages you need
\begin{document}
\begin{displaymath} % or \[
... math stuff ...
\end{displaymath} % or \]
\end{document}
Matrices
To create a matrix, use something like:
\begin{displaymath}
\mathbf{X} =
% \left and \right make the braces, the 'array' environment lays out items on a grid
\left( \begin{array}{ccc} % ccc makes the three columns centered, could be l or r
x_{11} & x_{12} & \ldots \\
x_{21} & x_{22} & \ldots \\
\vdots & \vdots & \ddots
\end{array} \right)
\end{displaymath}
Or using the amsmath package to define the bmatrix environment:
\documentclass{minimal}
\usepackage{amsmath}
\begin{document}
\begin{displaymath}
\begin{bmatrix}
x_{11} & x_{12} & \ldots & x_{1n} \\
x_{21} & x_{22} & \ldots & x_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
x_{m1} & x_{m2} & \ldots & x_{mn}
\end{bmatrix}
\end{displaymath}
\end{document}
Setting up vertical bars, boxes, etc:
\documentclass{article}
\pagestyle{empty}
\usepackage{amsmath}
\usepackage{array}
\begin{document}
\[
\overrightarrow{A}=
\begin{bmatrix}
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\ \hline
\multicolumn{1}{|c}{1} & 2 & 3 &
\multicolumn{1}{c|}{4} \\ \hline
1 & 2 & 3 & 4
\end{bmatrix}
\]
\[
\left[
\begin{array}{cc|c|c}
1 & 2 & 3 & 4\\
1 & 2 & 3 & 4\\
1 & 2 & 3 & 4\\
1 & 2 & 3 & 4\\
\end{array}
\right]
\]
\end{document}
Setting Up TeXnic Center
To set up TeXnic Center to have a latex => PNG output profile, go to build->Define Output Profile. Copy the LaTeX => PS profile, and name the new profile LaTeX => PNG. The (La)TeX tab can stay the same, modify the postprocessor tab by changing the executable to point to dvipng (in the bin directory), and put the options:
-T tight -o "%Bm.png" "%Bm.dvi"
which will create the png file with the same name as the tex file (%Bm is the full path minus the type extension with backslashes, use %bm for forward slashes), with tight bounds so only the printed area is visible. To use windows picture and fax viewer as the viewer, go to the Viewer tab and change 'path of executable' to
C:\windows\system32\rundll32.exe
Under 'view project's output' click 'command line' and change it to
C:\windows\system32\shimgvw.dll,ImageView_Fullscreen %bm.png
and change the other options to 'command line' and leave them blank. That should be it!
LaTeX and TWiki
- !MathModePlugin is a plugin that uses a LaTeX environment to automatically generate latex-rendered math, need to have a look at it.
Other Possibilities
- Need to look at mimeTex and jsMath -- easy ways to embed LaTeX math
- TeX4ht -- TeX for hypertext -- not sure how robust it is
See Also
External Links
--
SamPreston - 05 Apr 2007