Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config option to change MathJax renderer #1472

Merged
merged 5 commits into from
Jul 24, 2024
Merged

Add config option to change MathJax renderer #1472

merged 5 commits into from
Jul 24, 2024

Conversation

bwu62
Copy link
Contributor

@bwu62 bwu62 commented Jul 23, 2024

Not 100% sure, but based on a small amount of testing, I think this may render more neatly without sacrificing on portability or speed.

I noticed this when typesetting the formula for the sample standard deviation

$$s=\sqrt{\frac1{n-1}\sum_{i=1}^n(x_i-\bar{x})^2}$$

The default MathJax renderer of "Common HTML" "fakes" the square root top bar by using a border, which causes annoying misalignment with the radical symbol beside it. It also overall looks a bit more raggedy and not as pretty.

This small config change switches the default renderer to HTML+CSS (thanks @dennissxz for the tip).

Seems to be a marginal improvement.

Not 100% sure, but based on a small amount of testing, I think this may render more neatly without sacrificing on portability or speed.

I noticed this when typesetting the formula for the sample standard deviation

`$$s=\sqrt{\frac1{n-1}\sum_{i=1}^n(x_i-\bar{x})^2}$$`

The default MathJax renderer of "Common HTML" "fakes" the square root top bar by using a border, which causes annoying misalignment with the radical symbol beside it. It also overall looks a bit more raggedy and not as pretty.

This small config change switches the default renderer to HTML+CSS (thanks @dennissxz for [the tip](jupyter-book/jupyter-book#1174 (comment))).

Seems to be a marginal improvement.
@CLAassistant
Copy link

CLAassistant commented Jul 23, 2024

CLA assistant check
All committers have signed the CLA.

@cderv
Copy link
Collaborator

cderv commented Jul 23, 2024

Thanks for suggesting this change;

Changing default is always tricky, because it never comes without impact. It "fixes" the square root syntax you see, but does it break something else maybe ? Hard to test all possibly outcome.

I don't know why exactly but we use config=TeX-MML-AM_CHTML in every other places we have (by doing on quick github search).

So we should either make this easily customisable maybe, rather than changing default for everyone, which will change the equation looks for all bookdown book building out there.

@yihui what do you think ?

@bwu62
Copy link
Contributor Author

bwu62 commented Jul 23, 2024

@cderv Thanks for the reply. I think that makes sense, having this as a nondefault option in the YAML is probably a better idea. Maybe we can also add an option for using SVG as the renderer? I'll work on this a bit later and propose another change if nobody beats me to it.

Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

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

I have no idea about the consequences of changing the default config here, so I don't have an opinion. I'm okay with either this PR or a new PR that makes it possible to customize the config or the whole mathjax URL. Thanks!

@bwu62 bwu62 marked this pull request as draft July 23, 2024 15:16
@bwu62 bwu62 changed the title Change MathJax renderer to default to HTML+CSS Add config option to change MathJax renderer Jul 23, 2024
@bwu62
Copy link
Contributor Author

bwu62 commented Jul 23, 2024

Added new mathjax-config config option to bs4_book and gitbook templates to control MathJax config string. I did some preliminary tests and the following usages should be supported:

  • If left empty, defaults to original TeX-MML-AM_CHTML which renders in common HTML
  • If set to TeX-AMS-MML_HTMLorMML renders in HTML + CSS
  • If set to TeX-MML-AM_SVG renders in SVG

I'm sure other config options are possible but these are just the ones I've uncovered.

Let me know if these look good to you guys or feel free to suggest further changes :)

@bwu62 bwu62 marked this pull request as ready for review July 23, 2024 15:57
bwu62 added a commit to bwu62/stat240-revamp that referenced this pull request Jul 24, 2024
Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

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

Sounds good to me. Could you add a news item to NEWS.md? Then we'll merge this PR. Thanks!

Added new math-jax config option to NEWS.md
@bwu62
Copy link
Contributor Author

bwu62 commented Jul 24, 2024

Thanks @yihui for the approval. I've updated the NEWS.md. Let me know if there's anything else you need :)

Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

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

Thanks!

NEWS.md Outdated Show resolved Hide resolved
@yihui yihui merged commit 5dcce03 into rstudio:main Jul 24, 2024
1 check passed
@bwu62 bwu62 deleted the patch-1 branch July 24, 2024 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants