# Mathematics for HTML Email and Forums

Paul Kates,  Mathematics Faculty Liaison, University of Waterloo
June 9, 2005

## Writing math with simple text or LaTeX math formulas displayed with jsMath

Text
LaTeX math
jsMath
f(x) = sqrt(x + 2) +  | sin(2x) |
f(x) = \sqrt{x+2} + \bigm| sin(2x) \bigm|
f(x) = \sqrt{x+2}+ \bigm| sin(2x) \bigm|
y =  a * x^3 + b * x^2 + c * x +  x^(1/3)
y = a x^3 + b x^2 + c x + x^{1/3}
y=a x^3+bx^2+cx+x^{1/3}
lim{h --> 0}  ( f(x + h) - f(x) ) / h )
\lim_{h\to 0} \frac{f(x + h) - f(x)}{h}
\lim_{h\to 0} \frac{f(x + h) - f(x)}{h}

 f'(x) = lim{h -> 0} f(x+h)- f(x)  ------------ h  f '(x) =  \displaystyle{\lim_{h\to 0} \frac{f(x + h) - f(x)}{h} }  f^{\, \prime} (x) = \displaystyle{\lim_{h\to 0} \frac{f(x + h) - f(x)}{h}} sum{k=1 to infinity}  a_k / k! \sum_{k=1}^{\infty} a_k / k! \sum_{k=1}^{\infty} a_k / k! integral{a to b} sin(t) dt =         -cos(a) - (-cos(b)) \int_a^b sin(t) dt = -cos(t) \bigm]_a^b \int_{\textstyle a}^{\textstyle b} sin(t) dt = -cos(x)\bigm]_{\textstyle a}^{\textstyle b}

## ... more text math and LaTeX math formulas displayed with jsMath

Text
LaTeX math
jsMath
a <= b,  c >= d, e != f, g <> h
a \le b, c \ge d, e \ne f,  g \ne h
a \le b, c \ge d, e \ne f, g \ne h
i << j, k ~ m,  n = = p i \ll j,  k \approx m,  n \equiv p i \ll j, k \approx m, n\equiv p
a in A,  A subsetof B,  C supersetof D
a \in A,  A \subset B,  C \supset D
a \in A, A \subset B, C \supset D
delta f / delta x,  pi,  epsilon,
{\Delta f \over \Delta x},  \pi,  \epsilon
{\Delta f \over \Delta x}, \pi, \epsilon
N natural,  Z integer,  Q rational
\unicode{x2115}\;\unicode{x2124}\;
\unicode{x211A}
\unicode{x2115}\;\unicode{x2124}\;\unicode{x211A}
R real,  C complex \unicode{x211D}\;\unicode{x2102} \unicode{x211D}\;\unicode{x2102}

## What is jsMath?

• jsMath is a javascript program that translates LaTeX math notation written within HTML pages
• the program re-draws the HTML page, displaying  LaTeX-quality mathematics
• the mathematics is not a collection of image files (e.g. gifs),  so there are no extra files to manage
• math notation is added to HTML by editing the source file
• any HTML page can display mathematics - web page, email message, discussion forum - by students and faculty

## jsMath script for HTML

<!-- Use the UW-ACE editor macro feature to record and use the necessary HTML code below -->
<!-- Place before the first use of LaTeX in a question or email. -->
<script src="jsMath.js"></script>    <!-- example only -->

<!-- Write math using LaTeX math notation -->
<!-- Use the SPAN tag for math within a text line -->
If <SPAN CLASS="math"> f(x)=x+2 </SPAN> then
<SPAN CLASS="math"> f(4)=6 </SPAN>.

<!-- Use the DIV tag for math centered and displayed alone on a text line -->
<DIV CLASS="math"> \sum_{i=1}^{n} i = {n(n+1)\over 2} </DIV>

<!-- Some left-aligned display math using html styles -->
<div class="math" style="text-align: left;">
\int^{10}_{1} f(x) dx
</div>

<!-- Place after last use of LaTeX in quiz question or email. -->
<SCRIPT> jsMath.Process() </SCRIPT>

## LaTeX GIFs

In addition to using jsMath for writing LaTeX mathematics, there are tools to create images of mathematics,
which can be included in HTML pages - UW-ACE - for example.

Make a gif image at one of the locations below and cut and paste it into an HTML page.

Roger's online equation editor - a LaTeX to gif  application  (resolution is in pts and indicates the size of the gif, 72 pts ~ 1 inch)
tex2im - similar

AMS LaTeX ref card
Comprehensive LaTeX reference card geared towards AMS maths

Page one of another TeX reference card contains most of the math notation in jsMath except for the LaTeX equation, array and eqnarray environments.

The CTAN home page is the location of up to date LaTeX software and documentation. So is the article on TeX in wikipedia.org. The wiki engine running wikipedia.org takes TeX input and displays high quality math images. Its TeX math formula page is an easy way to look up examples of input math notation.

Advice writing mathematics with simple text is located at  Math Notation via Email and Typing Math.

## Using jsMath with the University of Waterloo learning management system UW-ACE (ANGEL  LMS)

• send me your UW-ACE course name and I'll make the macros of jsMath html available through the shared macro feature
• or, you can read the descriptions of jsMath at its home page and at my UW-ACE course page and create your own macros to share

Paul Kates pkates@uwaterloo.ca, June 9, 2005