4 ms·
It would be best to do this somewhere that supports MathJax (http://www.mathjax.org/ http://www.mathjax.org/). HN does not, which could make it awkward to discu
by tzs 15y ago
It would be best to do this somewhere that supports MathJax (http://www.mathjax.org/ http://www.mathjax.org/). HN does not, which could make it awkward to discuss math in an HN thread.
There are three reasonable ways to add MathJax support to a site.
1. Get the site owner to do it. The site owner simply has to toss in a script tag that loads MathJax from the MathJax CDN and sets some configuration options. Someone would need to convince PG that this is worthwhile. (I've done some timing tests, and MathJax doesn't seen to cause any noticeable performance problems when used on pages that contain no math. Any decent browser caches the script so load time of the script is not a problem).
2. The user can use a Greasemonkey script to load it, for browses that support Greasemonkey scripts. Here's an example that loads MathJax on Reddit: http://userscripts.org/scripts/review/108770 http://userscripts.org/scripts/review/108770. This could trivially be modified to work on HN instead of Reddit.
3. Safari doesn't support Greasemonkey scripts. There is a Safari plugin to add that functionality, but it does not work very well. I wrote a Safari extension to load MathJax (or Tex The World, discussed below) on Reddit: https://github.com/tzs/Reddit-Math-Display-for-Safari https://github.com/tzs/Reddit-Math-Display-for-Safari. This could easily be modified to work on HN instead of Reddit.
On Reddit, in /r/math, the convention is to use LaTeX delimited by [; and ;] to mark math, and to use a script called Tex The World to render it (http://thewe.net/tex/ http://thewe.net/tex/). That script finds the math, and sends it off to CodeCogs.com where it is rendered and an image is returned for display. This occasionally causes problems due to the load on CodeCogs.
To work around this, someone has a hacked version of the that script (link available in the sidebar on /r/math) that uses the Google Chart API to render small equations and does some kind of caching.
I'd recommend NOT using either of these. The author of TeX The World stopped work on it quite a while ago. There's no licensing information on the site so it is not clear if anyone else can take it over, and by using an external service to render the math it is fragile.
MathJax seems to be the best approach. That's what they are using at mathoverlow and math.stackexchange.com. Note that if MathJax is loaded by the page itself, rather than by an extension, then it works great on iOS and most other major mobile web devices, in addition to pretty much all major desktop browsers, without the need for the end user to do anything special.
- mkl 15y agoTesting new HN version of script: [;A\boldsymbol{x}=\lambda\boldsymbol{x};] Seems to be working, in Chrome at least. Can some other people try it out? http://userscripts.org/scripts/show/112966 http://userscripts.org/scripts/show/112966 Put latex code inside square bracket semicolon pairs: [;...code...;]
- deleted 15y ago[deleted]
- nhamann 15y agoWorks for me on Chrome 14. Testing: [;\frac{du}{dt};] [;\left[ \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right];]
- mkl 15y agoNow changed to use the MathJax default delimeters, as tzs explains.
- tzs 15y agoNote that /r/math on Reddit is using those delimiters because that's what Tex The World uses. I don't see any particular reason to use those over just sticking with the MathJax defaults, which are backslash-brackets and dollar dollar for display math, and backslash-parens for inline math. For your script, this can be achieved simply by deleting the line in the configuration that sets the inline math delimiters. I've tested, and the default delimiters seem to work fine on HN.
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]
- 15y ago