Trying to properly show an equation on a webpage is not exactly the easiest thing to do, since it often relies on arcane symbols and odd formatting. Never fear, Google is to the rescue.

Google Charts allows you to embed many types of graphs and charts in a webpage using a simple call to the chart api.

That may be wonderful in itself, but there is an even better use for this API, and that is to render equations. All you need to know for that is a little Latex.

This is an undocumented feature so the documentation from Google on this is rather scarce, although it is rather easy to use.

As an example, here is a formula for combinations

and the code required to create it is

<img src="http://chart.apis.google.com/chart?cht=tx&&chf=bg,s,FFFFFF00&chco=000000&chl=\[\left(\!\!\!\begin{array}{c}n \\r\end{array}\!\!\!\right) = {n}C_r = \frac{n!}{r!(n-r)!}\]"/>

The chf parameter sets the background colour of the resulting image, and chco controls the foreground colour. The actual latex code is specified in the chl parameter, which can be any valid latex code.

The possibilities for this are endless.

Thanks to Ryan Moulton who put up a blog post on this same topic where I first saw this feature mentioned.

Share