LaTeX equivalent to Google Chart API - math

I'm currently looking at different solutions getting 2 dimensional mathematical formulas into webpages. I think that the wikipedia solution (generating png images from LaTeX sourcecode) is good enough until we get support for MathML in webbrowsers.
I suddenly realized that it might be possible to create a Google Charts API equivalent for mathformulas. Has this already been done? Is it even possible due to the strange characters involved in LaTeX-code?
I would like to hit an url like latex2png.org/api/?eq="E = mc^2" and get the following response:
edit:
Thanks for the answers sofar. However, I am already aware of several tools to generate png images from latex source code (both online and from my commandline), but what I was looking for was a simple way to get the image via an Http GET request. Perhaps such a service does not exist.

Update
As #hughes (and others) pointed out, the previous Google Chart API has been deprecated.
The example I wrote still works as of Sept 2015, but a new one shall be used now (documentation):
Old answer
Google Chart can do it (Documentation):
http://chart.apis.google.com/chart?cht=tx&chl=%5CLaTeX
I'm using this with Google Docs, because it doesn't support math yet.

chart.apis.google with background color changed
https://chart.apis.google.com/chart?cht=tx&chf=bg,s,FFFF00&chl=%0D%0A4x_0%5CDelta%28x%29%2B3%5CDelta%28x%29%2B2%5CDelta%28x%5E2%29%3E0%0D%0A
or chart.apis.google with background color transparent and resized
For better readability URL needs to be decoded.
https://chart.apis.google.com/chart?cht=tx&chs=428x35&chf=bg,s,FFFFFF00&chl=
4x_0\Delta(x)+3\Delta(x)+2\Delta(x^2)>0
Data structure looks like this
{
"cht":"tx",
"chs":"428x35",
"chf":"bg,s,FFFFFF00",
"chl":"n4x_0\Delta(x) 3\Delta(x) 2\Delta(x^2)>0"
}
https://chart.apis.google.com/chart?cht=tx&chs=428x35&chf=bg,s,FFFFFF00&chl=%0D%0A4x_0%5CDelta%28x%29%2B3%5CDelta%28x%29%2B2%5CDelta%28x%5E2%29%3E0%0D%0A

You could try the Online image generator for mathematical formulas for a start.
mathurl is a mathematical version of TinyURL.com. It allows you to reference LaTeXed mathematical expressions using a short url. For example, http://mathurl.com/?5v4pjw will show [LaTeX output Image] which you can then edit. More details on mathurl’s help page

I just ran across MathJax on Ajaxian [via Wayback Machine]:
MathJax seems to have a chance at being a practical solution that offers a high quality display of LaTeX and MathML math notation in HTML pages.
The output is remarkably beautiful, and it's all pure HTML and CSS, which makes it scalable and selectable. Performance is currently a bit sluggish, but this is recognized.

As everyone has said, there are many services that do this already. Here is another easy one that I've used a number of times (and you can install it locally on your server if necessary):
http://www.codecogs.com/components/equationeditor/equationeditor.php

I'd take a good look at how the MediaWiki LaTeX support does it and borrow from there.

Please check out this site for a way to create TeX documents without any software installed. You can then snippet the result image with any screen capture method and embed the resulting image into a any website.
Go to http://sharelatex.com
The software is free to use, but you need to register to create documents.

Related

How to embed maths in MediaWiki

