11 ms·
MathJax: Beautiful and accessible math in all browsers
- peter_d_sherman 3y agoRelated: https://www.mathjax.org/#demo https://www.mathjax.org/#demo https://www.w3.org/Math/ https://www.w3.org/Math/ https://en.wikipedia.org/wiki/MathML https://en.wikipedia.org/wiki/MathML
- err4nt 3y agoIgalia, a 3rd party browser developer who ships code to multiple browser engines, has been working on native MathML support for Chromium and has shipped earlier this year! https://mathml.igalia.com https://mathml.igalia.com
- revskill 3y agoCan i display 2D geometry using MathML ?
- mananaysiempre 3y agoYou can display 2D geometry using SVG, and presumably nothing stops you from using MathML inside that :)
- runarberg 3y agoCorrect, SVG has <foreignObject> for that purpose. I don’t think there is an equivalent MathML element though.
- mindcrime 3y agoThere's no question that MathJax is a great project. But... pretty much all the major browsers have native support for MathML now, so hopefully we can start seeing most (most?) math on the Web in that format. This should bring advantages for folks who rely on additional technology for accessibility purposes, and for search.
- TheChaplain 3y agoFor those as confused as me, Chrome finally supports MathML as of January 2023. (insert starcraft "about time" meme)
- runarberg 3y agoTo be precise, they support MathML Core, which is a subset of MathML 4. Your expressions that you wrote for MathML 3 and worked in Firefox may not (and probably will not) work in Chrome. I actually wrote a library a little while ago which doesn’t work in Chrome because of this. That said, I think MathML Core is an excellent standard, and Chrome made the right choice to support it (or rather to allow Igalia to develop it for them). Going forward I’m certainly going to update my library to target MathML Core only.
- harshreality 3y agoMathML is technically human read/write-able, but not efficiently. Something like Mathjax (which targets mathml) is also necessary, to allow humans to read/write raw math expressions in a simpler format.
- invalidOrTaken 3y agoMathjax can output MathML, actually. It's as easy as linking to tex-mml.js
- mananaysiempre 3y agoA heavy, slow client-side script like MathJax seems like an unpleasant way to target MathML—why not precompile offline from something like AsciiMath?
- tombert 3y agoI haven't done any big investigations on this in quite awhile; how does MathJax compare to something like KaTeX nowadays?
- occamrazor 3y agoKeTeX is faster, but supports a limited subset of LaTeX. MathJax supports essentially everything. For most mathuses in blog posts KaTeX is going to provide a bettter user experience, but if you want to put a math paper on a webpageMathJax is the way to go.
- tombert 3y agoInteresting; does MathJax support the AMS extensions? That was my issue with KaTeX in the past.
- abdullahkhalids 3y agoYes, it does. Supported extensions here [1]. Two more notable ones are mathtools and physics, both of which make writing latex on the web much more pleasant. [1] https://docs.mathjax.org/en/latest/input/tex/extensions/index.html https://docs.mathjax.org/en/latest/input/tex/extensions/inde...
- singhrac 3y agoI think MathJax has really caught up in speed in the past few (5) years with MathJax 3. I would pick MathJax today for compatibility reasons.
- thatxliner 3y agoI haven't used MathJax simply because KaTeX is far easier to use than MathJax.
- romwell 3y agoKaTeX is so plug-and-play for simple LaTeX in web pages that I never bothered thinking about anything else
- Pxtl 3y agoI'm curious - is there any mathjax/mathml/latex/whatever equivalent to Markdown? Because every math extension seems to fail the one great feature of markdown: that when I view Markdown as plain text, it's still really legible and the amount of noise added by the markup is minimal, especially if you use the "underline with hyphens" syntax for headings. Like, every time I see backslashes they're just distracting if I'm trying to read it raw. Like is there any math format where the Quadratic Formula is just -b ± √(b² - 4ac) x = ---------------- 2a Obviously I'd expect something like this to be the output after running the text file through a formatter, just like how in Markdown it's common to reformat things as you go because they're hard to type manually. Like with Markdown Tables. Tables are extremely difficult to type in MD, and should never be done manually, right? Basically, here's how you do tables in markdown: First, you do them the wrong way, half-assed. | Header1 |Header2 |Header3 | |-|-|-| | BodyRow1 Cell1 | Cell2 |Cell3| | BodyRow2 Cell1 | Foo |Bar| which looks like crap, right? then you run them through a formatter and you get | Header1 | Header2 | Header3 | | -------------- | ------- | ------- | | BodyRow1 Cell1 | Cell2 | Cell3 | | BodyRow2 Cell1 | Foo | Bar | which looks nice, right? And then it becomes a real table when you convert your Markdown into Html/Pdf/Docx/whatever. That's what I was wondering if there's anything similar for math. Like, the way I'd type the Quadratic Formula would be x = -b +- sqrt(-b-4ac)) over 2a but when I run it through the code formatter, I'd expect to get cleaned up the same way my table did. -b ± √̅(b² - 4ac) x = ———————————————— 2a
- paulddraper 3y agoKudos for perfectly aligning those hyphens.
- Pxtl 3y agoThe trick is that HN turns into monospace when you indent. So this is not monospaced, but this text that is indented with 4 spaces is monospaced so I can easily align words.
- 3y ago
- dang 3y agoRelated: MathJax v3.2.0 - https://news.ycombinator.com/item?id=28155836 https://news.ycombinator.com/item?id=28155836 - Aug 2021 (1 comment) MathJax - https://news.ycombinator.com/item?id=24741077 https://news.ycombinator.com/item?id=24741077 - Oct 2020 (42 comments) MathJax: Beautiful Math in All Browsers - https://news.ycombinator.com/item?id=23286761 https://news.ycombinator.com/item?id=23286761 - May 2020 (2 comments) MathJax Turns 3.0 - https://news.ycombinator.com/item?id=22582343 https://news.ycombinator.com/item?id=22582343 - March 2020 (34 comments) MathJax CDN shutting down on April 30, 2017 - https://news.ycombinator.com/item?id=14074689 https://news.ycombinator.com/item?id=14074689 - April 2017 (75 comments) MathJax 2.0, probably the nicest way for showing/writing math on the Web - https://news.ycombinator.com/item?id=3720516 https://news.ycombinator.com/item?id=3720516 - March 2012 (4 comments) MathJax: Math just works on the web now - https://news.ycombinator.com/item?id=2455698 https://news.ycombinator.com/item?id=2455698 - April 2011 (4 comments) MathJax, beautiful math in all browsers - https://news.ycombinator.com/item?id=1974646 https://news.ycombinator.com/item?id=1974646 - Dec 2010 (36 comments) MathJax: convert LaTeX to HTML on the client - https://news.ycombinator.com/item?id=1034480 https://news.ycombinator.com/item?id=1034480 - Jan 2010 (3 comments) Mathjax - https://news.ycombinator.com/item?id=997096 https://news.ycombinator.com/item?id=997096 - Dec 2009 (34 comments)
- dllu 3y agoMy blog (eg https://daniel.lawrence.lu/blog/y2021m09d08/ https://daniel.lawrence.lu/blog/y2021m09d08/ ) uses MathJax on the serverside (via mathjax-node-cli) which gets rendered into SVG images. I find that this is nice because it's faster and the page doesn't jump around all the time while the equations are rendering. Equations can be cached. I can add alt text for accessibility. Common mistakes that other people make when using an image-based approach include: * failing to apply the proper sizing and offset for the baseline * using a raster PNG format which is bigger and looks fuzzy
- wolverine876 3y agoHow do you feel about the tradeoff of losing copy-and-paste functionality? I'm not implying it's a bad decision - there are tradeoffs in every option - but I'm wondering what you thought about it.
- dllu 3y agoWith the alt text, copying and pasting actually works as you expect.
- wolverine876 3y agoOhhh I didn't know that. For others trying it: * Right-click > copy copies the image itself * Highlight the image, then Right-click > copy gives you the alt text
- hju22_-3 3y agoHuh, that's surprising. I've never actually checked but always considered that they'd give the same result. Somewhat cumbersome, if one considers how few people know of this functionality though.
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- kzz102 3y agoI am wondering if there's any performance comparison between js based approach like mathjax and katex with the built-in mathml rendering? Given that the the browser needs to parse and render the generated html and css for the js approach, it seems that mathml should be faster. But is it the case for real performance?
- laxd 3y agoI've done math sites with MathML in Firefox and MathJax as fallback for other browsers. The difference is huge. MathML rendering is immediate while MathJax comes limping along after an annoying delay. Even when bundling the MathJax library. Edit: Don't want to send negative vibes toward MathJax. They do great work. Just think it would have been better if google didn't decide "no, the web shall not have native math rendering". Edit2: Didn't know chrome supported MathML now.
- 1propionyl 3y agoFun fact: you can tell ChatGPT to output all math in MathJax syntax and then inject MathJax as a browser script on that domain. It doesn't help with ChatGPT hallucinating and generally being poor about math/stats related queries, but it does make things a good bit more readable!
- amelius 3y agoWhat I want is something like this, but in my code editor, so I can make code look more like the math it is based on.
- protoster 3y agoI've run into it being used in https://webassembly.github.io/spec/core/syntax/instructions.html https://webassembly.github.io/spec/core/syntax/instructions.... It's slow, and you can't highlight the text. This also means that searching on the page is broken, since it can't be highlighted. Not a great experience.
- pclmulqdq 3y agoI looked into MathJax for my blog, and it's pretty slow and renders math as images. KaTeX is hands down a better option, IMO. The math comes in as text, and its UX is essentially the same.
- svat 3y agoThat's odd, MathJax does not render the math as images (unless you configure the output format to be SVG, but even that is not the default). Do you have a memory of (or can retrace) how you ended up with that unusual configuration? (MathJax's output formats, namely HTML+CSS, SVG, MathML — see https://mathjax.github.io/MathJax-demos-web https://mathjax.github.io/MathJax-demos-web or https://docs.mathjax.org/en/latest/output/ https://docs.mathjax.org/en/latest/output/ — are strictly a superset of KaTeX's output formats, namely HTML+CSS and MathML: https://katex.org/docs/options.html https://katex.org/docs/options.html )
- tylerneylon 3y agoWhen I worked at Medium, I pushed to get the team to natively support math markup. That never happened. It kind of killed my initial excitement for the company. Not only on Medium, but on the connected hope of a low-to-zero ad platform for everyone to write on, which is a bigger vision than any one company.
- batterylow 3y agoI was using KaTeX for a while on DataCrayon (e.g. https://datacrayon.com/practical-evolutionary-algorithms/population-initialisation/ https://datacrayon.com/practical-evolutionary-algorithms/pop...), but recently switched to server-side rendering with MathJax. I'm happy with the way it looks. I'd used KaTeX over MathJax previously because I found it rendered pages faster.
- mbid 3y ago> using KaTeX [...] switched to server-side rendering with MathJax I've been meaning to look into KaTex. Could you elaborate on why you switched away from it? KaTeX appears to support server-side rendering already, in the sense that it generates plain HTML.
- atlintots 3y agoMathJax has better MathML support.
- batterylow 3y ago> Could you elaborate on why you switched away from it? I started using KaTeX sometime after 2015 because it promised to be fast (the fastest! [1]). I had to change the representation of a bunch of expressions because KaTeX didn't support some environments, whilst MathJax did. It was a trade-off I was willing to accept at the time. Many years later, I started writing a personal static-site generator. I wanted comparatively lightweight pages, so rendering server-side was an option. I re-evaluated MathJax vs KaTeX again and this time I leaned towards MathJax, as speed was no longer an issue for me. It looks like KaTeX has broader support now [2]. [1] https://katex.org https://katex.org [2] https://katex.org/docs/support_table.html https://katex.org/docs/support_table.html
- singularity2001 3y ago"accessible" ... can't select the sample
- _a_a_a_ 3y agoNeeds JS? Does not seem to work without it. So Eww (emacs browser) won't render it.
- perihelions 3y agoMathstodon ( https://mathstodon.xyz/about https://mathstodon.xyz/about ) integrates this library. It forks/extends Mastodon to support inline LaTeX in Mastodon posts and equations, which get rendered by MathJax on the client side. - "This is important, since several math-based instances exist (such as https://mathstodon.xyz https://mathstodon.xyz ,https://types.pl https://types.pl) and produce math-based posts. However, when these posts federate to other instances they cannot be rendered, since other instances do not have MathJAX installed. Thus, a more portable version based on open standards is necessary." https://github.com/mastodon/mastodon/issues/19806 https://github.com/mastodon/mastodon/issues/19806