Index‎ > ‎Articles and Hacks‎ > ‎

Google's LaTeX

For people familiar with the typesetting language LaTeX: you already know the power of typesetting beautiful documents using LaTeX (e.g. using MiKTeX, LiveTeX, etc.). LaTeX is used by academics to create formula's and equations.

Google has it's own LaTeX implementation, freely available from the web, to be used in your web-content. Here is an example:

Does look great, doesn't it? Well here's a how-to, to do these nice things on your own website (for example like this Google Site).

<img src="http://www.google.com/chart?cht=tx&chf=bg,s,FFFFFF00&chco=000000&chl=e^z=\sum^{\infty}_{n=0}\frac{z^n}{n!}" />

This will show an image of the equation. Note the URL:

http://www.google.com/chart?cht=tx&chf=bg,s,FFFFFF00&chco=000000&chl=e^z=\sum^{\infty}_{n=0}\frac{z^n}{n!}

  • cht= tx, stands for "TeX". ChT stands for ChartType.
  • chf= bg stands for background, s stands for solid, FFFFFF00 is a 4bit Hexstring which is the colour used to render the background. The latest "00" in the string will make it a transparent image, and uses the other values for hinting the background-colour. ChF stands for ChartFormat.
  • chco= a 3bit Hexstring which is the foreground colour used to render the TeX. ChCo stands for ChartColour.
  • chl= the actual LaTeX string.

The arguments ChF and ChCo are optional. Default is an opaque white background with black foreground. It's very powerful and here are some examples (equations from my latest paper):

 (transparent, black)

\Delta U_{n}(x) = \text{p}\Bigl(\Theta_{n}\bigl(x,\Delta U_{n-1}(x)\bigr)\Bigr)

 (default parameters)

\Delta U : \mathbb{N}\times\mathbb{N}^{+}\rightarrow[\underline{\mathbb{P}}]

 (red, cyan/blue)

\text{p}(x) = \begin{cases}\{x\} & \text{ if }\text{d}(x)=0\\x & \text{ if }\text{d}(x)=1\\\underset{y\in x}{\bigcup}p(y) & \text{ if }\text{d}(x)>1\end{cases}

Since building these LaTeX strings are hard by hand, I recommend using LyX. Then you'd need to convert the LaTeX string into a URLEncoded string, because there are some invalid characters, e.g. ">" and "&".

I hope there will be a WYSIWYG editor by Google for use in Google Sites, but I don't count on it. This way also works quite well.