Mathematical equation editor in Rails - ruby-on-rails

I'm creating a simple blog using ruby on rails 4. I want to be able to write mathematical equations with it. I'd appreciate if you could help me with any of these questions:
Is there a gem/plugin/etc which I can use to add an editor for mathematical equations to my app? Just like Mathmatical editor in MS word I could use to create an equation and it could give me the MathML code as output?
Let's assume that I have a form where I write the equations in Latex. Is there a gem/plugin/etc (not javascript because it will probably be a huge code and it might cause conflicts and some problems) to convert the equations from Latex/Tex to MathML before saving them to the database?
Thanks.

You can use Equation Editor www.codecogs.com
This is designed to be physically integrated within a websites, allowing your users to create equations without leaving your website. There are two approaches to integrating the editor: either as a popup that can be activated from a button on your site, or as an object embedded directly a page. A range of plugins for popular editors are also available, e.g. CK Editor, Tiny MCE.

Related

LaTeX for Chemistry on my website

I am programming a website on the subject of chemistry and for obvious reasons I also have to include structural and molecular formulas on that site. I want to have as few images as possible on the side and would therefore like to know how I can compile LaTeX code on my website, so I can show everything I could do in LaTeX itself.
Thanks in advance.
As outlined in a previous comment, Chemistry.SE has enabled mhchem in MathJax to allow the rendering of simple formula and reaction equations. The MathJax documention actually gives some directions.
As far as structures of organic molecules are concerned, I'm usually draw them using BkChem and export them as the png images.
If I understand you correctly, you would like to avoid the images themselves and not just the act of drawing. Therefore, the idea to generate the drawings from a linear representation (InChi, SMILES) using openbabel will probably not convince you.
As a matter of fact, it is possible to create structure in LaTeX using chemfig and there have been requests to support this package in MathJax. However, it seems that so far, the strong dependance of chemfig on TikZ has prevented this.

Tradeoff between LaTex, MathML, and XHTMLMathML in an iOS app?

I plan to use Xcode to make an app for the iPhone that displays math equations that high school and college students often use. I do all my math with Mathematica, and it allows me to save such equations in three relevant formats. (1) LaTex (.tex); (2) MathML (.mml); (3) XHTMLMathML.
The Mathemactica documentation says the third format is XHTML with embedded MathML. I found some of the examples at this browser test don't look so good on my iPhone. So I will propbably not rely completly on MathML.
I am a total beginner with Xcode and the three file formats that I mention above, but I have some experience with OOP in C++. Assuming Mathematica can do a good job writing the required LaTeX, MathML, XHHTMLMathML needed for whatever equation, what are the tradeoffs between the three file formats? Can I mix the formats in the same app?
I would suggest to use HTML. The "right" way to include mathematical content is MathML -- which is part of HTML5 (but see below for using TeX).
iOS's UIwebview is webkit based and therefore has the same partial MathML support (though on iOS5 it's significantly worse due to a font bug) so I would also suggest to use MathJax (disclaimer: I'm part of MathJax).
MathJax is an open source javascript library which understands TeX and Asciimath input, converts either one to MathML and renders MathML as HTML-CSS or SVG (in any modern browser).
MathJax has no problem mixing these input formats. Additionally, it has better MathML support than webkit (and you can always configure MathJax to use the native MathML support if you want -- say when you know your content should render fine in webkits native support).
To get you started, you can take a look at this open source app to see how MathJax can be integrated in an iOS app.

How to store math equation/symbol and display them on the web?

I want to build a website where people can create tests with questions and answers . I want people can type in math equation/symbol and equations in a textbox or something like that, and they will be store in database, it'also displayed on the web like image.
My idea is i will store the text user input in latex syntax and store it, then display it using MathJax, i don't know it's possible or will have better way to do this.
And a problem is in user input will have normal text with "math text" (latex), so how can i separate them and only save the latex text? Please give me some idea or suggest the way to solve it, thanks.
p/s: i'm building this site in ruby on rails, i found the gem mathjax-rails but it seem not working.
Consider building off Gollum. It is the backend for the wiki system Github uses and works fairly well with LaTex equations (currently their is a very irritating bug with less/greater than symbols, but is documented and likely will be fixed in the next release). I start using it this summer to take notes in a math classes, an example of a full page of rendered LaTex equations notes is here here.
Note: You must be logged into Github in order for the equation to render.

How to generate a document like this in Latex

http://www.cs.umass.edu/~mccallum/papers/acm-queue-ie.pdf
I want to write a document that has the style like this one.
Like having a light colored background on a page, having a big header (like the EXTRACTION) shown in this link. Do you think it is possible to something like this in Latex?
I am comfortable with doing normal things in latex.
If you download and look at the document properties, it was made with InDesign CS3. Could you do this in LaTeX? Yes. The cover page is... just a cover page. If you use fancyhdr and make a page header, you can increase the header height, then lay the page header in there as an image. Try eso-pic for page backgrounds. But in all honesty, that document is kind of ugly. :D
Your best bet for a document like this is to use a desktop publishing system. A Free/Open Source Software solution would be Scribus Desktop Publishing.
Off the top of my head:
-- check out ConTeXt, strictly speaking an alternative to LaTeX but one designed for something closer to DTP than LaTeX itself;
-- LaTeX has lots of facilities for DTP-like work, a good place to start would be the newsletter on link text
-- investigate packages such as PGF/TKZ, eso-pic, newspaper.
That document smell like made with InDesign or QuarkXPress ... I guess there is a way to do it in latex but will not be straightforward at all ...
Actually it's quite feasible using LaTeX, it's just a pity that the learning curve and the technical involvement are higher than when using DTP tools like Adobe InDesign.
This explains why few people are willing to involve the required amount of time and energy into mastering LaTeX for such kind of projects, and consequently why few introductory material is available on the subject.
One notable exception is the recent workshop given by Dominik Wagenführ at Ubucon 2009 in Göttingen. Its proceedings are freely available a the bottom of the page, as well as the related source code. It's all in German but fairly easy to understand and very educational, so I'd recommand you to study it.

What's a solid, full-featured open rich text representation usable on the Web?

I'm looking for an internal representation format for text, which would support basic formatting (font face, size, weight, indentation, basic tables, also supporting the following features:
Bidirectional input (Hebrew, Arabic, etc.)
Multi-language input (i.e. UTF-8) in same text field
Anchored footnotes (i.e. a superscript number that's a link to that numbered footnote)
I guess TEI or DocBook are rich enough, but here's the snag -- I want these text buffers to be Web-editable, so I need either an edit control that eats TEI or DocBook, or reliable and two-way conversion between one of them and whatever the edit control can eat.
UPDATE: The edit control I'm thinking of is something like TinyMCE, but AFAICT, TinyMCE lacks footnotes, and I'm not sure about its scalability (how about editing 1 or 2 megabytes of text?)
Any pointers much appreciated!
FCKeditor has a great API, supports several programming languages (considering it is javascript this isn't hard to achieve), can be loaded through HTML or instantiated in code; but most of all, allows easy access to the underlying form field, so having a jQuery or prototype ajax buffer shouldn't be terribly difficult to achieve.
The load time is very quick compared to previous versions. I'd give it a whirl.
In my experience a two-way conversion between HTML and XML formats like TEI or DocBook is very hard to make 100% reliable.
You could use Xopus (demo) to have your users directly edit TEI or DocBook XML. Xopus is a commercial browser based XML editor designed specifically for non-technical users. It supports bidi and UTF-8. The WYSIWYG view is rendered using XSLT, so that gives you sufficient control to render footnotes the way you describe.
As TEI and DocBook don't have means to store styling information, those formats will not allow your users to change font face, size and weight. But I think that is a good thing: users should insert headers and emphasis, designers should pick font face and size.
Xopus has a powerful table editor and indentation is handled by nesting sections or lists and XSLT reacting to that.
Unfortunately Xopus 3 will only scale to about 200KB of XML, but we're working on that.
I can't really decide on one of them. IMHO they are all not very good and complete. They all have their advantages and clear disadvantages. If TinyMCE is your favorite then afaik, it also does tables.
This list will probably come in handy: WysiwygEditorComparision.
I've also used FCKEditor and it performed well and was easy to integrate into my project. It's worth checking out.
Small correction to laurens' answer above: As of now (May 2012), Xopus supports UTF8, but not BiDi editing. Right-to-left text is displayed fine if it came from another source, cannot be edited correctly.
Source: I was recently asked to evaluate this, so have been testing it.

Resources