A very handy way to embed equations or formulas in a blog or website is to use the Google Charts API. This is an example from their API documentation:

To embed an equation you either need to know TEX or have an equation editor which will export TEX.

For the quadratic equation above, the Tex representation is

x = \frac{-b \pm \sqrt {b^2-4ac}}{2a}

The Google API creates an image from the text string which is passed to an image server. The Tex description of the equation is inserted after 'http://chart.apis.google.com/chart?cht=tx&chl=’. Once you form the link, you can click on it or copy to your web browser address box to see the image.

http://chart.apis.google.com/chart?cht=tx&chl= x = \frac{-b \pm \sqrt {b^2-4ac}}{2a}

Depending on the browser, the spaces and symbols may need to be replaced with escape sequences to directly call the API:

To create a chart which is embedded in a webpage, an image tag is used. The image tag points to a source which is a Google server and it is passed information about how to draw the equation. The Tex description of the equation is inserted after 'http://chart.apis.google.com/chart?cht=tx&chl=’

<img align="middle" src="http://chart.apis.google.com/chart?cht=tx&chl= x = \frac{-b \pm \sqrt {b^2-4ac}}{2a}" />

Since this is an image, all of the things that can be done with an image can be done with the rendered equation. The following table shows a few examples which use some features in the API and in image tag. When adding Google API tags, a lot of problems occur if you do not pay attention to how spaces are used.

## My favorite way to generate Tex for equations

I use LyX as an equation editor. It can be used on Linux, Windows, and Mac computers. A new file can be started in LyX. The equation mode can be started by selecting the equation mode using this button:

By selecting “View>View Source” from the main menu, a preview of the Tex code for the equation appears in the bottom half of the editor. You can create the equation graphically. Once the equation looks good, the Tex code can be copied and combined with the Google API html codes.

## No comments:

## Post a Comment