I finally got access to a Google Wave sandbox account, making it possible to start experimenting. The first thing I made was a Latex robot. By adding the robot, it's possible to write Latex in Waves. Afterwards, simply by putting Latex between two $'s:
\lim_{n \to \infty} \frac{1}{n} = 0$$Watexy then changes the Wave and inserts the Latex as an image instead of the text.
You can try it yourself by adding watexy [this-funny-curly-a] appspot.com to your Wave-conversations. You can download the source here.
There's still a quite big bug: It's only the first Latex-image that gets substituted correctly. The following gets inserted some positions wrong, and the deletion of the text isn't correct neither. But the images itself are correct, only the substitution isn't working properly. But I'm working on that!
The more technical part: the robot is written in Python, hence using the Google Wave Python API. It's the first time I've tried that (thought it was a good possibility to learn it). The robot basically works by getting triggered when a new blip is submitted. Then it searches for Latex-code in that and substitutes it with pictures. Although the code is quite simple, it shows some very basic concepts on how to alter/change the contents of Waves on-the-fly (deleting text and inserting images, but it could be other things as well) with robots. The Latex-source-to-image is done by the http://www.forkosh.dreamhost.com/source_mathtex.html#webservice service.
The core Python comprising the robot is this:
# Python reference: # http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/index.html # Shortcut to the important OpBasedDocument # http://wave-robot-python-client.googlecode.com/svn/trunk/pydocs/waveapi.ops.OpBasedDocument-class.html """ Known bugs: - From (and including) the second Latex-fragment, the positioning gets wrong > Probably the document needs some kind of updatering > Even though it's a bit strange since the re matches all the Latex correctly """ __author__ = 'mikl@mikl.dk (Mikkel Meyer Andersen)' import re from waveapi import events from waveapi import model from waveapi import robot from waveapi import document def OnRobotAdded(properties, context): """Invoked when the robot has been added.""" root_wavelet = context.GetRootWavelet() root_wavelet.CreateBlip().GetDocument().SetText("Hi. My name is Watexy and I'm here to help you presenting Latex in waves. Just put the latex between " /> and2+2=5
) def OnBlipSubmitted(properties, context): """Invoked when a blip has been added.""" blip = context.GetBlipById(properties['blipId']) blip_text_view = blip.GetDocument() latex_regex = re.compile('\$\$(.+?)\$\$') m = latex_regex.search(blip_text_view.GetText()) """ Only replace one Latex-fragment at a time, because replaceing one fragment changes the text positions in the rest. That's why re.finditer isn't used. """ while m != None: """ The +/- 2 is because of the length of the " />'s. If not removed, the loop will run infintely! """ blip_text_view.DeleteRange(document.Range(m.start(1)-2, m.end(1)+2)) image = document.Image('http://www.forkosh.dreamhost.com/mathtex.cgi?' + m.group(1), caption=m.group(1)) blip_text_view.InsertElement(m.start(1)-2, image) m = latex_regex.search(blip_text_view.GetText()) if __name__ == '__main__': myRobot = robot.Robot('watexy', image_url='http://watexy.appspot.com/assets/icon.png', version='9', profile_url='http://watexy.appspot.com/') myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded) myRobot.RegisterHandler(events.BLIP_SUBMITTED, OnBlipSubmitted) myRobot.Run()



July 31st, 2009 at 01:16 (UTC)
A live-demo is available at:
https://wave.google.com/a/wavesandbox.com/#restored:wave:wavesandbox.com!w%252BnW6AFIIa%2525A
July 31st, 2009 at 01:17 (UTC)
Well, you have to copy the entire URL - for some reason WordPress apparantly doesn't think ! is valid in a URL.
August 2nd, 2009 at 15:49 (UTC)
If you added linefeed and caret return to the regex, wouldn't it work with multi-line entries as well? That'd be very useful for matrices for example.
August 2nd, 2009 at 22:35 (UTC)
Yes, if the LaTeX-webservice supports it. But I'll give it a try. Thanks!
August 10th, 2009 at 08:07 (UTC)
I'll also change the way the robot introduces itself so that the waves doesn't get too messy/spammed.
September 18th, 2009 at 19:30 (UTC)
Tried it out. Cool Robot. Good work!
Your invited to join our forums at http://www.googlewaveblogger.com and share your development efforts. I then blog about the developers that have joined the forums.
Cheers! Good luck with the work.
October 1st, 2009 at 14:21 (UTC)
The robot works well. Are you planning to develop it further? For example it would be even nicer if it could show the original LaTeX source when I am editing a blip.
October 4th, 2009 at 22:41 (UTC)
Hi Gustav. Thanks. Yes, I am planning to develop it further, but have been really busy the last couple of weeks, but hopefully I'll find the time very soon
.
October 6th, 2009 at 21:20 (UTC)
This is great, I'm going to have to give it a go soon. If you'll allow me to share my dream LaTeX plug-in, perhaps it will inspire someone.
First start off with your robot.
Now let your robot help me when I'm confused. Say I type in
or something.
Then I'd love it to do something like this:
http://detexify.kirelabs.org/classify.html
While just having it link me to that site would be ok, in my dream I imagine that it would include a drawing pad into the wave. Then let me draw a symbol. And then I could click the one I like and it would include the correct LaTeX for me.
/dream
Cheers and thanks for the plug-in
October 10th, 2009 at 04:21 (UTC)
Try http://chart.apis.google.com/chart?cht=tx&chs=1x0&chf=bg,s,FFFFFF00&chco=000000&chl=$$ $$
Someone on Reddit mentioned it.
October 10th, 2009 at 04:26 (UTC)
I mean,
http://www.reddit.com/r/math/comments/9pxpm/looks_like_google_docs_added_latex_support/
October 11th, 2009 at 03:08 (UTC)
Hi,
I like your bot. If there is one major thing it needs its this. I'm frequently revising the LaTeX command and the bot deletes it. It would be great if it inserted the original command in small grey print so I can reuse it. alejandro.erickson googlewave.com
October 13th, 2009 at 14:00 (UTC)
Hi,
I've made a similar robot, but also an Equation gadget to go with it, this means rather than replacing the equations with images, I replace them with an editable gadget. I'd be keen to collaborate with others on making Wave more useful for scientists.
If you have access to Wave preview you can learn more about the gadget/bot here:
https://wave.google.com/wave/#restored:wave:googlewave.com!w%252B4muyQgqQR.2
otherwise I will be putting more info up soon at http://waveyscience.appspot.com .
October 13th, 2009 at 15:47 (UTC)
Hi,
I had some time to spare today and I decided to port the robot over to Java. I hope you don't mind.
I also added the grey out feature that some of the commenters here requested. It's a bit wonky due to the current state of wave, though.
October 23rd, 2009 at 20:44 (UTC)
I just thought about the advances of a bot like this in my car today.
Amazing work, thank you!
October 28th, 2009 at 06:10 (UTC)
Great robot. One thing that I'm really missing when using it is the ability to define my own commands (in the preamble). For instance, I like to give the symbols I commonly use short names (e.g. \newcommand{\Rsp}{\mathbb{R}}).
Is it possible to add such an ability to watexy?
I skimmed through the mathtex page, they clearly let one add \usepackage, but I don't know about \newcommand.
Ideally, I think one could put commands into preamble within watexy's original response (or in reply to it), and they'd be used in all subsequent parsings.
November 9th, 2009 at 18:09 (UTC)
THIS ROBOT ROCKS!!!
November 10th, 2009 at 18:48 (UTC)
Hi! Great robot!
The 2 equations problem is a bit annoying, though. It is hard to write only one eq. per blip.
Did you try to go through m in reverse order? Last to first? Then the positions of all the preceding equations will not be changed...
November 11th, 2009 at 00:03 (UTC)
Please notive the update at
http://www.scienco.org/2009/watexy-version-12-now-supporting-multiple-equations-in-one-blip/
November 20th, 2009 at 17:18 (UTC)
It would be nice to also have a version of watexy which behaves more like a latex editor.
I.e, that watexy replies to your wave, and watexy updates it's reply as soon as you edit your original message. In this way you could use watexy really as a collaborative latex editing tool.
Like watexy is now it's easy for in chat like an mail like usage. But the ability to be able to edit your latex code afterwards would really enable collaborative edditing.
December 1st, 2009 at 22:56 (UTC)
i agree with Maarten Derickx. also, will it say hello with that message every time i'm gonna add it to a wave? that would so boring
December 2nd, 2009 at 06:56 (UTC)
Thanks for the comment, lostella. You're probably right. I better remove it, but because I'm travelling at the moment it'll take some weeks before it's done.
December 2nd, 2009 at 19:23 (UTC)
Congratulations, great robot!!
I have I suggestion. Has anyone though about having different waves for the source (.tex wave) and the compiled version of it (.dvi wave)?
The latter could be read-only.
Watexy as it is now is a great tool for discussion.
However, if at a certain point you decide you want to write a proper latex document, you cannot do it in collaboration.
Furthermore, now you can't reuse the wave to write a tex. At least not easily. Having access to the source would allow its reuse.
I just throw the idea. Don't have any clue on its viability.
Tanks for watexy!
Pablo Arias
December 4th, 2009 at 10:24 (UTC)
Very nice bot! In order to be able to use the document which has been elaborated in the wave, it would be very nice to be able to export the text with the original latex code contained. The

