# Should chat have TeX support?

OK, so chat is now available... but; it has been suggested that for Mathematics we should have TeX support.

The current TeX processing has some non-trivial client impact. Before I even attempt trying to hack this in, is this something that the community would want / use?

(this would only apply to maths rooms, and would presumably only apply to posts written with what is, for other sites, the fixed-font indent - i.e 4 spaces)

• Well first of all, there currently aren't that many users of that chat room. Unless more people show up to use it, $\TeX$-ing it up may well end up to be a waste of your time. – J. M. isn't a mathematician Nov 6 '10 at 12:11
• We were just now lamenting the lack of TeX support in chat. Would it be possible to reconsider this? – Glen Wheeler May 11 '11 at 19:26
• Half a year has passed after the comment by @Glen. If there are any news? Chat still seem to have a lack of TeX support. – Ilya Dec 2 '11 at 9:36
• My old comment is now irremediably false, as there's now a bunch of us discussing math and a bunch of other stuff animatedly on chat... – J. M. isn't a mathematician Dec 6 '11 at 15:12
• Is there anyone who is enough of a coding wizard that can put things together into a working Greasemonkey script that continually re-TeXs the page? Having to click a bookmark is crazy when things like this script exist and don't require clicking anywhere for it to work. – kahen Oct 22 '12 at 0:51
• Corresp. feature request: Why is there no support for MathJax in chat? – Grigory M Jul 16 '14 at 13:30
• There is a user script now; see here. (I tried to post this as an answer, but it was auto-converted. Huh.) – Raphael Sep 19 '15 at 16:41
• Is or how is mathjax available for mobiles? – draks ... Apr 11 '17 at 17:04

## 5 Answers

There are four bookmarks which are located on this installation page:

1. start ChatJax installs MathJax and starts a loop that renders $\LaTeX$ as needed. This is intended for use in chat, where the contents of the page are not static. Reloading the page will stop the loop, so the bookmark needs to be run again.

2. render MathJax installs MathJax and renders $\LaTeX$ once per execution. This is intended for use on web pages where the contents of the page are static.

3. rendering off disables MathJax while editing. This is useful when rendering is slow while editing questions and answers.

4. rendering on enables MathJax after being disabled by rendering off.

To get the bookmarks mentioned above, go to this installation page.

There is a section at the bottom of the installation page to install ChatJax on a browser that cannot add bookmarks using drag-and-drop or a contextual menu. This is how I installed ChatJax on my iPhone.

If you are still having trouble installing on an iOS device, see this answer on Ask Different.

On April 30, 2017, the MathJax CDN will be shutting down.

The bookmarks listed above will need to be reinstalled. I have updated the bookmarks to use the CDN at cdnjs.cloudflare.com. Make sure you reload this installation page so that the new bookmarks are not hidden behind a stale cache.

