How do I see LaTeX math on any web page and in email? - MathOverflow most recent 30 from http://mathoverflow.net 2013-05-23T03:49:41Z http://mathoverflow.net/feeds/question/22141 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page-and-in-email How do I see LaTeX math on any web page and in email? VA 2010-04-22T02:19:12Z 2010-11-24T18:27:34Z <p>This is a follow up to <a href="http://mathoverflow.net/questions/19679/seeing-math-when-viewing-abstracts-on-arxiv-org-closed" rel="nofollow">this closed question</a>.</p> <p>I open a random page, such as something on arXiv at 8:05 p.m. EST, and I see all these dollar signs, and I sigh and I wish that I could see nicely formatted math formulas instead, just like on MO. Is it possible? Can one write a Greasemonkey script to apply jsMath after the fact even if the page authors did not think of it? A Mozilla Firefox addon?</p> <p>Please share your solutions. Seeing like this is an active community of people with similar interests, I am sure that hundreds or thousands of mathematicians would benefit from a solution.</p> http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page-and-in-email/22219#22219 Answer by Scott Morrison for How do I see LaTeX math on any web page and in email? Scott Morrison 2010-04-22T16:39:52Z 2010-04-22T17:03:39Z <p>Yes, it is clearly possible to write a GreaseMonkey script that loads the jsMath library, then calls the appropriate code.</p> <p>In fact, you can easily look up the appropriate function call to re-render a page using jsMath, by inspecting the "(Re)process math" element on this page. For your convenience:</p> <pre><code>&lt;a onclick="jsMath.ConvertTeX();jsMath.Process(document);"&gt;(Re)process math&lt;/a&gt; </code></pre> <p>You might also look at this <a href="http://www.yuiblog.com/blog/2007/01/03/yui-greasemonkey/" rel="nofollow">description</a> of building a GreaseMonkey script that loads an external library. It seems sufficiently complicated (waiting to ensure the library has loaded before calling it) that I'm not interested in the details.</p> http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page-and-in-email/22248#22248 Answer by Scott Morrison for How do I see LaTeX math on any web page and in email? Scott Morrison 2010-04-22T20:01:50Z 2010-04-22T20:01:50Z <p>In fact, this question has <a href="http://mathoverflow.net/questions/16/how-do-i-typeset-mathematics-on-mathoverflow-net/110#110" rel="nofollow">previously been answered</a> on MathOverflow. There's a Greasemonkey script <a href="http://www.gold-saucer.org/mathml/greasemonkey/" rel="nofollow">here</a>, which does not in fact use jsMath, but rather produces MathML directly, and leaves it to the browser to render. I haven't tried using it, so I don't know the extent of its LaTeX support.</p> http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page-and-in-email/22378#22378 Answer by VA for How do I see LaTeX math on any web page and in email? VA 2010-04-23T17:53:25Z 2010-05-10T19:24:45Z <p>The <a href="http://www.gold-saucer.org/mathml/greasemonkey/display-latex.user.js" rel="nofollow">Greasemonkey MathML script</a> written by Steve Cheng and linked to in <a href="http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page/22248#22248" rel="nofollow">Scott Morrison's answer</a> worked only partially for me in Firefox on Windows 7: it did not display many \mathbb, \mathcal, and \mathfrak characters because the corresponding Unicode characters were missing in the fonts. Installing additional <a href="https://developer.mozilla.org/en/Mozilla_MathML_Project/Fonts" rel="nofollow">STIX and Asana Math fonts</a> did not help, in fact it made the display looking worse. </p> <p>So I rewrote the script (a long and tedious job finding the correct Unicode codes and putting them in the right places). I also added arxiv.org, front.math.ucdavis.edu, MathSciNet, and mail.google.com to the sites supported by default, and added miscellaneous characters and TeX commands missing in the original script.</p> <p><strong>Yes, it works with gmail (!)</strong> if you switch to the basic HTML view. So now you can read an email from your collaborator and see typeset math right there. Now tell me you haven't always wished and prayed for this? I know I have.</p> <p>Here are the detailed instructions for the method that produces good results using Mozilla Firefox on Windows 7. I haven't tested on other systems, you are welcome to share your experiences in the comments.</p> <ol> <li><p>Click <a href="https://addons.mozilla.org/en-US/firefox/addon/748" rel="nofollow">here</a> to install the Greasemonkey Firefox extension.</p></li> <li><p>Download a modified Greasemonkey script from <a href="http://sites.google.com/site/vaatmo/home" rel="nofollow">here</a> and save it to your Desktop.</p></li> <li><p>From the Firefox menu bar, File > Open File, navigate to the downloaded script and open it. Greasemonkey will offer to install it. Do that.</p></li> </ol> <p>That should be it. Check how it works by looking at some arXiv abstracts such as <a href="http://arxiv.org/abs/1004.2614" rel="nofollow">this</a>, or <a href="http://arxiv.org/abs/1004.4188" rel="nofollow">this</a>.</p> <p>Even when the authors use custom notations, such as \red or \cE, removing the dollar signs, putting math in a different font, and using sub- and superscripts dramatically increases the readability in my experience. </p> <p><strong>Edit:</strong> I also fixed the displayed formulas with double dollars, which the original script did not handle correctly. So now you can also view <a href="http://arxiv.org/abs/0903.1879" rel="nofollow">this</a> and <a href="http://arxiv.org/abs/1004.4623" rel="nofollow">this</a>.</p> <p>So in the end this was more of a community service than a question. Enjoy the results!</p> http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page-and-in-email/24135#24135 Answer by VA for How do I see LaTeX math on any web page and in email? VA 2010-05-10T19:20:51Z 2010-05-15T22:16:56Z <p>By now, I am aware of three ways to accomplish this:</p> <ol> <li><a href="http://www.mathjax.org/" rel="nofollow">MathJax</a>.</li> <li>display-latex2 described in <a href="http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page-and-in-email/22378#22378" rel="nofollow">the other answer</a> (written by Steve Cheng, to which I made some modifications).</li> <li><a href="http://www1.chapman.edu/~jipsen/mathml/asciimath.html" rel="nofollow">ASCIIMathML</a>, written by Peter Jipsen.</li> </ol> <p>I think the best choice by far is to use MathJax, an active project with a very professional development team. It is free, open source, and it is backed by the American Mathematical Society, the American Physical Society, and SIAM, among others. That is the way to go, if you are able to install it on your server.</p> <p>(In the previous version of this answer, I mentioned several problems. They were very promptly resolved by the developers, who are truly impressive, and whom I can not praise enough.)</p> <p>I wrote a <a href="http://sites.google.com/site/vaatmo/home" rel="nofollow">very simple Greasemonkey script</a> which allows you to use your local installation of MathJax on any web page, and in Gmail (in "basic HTML" and "print" views).</p> <p><a href="http://sites.google.com/site/vaatmo/home" rel="nofollow">The same web page</a> also contains a Greasemonkey script allowing you to pick and choose between the three locally installed math engines.</p> <p>In the long run, the best way would be for arXiv, MathSciNet, and Gmail to use MathJax on their servers. I made a <a href="http://groups.google.com/group/gmail-labs-suggest-a-labs-feature/browse_thread/thread/4c3c262ca0459385?pli=1" rel="nofollow">Gmail Lab request for this.</a> If more people support it, maybe they will do it, that would be great. </p> <p><hr> Here are detailed instructions. I am hesitant to bump this question too often. So for minor edits I will update <a href="http://sites.google.com/site/vaatmo/home" rel="nofollow">this web site</a> instead. <br><br></p> <h2> Installation instructions </h2> <p>This solution assumes that you have access to a web server and can install Javascript programs on it. </p> <p>First, download and install MathJax and MathJax web fonts. Install MathJax on your web server. Install the MathJax fonts from the MathJax-webfonts(-beta2)/fonts/HTML-CSS/TeX/otf directory.</p> <p>The customization is done by editing the file MathJax/config/MathJax.js. You need to set</p> <pre><code>webFont: null, </code></pre> <p>so that MathJax uses your locally installed MathJax TeX fonts. Next, download mathjaxthispage.user.js and save it to your Desktop. The script assumes that your MathJax installation resides in <a href="http://localhost/MathJax" rel="nofollow">http://localhost/MathJax</a>. If it is different, edit the script accordingly. From the Firefox menu bar, File > Open File, navigate to the downloaded script and open it. Greasemonkey will offer to install; do that. Start surfing.</p> <h3> Muting the TeX errors (optional) </h3> <p>The following settings make for a more pleasant viewing experience when browsing the pages with non-standard TeX macros, for example arXiv.org.</p> <blockquote> <p>extensions: ["tex2jax.js", "TeX/noErrors.js", "TeX/noUndefined.js"], </p> </blockquote> <p>and inside the TeX block, the following code</p> <blockquote> <p>TeX: { </p> <pre><code> noErrors: { inlineDelimiters: ["",""], multiLine: false, style: { "font-family": "serif", "font-size": "120%", "color": "gray", "border": "" } }, noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "100%" } }, </code></pre> <p>// The rest follows...</p> </blockquote> <p>If you don't have the extensions noErrors.js and noUndefined.js in your MathJax/extensions directory, you can get them from a more recent build available at <a href="https://sourceforge.net/projects/mathjax/develop" rel="nofollow">https://sourceforge.net/projects/mathjax/develop</a></p> <h3> Using the native MathMML output (optional) </h3> <p>With Mozilla Firefox, you have an option of using the native MathMML instead of HTML-CSS output, which is faster. For this, you will need to set the following in MathJax/config/MathJax.js :</p> <blockquote> <p>jax: ["input/TeX","output/NativeMML"],</p> </blockquote> <p>Next, add the following to your userContent.css file (see <a href="http://www.mozilla.org/unix/customizing.html" rel="nofollow">Customizing Mozilla</a>):</p> <blockquote> <p>math { font-size: 112% } [mathvariant="double-struck"] {font-family: MathJax_AMS; } [mathvariant="script"] {font-family: MathJax_Script; } [mathvariant="fraktur"] {font-family: MathJax_Fraktur;} [mathvariant="-tex-caligraphic"] {font-family: MathJax_Caligraphic; } [mathvariant="bold-script"] {font-family: MathJax_Script; font-weight: bold;} [mathvariant="bold-fraktur"] {font-family: MathJax_Fraktur; font-weight: bold;} [mathvariant="monospace"]{font-family: monospace} </p> </blockquote> <p>The first line controls the magnification of math output, and you can change it to your liking. The other lines are needed to fix a bug with Mozilla's display (otherwise, Mozilla does not display MathML correctly).</p> <p>For font consistency, you could also type 'about:config' (without the quotes) in the location bar, and change the variable font.mathfont-family to</p> <blockquote> <p>MathJax_Main, MathJax_Math, MathJax_Size1, MathJax_Size2, MathJax_Size3, MathJax_Typewritter, MathJax_AMS, MathJax_Caligraphic, MathJax_Fraktur, MathJax_SansSerif</p> </blockquote> http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page-and-in-email/24808#24808 Answer by Anton Geraschenko for How do I see LaTeX math on any web page and in email? Anton Geraschenko 2010-05-15T20:05:03Z 2010-05-16T19:06:00Z <p>Here's a solution that is easy and doesn't require you to install Greasemonkey (in particular, you can use it with Chrome), but is quite crufty. Visit a page with math on it (like <a href="http://arxiv.org/abs/1004.2614" rel="nofollow">this arXiv abstract</a>), paste the following into the location bar of your browser and hit enter:</p> <pre><code>javascript:var e=document.createElement("script");e.type="text/javascript";e.src="http://www.mathjax.org/MathJax/MathJax.js";document.getElementsByTagName('head')[0].appendChild(e);setTimeout(function(){MathJax.Hub.Config({config:["MMLorHTML.js"],extensions:["tex2jax.js","TeX/noErrors.js"],tex2jax:{inlineMath:[["$","$"],["\$$","\$$"]]},jax: ["input/TeX"],MMLorHTML:{prefer:"MML"}});MathJax.Extension.tex2jax.PreProcess(document);MathJax.Hub.Process(document);},300);void(0); </code></pre> <p>If that worked, create a new bookmark in your browser with the above line as the "location". When you come to a page where you want to process the math, just click on the bookmark.</p> <p><strong>Edit(VA):</strong> Please consider installing MathJax locally. You don't want to cost the MathJax organization bandwidth. And with a local installation, you are fully in control, and can configure MathJax in a local configuration file. In that case, you can use a shorter bookmarklet (replace 'localhost' by your server): </p> <pre><code> javascript: var e=document.createElement("script"); e.type="text/javascript"; e.src="http://localhost/MathJax/MathJax.js"; document.getElementsByTagName('head')[0].appendChild(e); setTimeout(function(){ MathJax.Extension.tex2jax.PreProcess(document); MathJax.Hub.Process(document); },200); void(0); </code></pre> <hr> <h2>How it works</h2> <p>The basic idea is to load MathJax from <a href="http://mathjax.org" rel="nofollow">mathjax.org</a> like this:</p> <pre><code>var e = document.createElement("script"); e.type = "text/javascript"; e.src = "http://www.mathjax.org/MathJax/MathJax.js"; document.getElementsByTagName("head")[0].appendChild(e); </code></pre> <p>Then you set up MathJax and process the page like this:</p> <pre><code>MathJax.Hub.Config({ config:["MMLorHTML.js"], extensions:["tex2jax.js","TeX/noErrors.js"], tex2jax:{inlineMath:[["$","$"],["\$$","\$$"]]}, jax: ["input/TeX"], MMLorHTML:{prefer:"MML"} }); MathJax.Extension.tex2jax.PreProcess(document); MathJax.Hub.Process(document); </code></pre> <p>This solution simply runs all this together on one line and tells the browser to execute it. MathJax loads asynchronously, so javascript will try to execute the second step before MathJax finishes loading. To avoid this, I've inserted a small (0.1 sec) pause after the first step to give MathJax a chance to load. This works well for me, but you may have to tweak this number ... it's at the very end of the line (in milliseconds).</p> <h2>Issues</h2> <ul> <li>As with VA's solution, this doesn't seem to work with the standard view in Gmail.</li> <li>Mathjax.org may not be happy with people loading the script from them to view random web pages.</li> <li><del>For me, this works in Chrome, but leaves the page in Firefox (javascript must be overwriting the contents of the page). </del> Does anybody know how to fix that? If yes, please edit this answer (it's CW). <strong>Edit (VA):</strong> I increased the timeout to 0.3 sec and added 'void();' at the end. In my tests, it now works in Chrome, Firefox, Internet Explorer, and Opera.</li> </ul> <h2>MathML</h2> <p>If your browser supports MathML, this solution should produce MathML output, but I haven't tested this yet (because it doesn't work in Firefox for me). If you can get MathML output, please leave a comment saying so. If you had to do something special, please edit this answer (it's CW).</p> <p><strong>Edit(VA):</strong> I believe the only browsers supporting MathML now are Firefox and IE with MathPlayer installed. Using the default output (HTML-CSS) should work very well if you have installed MathJax fonts on your machine. Or you can wait until the official STIX fonts come out (it has been 13 years of delays but maybe they are really coming out on May 17?) and install those. </p> <p>Also, noErrors.js and noUndefined.js are not currently part of the standard MathJax distribution. But they can be obtained from the recent builds as explained in the other answer.</p> http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page-and-in-email/25021#25021 Answer by pulse for How do I see LaTeX math on any web page and in email? pulse 2010-05-17T15:27:04Z 2010-05-17T15:27:04Z <p>Does any of the solutions (MathJax, mathml etc.) work on Google Docs? I use it on and off for organizing stuff and it'll greatly help if math displays properly on it.</p> http://mathoverflow.net/questions/22141/how-do-i-see-latex-math-on-any-web-page-and-in-email/27524#27524 Answer by VA for How do I see LaTeX math on any web page and in email? VA 2010-06-08T21:19:54Z 2010-11-24T18:27:34Z <p>I wrote a little program called GmailTeX which adds $\TeX$ capability to Gmail. You can get it <a href="http://alexeev.org/gmailtex.html" rel="nofollow">here</a>. </p> <p><img src="http://alexeev.org/mathoverflow.png" alt="alt text"></p> <p>GmailTeX now includes the "live" fully automatic mode, just like when you type a question / answer on MO. (Actually, faster than the current MO math preview.)</p> <p><strong>Added 9/1/2010:</strong> Thanks to Kristi Tsukida, it is now available as a <a href="http://userscripts.org/scripts/show/84589" rel="nofollow">Firefox greasemonkey script</a> and as a <a href="https://chrome.google.com/extensions/detail/eenhaafocdcfjengcoflbdnoljeaepgb" rel="nofollow">Google Chrome extension</a>, for easy installation.</p> <p><strong>Added 11/24/2010:</strong> Now available as a <a href="https://addons.mozilla.org/en-US/firefox/addon/257869/" rel="nofollow">Firefox add-on</a>.</p>