*KAP* (8kap8) wrote in suggestions,

Using jsMath to render math formulas

Using jsMath to render math formulas

Short, concise description of the idea
Use jsMath package allowing users to easily typeset math formulas anywhere on LJ.

Full description of the idea
Currently, there is no way to insert math formulas into LJ posts or comments except via images or by using HTML markup like sub and sup tags. The former way is very time-consuming and does not allow easy editing, while the latter allows one to produce only the simplest formulas, and even those will be of rather poor quality.

jsMath (http://www.math.union.edu/~dpvc/jsMath/) is a javascript package that enables the authors of web pages to insert math formulas into their pages so that the visitors of the pages will see it beautifully typeset. By using javascript it does all the required processing client-side. The output looks very similar to that of (La)TeX (see examples http://www.math.union.edu/~dpvc/jsMath/examples/welcome.html). This is done either using fonts from client's computer, either using "image fonts", that is, by constructing the formula from server-stored images for each symbol.

There were similar suggestions (http://community.livejournal.com/suggestions/657683.html in 2006 and http://community.livejournal.com/suggestions/752752.html in 2007), but these were suggesting some server-side code. So, both were criticized mainly for CPU and storage overhead and for the implementation difficulty; so the former suggestion was rejected, and the latter left with no status.

However, jsMath does not execute any server-based code, it does all the processing on the client side with javascript. There server only need to host the script .js files and images for image fonts, which seems to be about 20000 files occupying 7 Mb.

Installation of jsMath is easy, I have myself tested it on my local site. Only two steps are required to get it working:
- download jsMath code and image fonts and extract them from the archive
- insert one script tag into a page template

From my (rather short) experience, jsMath has sometimes problems with choosing proper fonts resulting in strange symbols in formulas, but these problems can be easily overcame even by user (who is viewing the page) himself by using jsMath "control panel".

An ordered list of benefits
  • Allow LJ users to embed math formulas into posts, comments, and even other areas (profile, etc?)
  • Use a widely-known and rather simple TeX syntax
  • Get beautiful TeX-like results
  • Allow such formulas to be easily edited.
An ordered list of problems/issues involved
  • Need to store 20000 files (however, those files are small and occupy only about 7 Mb; moreover, these files never change).
  • Some slowdown of loading each page, as the browsers will load jsMath javascript code (however, jsMath can be set up so that it will not load the main part of itself if the page contains no formulas).
  • A noticeable slowdown of loading pages that contains formulas when using image fonts due to the need to download all the images (however, this is in any case better than current situation).
Tags: markup, § no status
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded