Skip to content

Support R KaTeX package as a new math-method - #2304

Merged
cderv merged 10 commits into
mainfrom
math-katex-r
Feb 14, 2022
Merged

cderv merged 10 commits into
mainfrom
math-katex-r

Conversation

@cderv

@cderv cderv commented Feb 7, 2022

Copy link
Copy Markdown
Collaborator

This is based of #2215 and replaces it. It is based on new math support in rmarkdown to offer support for R package katex (https://docs.ropensci.org/katex/)

output:
  html_document:
    math_method: r-katex

If R package is not available, then it fallbacks to use math_method: katex.

Regarding the implementation, Pandoc requires us to set some math method otherwise some warnings will be thrown ([WARNING] Could not convert TeX math ) by Pandoc. And katex R packages only handles the syntax resulting by --mathjax flag for Pandoc (and not --katex).

This leads to a limitation: On a template where $math$ variable is included into Pandoc's template, the Mathjax JS library will be inserted in <head>. For our default template, we don't have it, but it could happen with non default template (template arg in html_document_base().

@cderv

cderv commented Feb 9, 2022

Copy link
Copy Markdown
Collaborator Author

@jeroen here is how I would integrate katex to be used with rmarkdown document.

Does it looks good to you ?

Thanks for the katex update BTW. It is cleaner to use --katex. Only drawback still existing is that when used with non default template, Pandoc will still insert some JS and CSS for katex. But our templates does not have that so we're good.

@jeroen

jeroen commented Feb 9, 2022

Copy link
Copy Markdown
Contributor

I think so. I would personally prefer to error instead of warn if the user sets r-katex but the katex package is not installed. If the document gets rendered in CI, people may miss the warning and end up with something that they did not expect.

@cderv

cderv commented Feb 9, 2022

Copy link
Copy Markdown
Collaborator Author

Good thinking. I'll change to an error.

@yihui yihui left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@cderv cderv changed the title Support R KaTeX package Support R KaTeX package as a new math-method Feb 14, 2022
@cderv
cderv merged commit fc8e1d7 into main Feb 14, 2022
@cderv
cderv deleted the math-katex-r branch February 14, 2022 15:17
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants