François Pinard's site

2009-08-02

Tomboy, Web and maths

Seeing the tomboy-LaTeX add-in for Tomboy, I decided to give it a try. Here are my first impressions.

More it goes, more I use Tomboy for taking notes and organising my work in various ways. Many pages on my Web sites are now Tomboy notes, converted to HTML using my tboy and site.mk machinery. The Tomboy page holds, near its beginning, a few links yielding to other Tomboy-related comments of mine.

Popping an existing Tomboy note, either through the menu of recently edited notes, by following a link from another note, or though the search facility, is easier to me than traditionally looking for a file and calling an editor on it. Slight or moderate edition is immediate and simple within Tomboy. So I converted many of my previous reST or HTML notes to Tomboy, knowing they are going to be easier to manage, while being converted back to HTML of quality comparable to what it was before. Granted that reST is far more expressive, yet I found out that I do not need all of reST power on the average.

I have a few notes, not so many, which are a bit more mathematically oriented, and for which I used a kind of character art for representing the formulas. So, when I recently stumbled on the tomboy-LaTeX page, I felt it might be worth a try. I'm not really setup to compile C# code, and did not succeed at compiling Tomboy from sources the last time I tried, so I feared tomboy-LaTeX might be difficult to install. But to my pleasure, it went rather well: the add-in compiles simply and quickly, independantly of Tomboy itself. The activation of the add-in is also a simple matter.

I initially found tomboy-LaTeX suprisingly speedy. I was expecting worse, given that for each mathematical snippet in a Tomboy note, processing or external programs are needed for generating a LaTeX source, and for turning it successively into DVI, then PostScript, then PNG. But that speed impression vanished when I started using LaTex within real, actual notes. The conversion appears fast enough indeed, but the overall edition crawls to the point of irritation: the cursor often disappears out of sight for many seconds, and inserting or deleting a single character often take a long time. I presume this is related to the number of formulas in a single Tomboy note, but am not sure. However, when there is no or little math involved, like in this very note I'm writing, everything is speedy as normal.

Using LaTeX in my case in only acceptable if it can be extended to automatic HTML conversion, so this was the natural next step. There does not seem to be a universally supported way to embedd images within an HTML page, we can only include references to external images. This means that we need ways for naming each mathematical snippet extracted from Tomboy notes, turning these into images, caching the work already done so to avoid useless regeneration, recovering the cache if it existed already, and cleanup of images which are not needed anymore. Everything being fully automatic, of course.

I'm not overly satisfied with the result, even if is acceptable to a certain extent. See the page choose(n, k) is an integer! for an example, which I criticize at least on these two points:

  • The mathematical images maybe aligned either top, center or bottom (which is the default), and best is to center formulas within the surrounding text. However, at least within Firefox, the image is apparently centered with respect to the base line of text, while it would be nicer to center it with respect to the center of text. When the formula does not use more than the vertical width of a line, this is clearly too low, so I tried to use bottom alignement for those, which yields an image which, despite being too high, is less shocking. It is uneasy to decide, while generating the HTML, if a formula uses a single line or not, so I felt back on the naive heuristic of checking if the formula contains any curly brace — which are needed whenever LaTeX coding is a bit more complex — as simple formulas, like variables, do not need any on the average.
  • The font used for mathematical rendering is a bit small, and I am not familiar enough with LaTeX for resizing it. For the HTML rendering, I merely reused the recipes found within tomboy-LaTeX source code — all hails to source code! The small font problem is especially noticeable with my notation. I was not patient enough to try more substantial LaTeX, in view of really using the rendering I hoped for, so this is a compromise. tomboy-LaTeX does not provide an easy way for augmenting LaTeX with one's own definitions, as each mathematical snippet starts with a virgin environment.

Within Tomboy itself, tomboy-LaTeX uses bottom alignment, which is not ideal, and even a bit ugly at times. Nevertheless, previewing the rendered mathematical formulas within Tomboy notes, almost in real-time, is a comfortable capability.