mode seems to store the original latex, so it should be quite easy to get the document with latex code out of the wave? (In order to run it with latex and pubish the paper for example) The bot could answer to a command with this complete text+latex code.December 9th, 2009 at 21:47 (UTC)
Nice!
$$ doesn't work for me, and the images aren't completely rendered always, but heck; wave isn't out yet
December 10th, 2009 at 02:38 (UTC)
That sounds a bit strange. I just checked it and the images showed up as usual. I haven't checked the actual $$ to image conversion, but I haven't change anything. But maybe Wave have been updated and bugs have been introduced. It's certainly been seen before. Let's give it some time.
December 10th, 2009 at 08:07 (UTC)
First of all, thanks for your work. I have tosay that I have the
! only show as missing picture icons.
same problem here too. Formulas between
February 14th, 2010 at 00:31 (UTC)
[...] agents/bots and arbitrary Javascript extensions is more useful. For example, someone has written ‘Watexy’, a Wave bot which can interpret Latex [...]
February 24th, 2010 at 19:18 (UTC)
This is a really neat robot. We're trying to use this in class to post homework solutions. It's wonderful to have real equations in the text. And students can comment or even correct the solutions which is fun.
However, we're having a lot of trouble with images not being rendered. There seem to be some serious bugs in the current version. Images show up as lines, and I have to double-click on them to get the edit box and then the rendering is shown. I know the students are going to complain (and blame me!).
Am I doing something wrong? Are there any bot updates / bugfixes to correct this?
Thanks again for your effort with this important project.
February 24th, 2010 at 19:30 (UTC)
Thanks. I'm sorry for the trouble. It seems like the server can't always cope with the pressure, although I'm not entirely sure that's the real problem. The reason is that right now Wave doesn't allow robots to attach images inline in waves, hence the wave has to get the image from the server every single time. This is not optimal - not at all - but it's the only solution for now.
Another solution is to use MathML, and I'm also working on that. But for know it's really not that supported, so I'm not planning on releasing anything shortly.
The problem with you having to click the image can be caused by two things: either it's simply not generated (which I don't think is the case, because then you probably wouldn't be able to see it when editing), or wave's auto-height adjusting is terrible (sorry, Google). As far as I have experience, it's only an issue with block math, so maybe try with inlining equations (although it doesn't give you the possibility to edit, again because Waves doesn't support inline Gadgets).
So there's still som bugs, but as you can read, I believe that the most is caused by Google
.
Please keep commenting and posting experiences!
February 24th, 2010 at 22:06 (UTC)
Thanks for the reply. Let us know if there's any way we can pressure Google to address this.
I like the MathML idea--would this give us real fonts rather than images? That would be much nicer on the eyes.
The LaTeX input form is wonderful and I think the best solution for writing equations.
Would cut-and-paste from the Word equation editor ever be possible? Seems like that could be encoded in MathML. Its LaTeX-like entry and immediate conversion to math fonts is wonderful and might be a goal to strive toward with this package.
Thanks again.
February 25th, 2010 at 06:48 (UTC)
Yes, I'll do that. Thanks.
Yes, that is what MathML would mean. You can take a look at e.g. http://en.wikipedia.org/wiki/MathML . But the downside is that additional fonts is required to be installed for MathML to work.
Regarding c'n'p from Word, I'm not sure. I actually haven't thought about it before you mention it. I'll keep it in my mind, but it's a low priority if it's even possible.
February 25th, 2010 at 15:13 (UTC)
Hi Mikkel,
We are experiencing even more trouble today. Perhaps we just have too much watexy content on one page?
Would you consider examining our page to see how we are using it and see if you can identify why the robot is being crazy?
My wave account is jeffreyjgray@googlewave.com -- or email me at jgray@jhu.edu and I can invite you to the wave with our homework solutions.
I would appreciate any insight you could offer. It's really important for us to have equations in this document and the wave+watexy seemed like a great way to do it, but at this point the problems are making it very difficult for us.
Thank you for considering the help.
Jeff
March 10th, 2010 at 11:43 (UTC)
[...] Durch Plugins bzw. Extensions lassen sich sogar Mathematische Formeln einfügen und bearbeiten (Watexy). Besonders in der Phase der Prüfungsvorbereitung haben wir gute Erfahrungen damit gemacht. So [...]
April 9th, 2010 at 15:37 (UTC)
Hi there,
Thanks for writing your Watexy robot - I'm already using it for collaborating with my colleagues.
If I might may a small request/suggestion --- would it be possible to make inline TeX formulas (thus those invoked using
) appear slightly lower in the line? They look a bit out of place at the moment.
Thanks again,
Konstantin
May 11th, 2010 at 13:15 (UTC)
[...] Update [2009-10-03]: Some other things worth a mention: online LaTeX editors like MonkeyTex (but no one really likes editing in anything other than their familiar environment), a page at Wikibooks based on one of the PracTeX articles mentioned above, and, coming Real Soon Now, support for LaTeX in Google Wave.(link.) [...]
July 7th, 2010 at 08:49 (UTC)
There is a LaTeX and Google docs - online viewer, pdf compiler, editor
http://docs.latexlab.org
July 7th, 2010 at 12:49 (UTC)
Thanks for the link!
July 21st, 2010 at 05:34 (UTC)
[...] Watexy- A Google wave robot for Latex writing (watexy@appspot.com) [...]