You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Reacted by Johan Larsson, David Beauchemin, Tim Hosgood, dgiannelli and Alessandro Luongo
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.
@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.
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
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!
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.
Activity
yihui commentedon May 31, 2017
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
equationenvironment.py9mrg commentedon Feb 25, 2020
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:
Being able to add the bottom
math: katexoption, to abookdowndocument or evenhtml_notebookwould 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
themeandhighlightlines, to revert back to the standard html output.cderv commentedon Oct 29, 2020
Just some news about this: Support has been added in August (KaTeX/KaTeX#2369) but doc has not been updated in WIKI
py9mrg commentedon Oct 29, 2020
Great - all the more reason to do it, then!
atusy commentedon Oct 31, 2020
I opened PR rstudio/rmarkdown#1940 to solve this.
prdm0 commentedon Nov 16, 2020
Is it already possible to use katex? Is it possible to pass
math: katexto the YAML preamble?atusy commentedon Nov 16, 2020
No, not yet. When it becomes possible rstudio/rmarkdown#1940 becomes merged and this issue becomes closed.
atusy commentedon Nov 16, 2020
@prdm0 At least you can try with
remotes::install_github("rstudio/rmarkdown#1940")prdm0 commentedon Nov 17, 2020
@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.
thosgood commentedon Jan 2, 2021
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
.jsscript that parses all the maths as KaTeX manually, but settingmathjax: nullresults in inline maths being rendered as unicode, without the LaTeX input being preserved in the tag dataEdit. 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
where
KaTeX.htmlloads thekatex.jsand then (using jQuery) renders alleqtags using KaTeX (as either display or inline, depending on theenvattribute of theeqtag).Just leaving this comment here in case other people find themselves in the same situation as me!
cderv commentedon Jul 7, 2021
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.
cderv commentedon Feb 3, 2022
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 whentemplate = "default"in rmarkdown, which is not compatible with how this is set up ingitbookwhich 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.
fecet commentedon Dec 12, 2022
Can we use katex in bookdown somehow? I found re-rendering math in live preview is very time-consuming and annoying.