I'm trying to transfer some maths content from and old wiki to my new MediaWiki.
The old page uses MathJax, and looks like this:
Here is the k-degree Taylor series for [[$ f(x) $]]
expanding around [[$ x=0 $]]
[[$ T_k(x) = f(0) + x\cdot f'(0) + \frac{x^2}{2!} f''(0) + \dots
+ \frac{x^k}{k!} f^k(0) $]]
This is what I've found so far:
http://www.mediawiki.org/wiki/Extension:MathJax -- appears to be discontinued.
http://www.mediawiki.org/wiki/Extension:SimpleMathJax -- I tried this and it works on OSX Chrome but gives rendering errors on OSX FireFox (https://github.com/jmnote/SimpleMathJax/issues/1)
http://www.mediawiki.org/wiki/Extension:Math -- this appears to be where the active development is occurring, but I haven't managed to get it working. Also it is a huge headache.
Have I missed anything?
What's the right way to enable maths content in a MediaWiki?
From what I can see, it is looking like: "render on server and provide PNG is faster, render on client using MathJax is simpler/cleaner"
SimpleMathJax is an absolutely minimal install. If only it worked on Firefox!
Math extension is looking like hard work, it looks like overkill -- it seems to support at least 4 different techniques for rendering.
A year after, the situation is getting even more confusing about how MediaWiki sites could process maths. If we all agree that texvc and maths formula displayed in png images are ugly and obsolete, it seems that Mathoid, according to https://www.mediawiki.org/wiki/Extension:Math, "is the most recommended option; Mathoid is the rendering mode that will be used on Wikipedia in the future.” .
But Mathoid requires an external server like Parsoid and they both (Mathoid and Parsoid) are in an heavy development. Therefore I looked for an other solution and found and tested successfully 'SimpleMathJax' (https://www.mediawiki.org/wiki/Extension:SimpleMathJax). It can be set like below
wfLoadExtension( 'SimpleMathJax' );
// MediaWiki 1.24 or earlier
// require_once "$IP/extensions/SimpleMathJax/SimpleMathJax.php";
works on any recent version of MediaWiki (latest version tested is mw1.28 of late December 2016).
However the code of the extension itself is not distributed with the numerous MediaWiki extensions from the WikiMedia fundation (which supports mathoid) but you can get it on github at https://github.com/jmnote/SimpleMathJax/archive/master.zip and expand it into your extension subdirectory with other extensions.
The math rendering is beautiful because it uses MathJax and MathJax (.org) is "an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers."
Most of the standard AMS LaTeX code seems to work fine (align etc).
It is called "simple" MathJax probably because it doesn't have the ambition of the MW MathJax extension to process all LaTeX and TeX facilities like numbering equations and process TeX macros, but it uses the original javascript CDN of mathjax.org and therefore is very simple to install and to use for short mathematical texts.
- If you want to process longer and even huge mathematical texts, you can try 'pandoc' which will transform your full LaTeX document into mediawiki source with the following command line:
$ pandoc -o foo.wiki -f latex -t mediawiki foo.tex
You do really want https://www.mediawiki.org/wiki/Extension:Math it is the standard way of doing things.
Maths rendering has been a problem on wikipedia for a long time now. The original system uses PNG images dates back to about 2005. It was the best that was available then, but it is really ugly, the font sizes don't match, the base line are all wrong and there is no anti-aliasing. The advantage is that its stable and works for all browsers.
Ever since then there has been attempts to improve the maths rendering. The first attempt was Blahtex which produced MathML but never got traction with the developers.
Then MathJax came along. The first implementation was as a user script
https://en.wikipedia.org/wiki/User:Nageh/mathJax this worked pretty well but needed the user to manually add it to their javascript skin files.
A couple of years ago MathJax got rolled into the main Math extension, with a user preference (off by default).
MathJax is the nicest current rendering but there are two major problems, browser support, it has to work on all possible browsers including the more limited ones on phones and ancient systems. The other is speed, as it is rendered by javascript it takes time to format the equations, this can be up to a minute for the more complex formula rich pages.
MathML is another possible option, however Firefox is the only browser with halfway decent support.
This has led to a problem with making a universal system. The current development is a system which allows client side MathJax/MathML rendering for those who want the best rendering, the old PNG rendering as a fallback and a new system which uses MathJax to render SVG on the server side.
As to what to actually do. I think the simplest is to ignore extensions completely and just use MathJax on the global javascript files. See https://en.wikipedia.org/wiki/Wikipedia:Common.js_and_common.css. This would be a pretty standard MathJax configuration.
Lets look at how the User:Nageh/mathJax script works, and adapt this for your setting. What he did is install a copy of mathjax on the webserver server, in his case it was all installed in his user space
https://en.wikipedia.org/w/index.php?title=Special%3APrefixIndex&prefix=Nageh%2FmathJax&namespace=2
If you have access to the server you could install the code in a more sensible place. Say for sake of argument MediaWiki/includes/MathJax. Then in common.js just have a line
importScript("/MediaWiki/includes/MathJax/MathJax.js");
or possible better
mw.loader.load("/MediaWiki/includes/MathJax/MathJax.js");
or even better
mw.loader.using("/MediaWiki/includes/MathJax/MathJax.js").done( function() {
MathJax.Hub.Config( ... );
} );
after than just have the MathJax hub setup you need. See https://www.mediawiki.org/wiki/ResourceLoader for details.

Markdown formula display in GitHub

When I write an R markdown file in RStudio and Knit HTML, my formulas (inline using $..$ or display using $$..$$) can be displayed properly. However, when I push my .md file to GitHub, these formulas cannot be displayed. They only show $..$ and $$..$$. Is there a way to let GitHub know how to parse latex formulas? Thanks!
Is there a way to let GitHub know how to parse latex formulas?
Some sites provide users with a service that would fit your need without any javascript involved: on-the-fly generation of images from url encoded latex formulas.
codecogs.com
iTex2Img.
given the following markdown syntax
![equation](https://latex.codecogs.com/gif.latex?1%2Bsin%28mc%5E2%29%0D%0A)
it will display the following image
Note: In order for the image to be properly displayed, you'll have to ensure the querystring part of the url is percent encoded. You can easily find online tools to help you with that task, such as www.url-encode-decode.com
I also looked for how to render math on GitHub pages, and after a long time of research I found a nice solution.
I used KateX to render formulas server side: it is really faster than MathJaX.
Please note that same solution could be arranged to work also client side, but, I prefer server side rendering, cause
you know your server environment, but you don't know the client environment of your visitors
it is also faster client side, if the formulas are rendered on the server, only once.
I wrote an article showing the steps, I hope it can help math divulgation: see Math on GitHub Pages.

PDF to HTML or similar

I'm building an application to view pdf's through a browser without the need of a plugin on mobile devices. I tried ImageMagick and ghostscript to covert the pages to images but they are far too large and text becomes unclear. I see website offering a service of converting pdf's into html and do a descent job but I can't find an example of how this is accomplished. Any help is much appreciated. Thanks!
EDIT: I seem to have read the question backwards. In this case it might be best to parse through the PDF and then format some HTML based on what you find. I believe the javapdf option is capable of this, but I haven't used any of these so I am not sure. If worse comes to worst and you can't find software to disassemble a PDF, you might be able to write your own disassembler in Java or PHP by reading the PDF specification. Best of luck!
http://www.adobe.com/devnet/pdf/pdf_reference.html - PDF Specification (Adobe Modified Version, because they are most popular you may want to support their extensions)
-- OLD -- These websites probably write their own proprietary software to do the trick. If you are truly interested in this undertaking, I would suggest parsing the HTML to get the data and style information and using it to format some sort of PDF writer APIs. A quick Google search yields the following: -- END OLD --
http://www.cutepdf.com/Solutions/
http://ruby-pdf.rubyforge.org/pdf-writer/doc/index.html
http://asprise.com/product/javapdf/
If you are looking at converting PDF to HTML and planning to run the conversion on a server, then you can try pdf2html. It is a program packaged as part of poppler-utils. I do not know how the program accomplishes it.
I was googling and came across the below link explaining how scridb.com implements conversion.
http://coding.scribd.com/2010/06/01/the-perils-of-stacking/

Javadoc with Equations?

I'm only familiar with the no-frills javadoc generator, however I'd like to include some mathematical equations in my javadoc (rather than constantly referencing another document).
Is there a convenient option to do something like include/properly render LaTeX (most preferred - then I could just cut-n-paste) or MathML tags?
Check out Doxygen.
It's blazing fast, free, and supports embedded LaTeX.
Maybe something like MathJax or jsMath could be your solution. They're both JavaScript libraries, so you'll have to find a way to add them into your javadocs pages.
While I haven't done it personally, there are ways to create your own using the Doclet or Taglet API to create your own Doclet or Taglet. Several of these have already been done according to a quick search providing one such example http://www.ohloh.net/p/latextaglet
If you're feeling daring enough the latextaglet project is open source, so you might be able to further adapt it to your needs.

Where can one post nicely formatted code combined with LaTeX for mathematical expressions?

Admittedly not a programming question, but I don't really know where else to ask this...
I'm planning to start a blog to post the stuff I'm working on, which is mostly about Expression Trees & Mathematics. Hopefully this will help me focus on the problem at hand instead of going off every possible tangent that comes up.
I wonder if someone out there knows a good place to host a blog with the two following requirements:
(1) Nice support for code listings (as seen here, for example).
(2) Support for complex mathematical expressions, ideally in LaTeX (as seen here, for example).
For a while now I've been looking around for posts/articles combining both nicely formatted code and mathematical expressions, but I haven't found anything.
Thanks a lot!
PS - If there's another Q&A forum where this question would fit better, then please let me know and I'll move it there.
EDIT(1): While carrying out some additional research, I found this related SO question (see also resources therein), which then took me to here. Leaving the question open for now though in case someone wants to suggest alternatives.
Read here:
http://sixthform.info/steve/wordpress/?cat=2
http://fugato.net/2007/01/20/latex-in-wordpress/
about LaTeX on Wordpress, syntax higlighting is easy (hint: google for "syntax highlighting") and you can go on any host with WP.
Good luck.
Edit: Okay, about that latex - it seems you need to have administrator rights, so any hosting with friendly administrator or virtual server or server hosting/housing :)
Edit: As for syntax highlighting:
PHP SH: http://xtractpro.com/articles/CSharp-Syntax-Highlighter.aspx
JS SH: http://wordpress.org/extend/plugins/google-syntax-highlighter/
For math expressions in LaTeX syntax checkout MathJax. It can probably be used with most blog hosting services. You just need to be able to add javascript to the page.

Resources