20
votes

# Tildes should support Latex

Tildes should support Latex using MathJax, or something similar. Having a standard implementation would also act as an easy way to use advanced formatting, while extensions beyond the _{sub} and ^{sup} tags are being made. It would greatly increase the ease of using ~math (actually ~science). Though I could be wrong, it doesn't look like $$\LaTeX$$, $$x^2$$ $\int_{x=0}^p e^{-x^2}dx$ is rendering.

Edit: Katex (not my MathJax recommendation) was a good suggestion, using a partial font download and server side html/css generation.

Edit: Also, to be clear, this is not a must-have-now feature (though that would be nice), but I would like to see support for this in the future, as latex is almost universal in the mathematical sciences.

I have no idea how complicated that might be to implement, but this seems like a highly specialized feature for a general purpose website. Tildes is not a technical message board. Maybe it would be more appropriate to share links to images, some repository or pastebin equivalent that does support mathematical notation.

I imagine that there would be two facets: the first would be string cleaning, which wouldn't be too difficult. The second is the addition of a js script file. It would technically introduce images into tildes, though I think it's worth that cost.

As far as being technical, latex isn't particularly. The mathematical formatting system is fairly standard. Should we implement it now? Maybe not immediately, but I think it would help conversations about math/programming/science as far as clarity.

As far as pastebin, I don't believe that works:

∫px=0e−x2dx symbols are transferred, but to rewrite if properly using the sup markdown, would be fairly difficult: repeated exponent

^{iation}_{a}appears to work, but subscripts are shifted over. So I could write the equation as ∫^{p}_{x=0}e^{−x2}dxbut for anything more complex than that, you start to run into trouble. I image a fair amount of the users here have some familiarity with LaTeX, and I like to think of math as a universal language, so I don't think there would be any negative impact.

Sorry I don’t think I was clear enough: I didn’t mean pastebin itself, but rather a similar service/markup that is suitable for mathematics.

I used this. I believe the idea is the same, but, to my knowledge, Tildes doesn't currently support all the markdowns present in what's being generated.

Who said Tildes was "a general purpose website" though? An idea for groups is that they'll eventually form their own distinct communities, and maybe even have their own functional and programmatic differences, despite being on the same website.

Sure, supporting Latex is "a highly specialized feature", but the big idea for groups is

that they'll eventually become highly specialized, individual communities as Tildes grows.Keeping that in mind, supporting mathematical notation begins to make sense when it actually isn't that complicated to support, or that resources intensive to load. Any groups having anything to do with game development, computer science, mathematics, physics, and all other kinds of subjects, absolutely could benefit from being able to use mathematical notations right here on Tildes, and not have to annoyingly link to other websites like we have to do for images.

Respectfully, I feel like you're looking at this suggestion with too narrow a lens, as if @grungegun was suggesting that Latex support be implemented

right now, and not thinking about the big picture.I fully support this idea too, and there is actually already a Gitlab issue for this suggestion with some discussion about it that took place a while ago too, where @wirelyre even provided some advice for anyone that wants to try to implement it here using KaTeX: https://gitlab.com/tildes/tildes/-/issues/620

From the issue:

That’s goes against Tildes goal of remaining lightweight and mostly accessible without JavaScript.

Hm, Deimos's server side rendering suggestion is interesting.

I think it gives a method for lightweight support. Rather than rendering to an image, as recommended, apply the js in mathtex(katek) directly on the server side, then just send the generated css over. It appears to support this directly. The font problem is serious, but the fonts are hosted separate from each other, so a $150\,kb$ font download impact could be managed by restricting overly specialized symbol use.

Optionally, it could be a toggle, by default off that you enable to determine whether you want to enable the rendering of latex snippets.

Please read the entire issue and don't just cherry pick quotes that support your argument. There are lighter alternatives available that don't even require JavaScript. It's all right there in the issue:

Do correct my mistakes. But please, do not attribute to bad faith what may simply be ignorance.

I didn't see it either. I thought the server-side rendering novel, but it looks like someone's already tested it.

The only thing you had to do was scroll down and keep reading to invalidate the quote you chose to include.

