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

Use katex instead of mathjax #3

Open
wants to merge 5 commits into
base: gh-pages
Choose a base branch
from

Conversation

SamLau95
Copy link
Contributor

I managed to get KaTeX to render in Gitbooks: https://github.com/SamLau95/plugin-katex

This fixes the mathjax initialization issue in a non-hacky way (no appending to the DOM, etc):

prob140

However, as the GIF above shows this breaks usages of \mbox. It looks like mbox isn't recommended (https://tex.stackexchange.com/questions/146909/what-does-mbox-do) and when I replace \mbox with \text the math renders just fine:

screenshot 2018-01-14 00 40 49

Another change is that the align* environment needs to be wrapped in $$ and replaced with aligned (this also renders in a notebook correctly). After doing that, math like this renders fine:

screenshot 2018-01-14 00 44 31

One perhaps easier thing to do is to just find and replace across all the notebooks for usage of \mbox and the align* environment during the notebook conversion step. What do you think?

@dibyaghosh
Copy link
Contributor

dibyaghosh commented Jan 14, 2018

Can we fix the wrap-around issues?

image

@SamLau95
Copy link
Contributor Author

Hm. Looks like the wrap-around issues are appearing in the live version of the textbook as well: https://textbook.prob140.org/notebooks-md/1_2_Equally_Likely_Outcomes.html

screenshot 2018-01-14 21 09 46

I don't know of an easy way to fix this since in both cases the math is being rendered differently than normal text in the DOM.

We can, however, attach a horizontal scroll bar when the content overflows so the user can at least view the entire equation instead of it being simply chopped off:

.katex {
  width: 100%;
  overflow-x: scroll;
}

I've pushed this update to the PR.

@dibyaghosh
Copy link
Contributor

MathJax has an option to account for wrap-around (at render-time): this change was part of my most recent push. It looks like this with MathJax
image

Maybe KaTeX has a similar option?

@SamLau95
Copy link
Contributor Author

Looks like KaTeX's doesn't have equation wrapping for block-level equations, unfortunately: KaTeX/KaTeX#327 . I posted a comment requesting for MathJax-style functionality.

I've found a way to add linebreaks to equations by making words wrap. It's not as nice as MathJax's:

screenshot 2018-01-16 14 18 41

What are your thoughts?

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.

2 participants