Skip to content

support katex #401

Open
Open

Description

@laoshaw

This is really a feature request, please adding Katex support as it is replacing all other math rendering these days, it's also very fast and easy to use.

Activity

  1. yihui commented on May 31, 2017

    @yihui
    Collaborator

    Thanks! I'll consider it in the future. KaTeX is indeed very fast, but it only covers a subset of MathJax's LaTeX commands and environments: https://github.com/Khan/KaTeX/wiki/Function-Support-in-KaTeX For example, there is no equation environment.

  2. py9mrg commented on Feb 25, 2020

    @py9mrg

    I'd love this feature, too.

    While I accept that KaTeX has some limitations, an option to switch between MathJax and KaTeX, similar to what is done by the prettydoc package would be great:

    title: Nineteen Years Later
    author: Harry Potter
    date: July 31, 2016
    output:
      prettydoc::html_pretty:
        theme: cayman
        highlight: github
        math: katex
    

    Being able to add the bottom math: katex option, to a bookdown document or even html_notebook would be fantastic.

    If you're wondering why I don't just use that package - it's because I'd prefer to be able to switch to KaTeX using arbitrary themes, but I don't seem to be able to - easily - get that package working in anything but the themes they've provided. Maybe I'm being dumb, but it's not as easy as deleting the theme and highlight lines, to revert back to the standard html output.

  3. cderv commented on Oct 29, 2020

    @cderv
    Collaborator

    For example, there is no equation environment.

    Just some news about this: Support has been added in August (KaTeX/KaTeX#2369) but doc has not been updated in WIKI

  4. py9mrg commented on Oct 29, 2020

    @py9mrg

    Great - all the more reason to do it, then!

  5. atusy commented on Oct 31, 2020

    @atusy
    Collaborator

    I opened PR rstudio/rmarkdown#1940 to solve this.

  6. prdm0 commented on Nov 16, 2020

    @prdm0
    Contributor

    Is it already possible to use katex? Is it possible to pass math: katex to the YAML preamble?

  7. atusy commented on Nov 16, 2020

    @atusy
    Collaborator

    No, not yet. When it becomes possible rstudio/rmarkdown#1940 becomes merged and this issue becomes closed.

  8. atusy commented on Nov 16, 2020

    @atusy
    Collaborator

    @prdm0 At least you can try with remotes::install_github("rstudio/rmarkdown#1940")

  9. prdm0 commented on Nov 17, 2020

    @prdm0
    Contributor

    @atusy, thanks for the info. I will try it because I am writing material in bookdown that has many mathematical formulas and rendering with MathJax is a bit boring.

  10. thosgood commented on Jan 2, 2021

    @thosgood

    so is there currently a way to get Bookdown to build a Gitbook output with KaTeX instead of MathJax? I would even be happy with a way to entirely exclude MathJax so that I could just include a .js script that parses all the maths as KaTeX manually, but setting mathjax: null results in inline maths being rendered as unicode, without the LaTeX input being preserved in the tag data


    Edit. For anybody looking to use KaTeX with the Gitbook output of Bookdown, the easiest way that I've found of doing so is to have

    output:
      bookdown::gitbook:
        mathjax: null
        pandoc_args: ["--gladtex"]
        css: "katex.css"
        includes:
            after_body: "KaTeX.html"
    

    where KaTeX.html loads the katex.js and then (using jQuery) renders all eq tags using KaTeX (as either display or inline, depending on the env attribute of the eq tag).
    Just leaving this comment here in case other people find themselves in the same situation as me!

  11. added
    feature
    and removed on Mar 15, 2021
  12. cderv commented on Jul 7, 2021

    @cderv
    Collaborator

    Sharing here that a new package by rOpenSci in on CRAN now : https://docs.ropensci.org/katex/reference/katex.html.

    It enables server-side math-to-html rendering in R, such that no javascript library is needed in the html document.

  13. cderv commented on Feb 3, 2022

    @cderv
    Collaborator

    rmarkdown now support KaTeX and other math method (rstudio/rmarkdown#1940)

    For gitbook() to support it, we just need to change the way it is triggered. Currently it applies only when template = "default" in rmarkdown, which is not compatible with how this is set up in gitbook which uses a default template.

    I think we need to change the way it is working or trick rmarkdown from bookdown so that it is activated.

  14. added
    next
    on Feb 3, 2022
  15. fecet commented on Dec 12, 2022

    @fecet

    Can we use katex in bookdown somehow? I found re-rendering math in live preview is very time-consuming and annoying.

  16. moved this from Backlog to Next in R Markdown Team Projectson Dec 12, 2022
  17. moved this from Next to Backlog in R Markdown Team Projectson Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurenext

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions