Login

Welcome, Guest. Please login or register.

November 13, 2024, 10:37:26 am

Author Topic: [Temporary] Rendering LaTeX using the Google Charts API  (Read 1960 times)  Share 

0 Members and 1 Guest are viewing this topic.

Mao

  • CH41RMN
  • Honorary Moderator
  • Great Wonder of ATAR Notes
  • *******
  • Posts: 9181
  • Respect: +390
  • School: Kambrya College
  • School Grad Year: 2008
[Temporary] Rendering LaTeX using the Google Charts API
« on: July 18, 2011, 02:39:48 pm »
0
Hello All,

Since the forum upgrade, we have all noticed that the tags are broken. No idea how long it'll take before it comes back up, so I shall provide an alternative to rendering in the meanwhile.

Google Charts API can draw images using strings specified in the URL. Amongst its many functionalities, it can render . The syntax is
Code: [Select]
http://chart.apis.google.com/chart?cht=tx&chl=YOUR_LATEX_CODE_HERE
To include it into a forum post, simply write the TeX code in a text editor (or simply type it out in the address bar), add in the url calling for the Google Charts API, and use an image tag. Note that URLs do not allow spaces and most special characters, but most browsers these days will automatically convert special characters to URL escaped characters (e.g. " " --> "%20")

e.g.
LaTeX code:
Code: [Select]
\displaystyle \frac{2}{3} \prod_{i=1}^{4}i = 16URL (what you type into the address bar):
Code: [Select]
http://chart.apis.google.com/chart?cht=tx&chl=\displaystyle \frac{2}{3} \prod_{i=1}^{4}i = 16
Browser corrects to URL-escaped characters (i.e. what you get after you press ENTER, copy+paste'd from the address bar):
Code: [Select]
http://chart.apis.google.com/chart?cht=tx&chl=\displaystyle%20\frac{2}{3}%20\prod_{i=1}^{4}i%20=%2016
Forum code (what you type into your post):
Code: [Select]
[img]http://chart.apis.google.com/chart?cht=tx&chl=\displaystyle%20\frac{2}{3}%20\prod_{i=1}^{4}i%20=%2016[/img]
result:







Known issues:
Not transparent (white background).
Multi-line environments (tables, align, cases) don't work very well. This is mostly because the LaTeX alignment character '&' is also special character in URLs, and so must be manually escaped in the LaTeX code. You can use a URI-encoder to convert your text to URL-escaped characters. Even so, the rendering is still not up to scratch.



@Davidb3ck + @enwiabe, please don't get lazy and use the Google API as the LaTeX renderer for AN. :P
« Last Edit: July 18, 2011, 02:46:46 pm by Mao »
Editor for ATARNotes Chemistry study guides.

VCE 2008 | Monash BSc (Chem., Appl. Math.) 2009-2011 | UoM BScHon (Chem.) 2012 | UoM PhD (Chem.) 2013-2015