• I would nominate you to a Hacker badge if I could. – Asaf Karagila Dec 6 '11 at 8:58
• @Asaf: It's okay, I got a Necromancer badge for this answer. :-) – robjohn Dec 6 '11 at 10:30
• To get automatic processing, register the code above as a callback to the global AJAX complete event: $('html').ajaxComplete(function() { ... }); Warning: this is just a hack and will cause MathJax to be reloaded on each use. – Zhen Lin Dec 6 '11 at 11:39 • @ZhenLin: Thanks! I have added your automatic processing addition. – robjohn Dec 6 '11 at 13:06 • Here is how to handle the bookmark bar in Chrome. Create an empty bookmark, copy all of the text above starting with "javascript:(function(){if(window.MathJax'" into the destination for a bookmark in the bar. – robjohn Jan 4 '12 at 13:53 • How persistent is the (Cloudfront) site hosting MathJax.js? – Willie Wong Jan 5 '12 at 10:20 • @Willie: if you are asking about "d3eoax9i5htok0", this explains the weird domain name. – robjohn Jan 5 '12 at 22:15 • @robjohn: thanks. That's precisely what I was wondering about. BTW: thanks for the bookmark! – Willie Wong Jan 6 '12 at 9:04 • Alert! Linux and Windows versions have different bookmarking with Google Chrome but the combo SHIFT+CTRL+B should show you the bookmark -bar. – hhh Mar 20 '12 at 7:54 • @Willie: the cloudfront.net url seems to be down, so I am switching to the mathjax.org url since that is what the main site uses. – robjohn Jun 6 '12 at 17:09 • For some odd reason, single $...$ -thing does not work in Twitter but the double $$...$$ -thing works, odd, investigating... – hhh Sep 2 '12 at 1:28 • note to myself: click on Firefox bookmark whenever I enter math chat – Theta33 Mar 2 '13 at 19:58 • @Theta30 I bet some greasemonkeying could save you that click – Tobias Kienzler Mar 21 '13 at 14:34 • Does this only work for SE or any website? – Meow Apr 6 '13 at 21:40 • The render MathJax and start ChatJax bookmarks will work on any website. The rendering off and rendering on bookmarks only work on websites that use MathJax. – robjohn Apr 7 '13 at 3:31 Revision 3. This one actually has a working loop, and uses jQuery instead of directly injecting a script element. Unfortunately, it seems that new chat messages no longer trigger the ajaxComplete event, so my hack has to be replaced with a different one. This one runs MathJax on a 1-second cycle. Bookmarklet: javascript:(function()%7Bif(window.MathJax===undefined)%7BjQuery.getScript(%22http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML%22,function()%7BMathJax.Hub.Config(%7B%22HTML-CSS%22:%7BpreferredFont:%22TeX%22,availableFonts:%5B%22STIX%22,%22TeX%22%5D,linebreaks:%7Bautomatic:true%7D,EqnChunk:MathJax.Hub.Browser.isMobile?10:50%7D,tex2jax:%7BinlineMath:%5B%5B%22$%22,%22$%22%5D,%5B%22%5C%5C%5C%5C(%22,%22%5C%5C%5C%5C)%22%5D%5D,displayMath:%5B%5B%22$$%22,%22$$%22%5D,%5B%22%5C%5C%5B%22,%22%5C%5C%5D%22%5D%5D,processEscapes:true,ignoreClass:%22tex2jax_ignore%7Cdno%22%7D,TeX:%7BnoUndefined:%7Battributes:%7Bmathcolor:%22red%22,mathbackground:%22#FFEEEE%22,mathsize:%2290%25%22%7D%7D%7D,messageStyle:%22none%22%7D);MathJax.Hub.Startup.onload();theLoop=function()%7BMathJax.Hub.Queue(%5B%22Typeset%22,MathJax.Hub%5D);window.setTimeout(theLoop,1e3)%7D;theLoop()%7D)%7Delse%7BMathJax.Hub.Queue(%5B%22Typeset%22,MathJax.Hub%5D)%7D%7D)() Source code: (function () { if (window.MathJax === undefined) { jQuery.getScript('http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML', function () { MathJax.Hub.Config({ "HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX", "TeX"], linebreaks: { automatic: true }, EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50) }, tex2jax: { inlineMath: [ ["$", "\$"],
["\\$", "\$/extract_itex]"] ], displayMath: [ ["", ""], ["\\[", "\$"]
],
processEscapes: true,
ignoreClass: "tex2jax_ignore|dno"
},
TeX: {
noUndefined: {
attributes: {
mathcolor: "red",
mathbackground: "#FFEEEE",
mathsize: "90%"
}
}
},
messageStyle: "none"
});

MathJax.Hub.Startup.onload();

theLoop = function () {
MathJax.Hub.Queue(['Typeset', MathJax.Hub]);
window.setTimeout(theLoop, 1000);
};
theLoop();
});
} else {
MathJax.Hub.Queue(['Typeset', MathJax.Hub]);
}

})();


There is ChatJax++ now, a user script that enables MathJax in SE chat in a smart way, i.e. it requires no user interaction and renders new messages automatically.

For those of us who struggle to get ChatJax running on an iPad, you need to fake it into a bookmarklet that you can copy and paste into the Safari URL line, then save as a bookmark. Make an .html file on your desktop that you will save, put in Dropbox, and open with Safari on your iPad.

That .html file should have a textbox in it that you can copy here (go into edit mode):

ChatJax Bookmarklet
COPY AND PASTE ROBJOHN'S SCRIPT HERE

• We can no longer edit your answer to get the textbox because community Wiki answers cannot be edited. – user400188 May 19 at 7:36

With MathJax 2.x the way to load it dynamically has changed and the documentation says that one should use a new method.

It seems to me that it ought to be possible to turn this into a Greasemonkey script that runs automatically when receiving new input.