So even if I'm wrong, and you weren't just cherry-picking quotes, I'm still going to ask you to be more studious when it comes to giving feedback to suggestions.

Be nice. Even grungegun (the OP who wants LaTeX support here) admitted they didn't see it either.

Thanks for finding that. I read the katex specs only, and didn't notice that there was more to the discussion. The quote appears to agree with what I found looking through github.

Ping!

KaTeX/MathJax serverside really seems like the best bet.

I was thinking more about this — the notation might have to be a bit nonstandard, since

`\(`

and`\)`

are relatively common in Markdown. Maybe`$( mathematics )$`

inline andIt's also going to be a bit tricky to restrict the inline styles so that they're not directly user-accessible. Otherwise I think you'd have access to element padding which would be an interesting attack vector. Maybe you'd replace all maths with placeholder spans, run Bleach, inject the rendered HTML, and run Bleach

againwith fewer restrictions.For what it's worth, gitlab

~~and github both have~~has LaTeX support inside markdown files.~~Github's implementation.~~[Edit: Github doesn't support LaTeX. Pretty disappointing.]Gitlab's implementation:

I like the idea of treating math as a code subset. My only suggestion would be to do something similar for inline mathematics:

If Tildes was less a general-purpose site, I'd also suggest MathOverflow's "math mode" - any content between

`$`

and`$`

treated as inline mathematics, content between`$$`

and`$$`

treated as "block" mathematics - but it'd probably havea lotof false positives on Tildes.(If anyone's wondering, changing delimiters, at least for KaTeX, is easily done - the configuration file would look something like this:)

Brilliant, that completely sidesteps the problem of inline false positives (

`$( a *b )$ something*`

which would give insane markup) — the TeXification can be an operation on the HTML tree. In fact, if you trust it, you can even inject the finished math without an extra Bleach step.Yeah, since this will likely be a pretty niche use anyways, I think rather than futzing too much with the markdown parser to get it to recognize when someone is trying to use LaTeX-like notation in regular comments, requiring the user to trigger it using the already implemented syntax-highlighting system for codeblocks may be the best way to go about it.

This came up in issue #1 too. Modifying the Markdown parser is frankly pretty fussy (though doable). It's really not well-suited for extensions in forks.

Could you share some examples of existing Tildes comments that use mathematical notation that you think could benefit from this feature?

There's my post asking about norms This is partly a chicken/egg problem. I don't include mathematical notation because it's hard to format. However, it would make my post clearer, for instance, I could give definitions for some of the terms I use, just in case someone isn't familiar with them.

It's mostly a question of whether users should be able to discuss math with each other or is tildes aiming to have 'that's cool' discussions about math posts. Most science discussion forums aren't very scientific in that they can't encourage the experimental method, which is a shame. However, math is unique in that you can do it on the fly, in discussion, anywhere, which means that any discussion involving mathematics could turn into a discovery. I'm in favor of encouraging this, as opposed to a math from the sidelines approach.

Here is a comment I wrote that would have benefitted from LaTeX markup. (HTML and Unicode suffice, but it’s certainly less ideal than LaTeX math mode.) Sure, I also could have typeset this myself and linked to a PDF, but then I have to figure out a hosting solution etc. It would have been more convenient if I could have just put some in-line math mode in my comment. I realize that only a subset of users would take advantage of LaTeX support on Tildes, but it’s a highly overlapping subset with those who make use of code blocks, which is also a niche technical feature that is only part of Markdown because its creator, John Gruber, is a technical guy (I suppose the population of people who create markup languages is self-selecting in that way, but I digress).

Here's the conversation that initially kicked off the discussion and GitLab issue about LaTeX support.

It's worth noting that LaTeX support will also increase the number of conversations about math, just because it's very hard to talk about most anything more complicated than high-school algebra without some sort of mathematical notation support, LaTeX being the gold standard.

Previous discussion on the matter.

Thanks, I didn't notice that particular post at first. It's the fifth result currently in a google search, with mine currently top, so maybe future posters will realize there's a topic sooner than I did.