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.

23 comments

  1. [4]
    mrbig
    (edited )
    Link
    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...

    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.

    19 votes
    1. [3]
      grungegun
      (edited )
      Link Parent
      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...

      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 exponentiationa appears to work, but subscripts are shifted over. So I could write the equation as ∫px=0e−x2dx
      but 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.

      8 votes
      1. [2]
        mrbig
        (edited )
        Link Parent
        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.

        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.

        2 votes
        1. grungegun
          Link Parent
          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.

          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.

          6 votes
  2. [14]
    cfabbro
    (edited )
    Link
    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...

    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

    10 votes
    1. [6]
      mrbig
      Link Parent
      From the issue: That’s goes against Tildes goal of remaining lightweight and mostly accessible without JavaScript.

      From the issue:

      It's still not lightweight though - from a quick look, KaTeX seems to require a 255kb minified JS file, 22kb minified CSS, and 2MB of fonts.

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

      6 votes
      1. grungegun
        Link Parent
        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)...

        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.

        4 votes
      2. [5]
        Comment deleted by author
        Link Parent
        1. [3]
          mrbig
          Link Parent
          Do correct my mistakes. But please, do not attribute to bad faith what may simply be ignorance.

          Please read the entire issue and don't just cherry pick quotes that support your argument.

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

          9 votes
          1. grungegun
            Link Parent
            I didn't see it either. I thought the server-side rendering novel, but it looks like someone's already tested it.

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

            2 votes
          2. [2]
            Comment deleted by author
            Link Parent
            1. cfabbro
              Link Parent
              Be nice. Even grungegun (the OP who wants LaTeX support here) admitted they didn't see it either.

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

              9 votes
        2. grungegun
          Link Parent
          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.

          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.

          2 votes
    2. [7]
      wirelyre
      Link Parent
      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....

      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 and

      ```mathematics
      block-level
      ```
      

      It'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 again with fewer restrictions.

      3 votes
      1. psi
        (edited )
        Link Parent
        For what it's worth, gitlab has LaTeX support inside markdown files. [Edit: Github doesn't support LaTeX. Pretty disappointing.] Gitlab's implementation: Einstein's pretty smart for realizing $`E...

        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:

        Einstein's pretty smart for realizing $`E = mc^2`$. 
        
        But he still doesn't beat Euler!
        
        ```math
        1 + e^{i \pi) = 0
        ```
        
        6 votes
      2. [3]
        petrichor
        Link Parent
        I like the idea of treating math as a code subset. My only suggestion would be to do something similar for inline mathematics: `math e^{i\pi} + 1 = 0` ```math e^{i\pi} + 1 = 0 ``` If Tildes was...

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

        `math e^{i\pi} + 1 = 0`
        
        ```math
        e^{i\pi} + 1 = 0
        ```
        

        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 have a lot of false positives on Tildes.

        5 votes
        1. petrichor
          Link Parent
          (If anyone's wondering, changing delimiters, at least for KaTeX, is easily done - the configuration file would look something like this:) delimiters: [ // order is important {left: "```math",...

          (If anyone's wondering, changing delimiters, at least for KaTeX, is easily done - the configuration file would look something like this:)

          delimiters: [ // order is important
              {left: "```math", right: "```", display: true},
              {left: "`math", right: "`", display: false}
          ]
          
          4 votes
        2. wirelyre
          (edited )
          Link Parent
          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,...

          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.

          3 votes
      3. [2]
        cfabbro
        (edited )
        Link Parent
        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...

        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.

        2 votes
        1. wirelyre
          Link Parent
          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.

          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.

          3 votes
  3. [4]
    Comment deleted by author
    Link
    1. grungegun
      Link Parent
      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...

      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.

      11 votes
    2. onyxleopard
      Link Parent
      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...

      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).

      7 votes
    3. petrichor
      Link Parent
      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...

      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.

      4 votes
  4. [2]
    Moonchild
    Link
    Previous discussion on the matter.
    3 votes
    1. grungegun
      (edited )
      Link Parent
      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...

      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.

      1 vote
  5. Comment removed by site admin
    Link