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

Mathjax does not load until the page is refreshed #5

Closed
quangounet opened this issue Aug 22, 2017 · 10 comments
Closed

Mathjax does not load until the page is refreshed #5

quangounet opened this issue Aug 22, 2017 · 10 comments
Assignees
Labels

Comments

@quangounet
Copy link
Collaborator

Mathjax formulae are not loaded on the first page visit. One needs to refresh the page for the formulae to load.
One possible way around is to force the formulae to be statically loaded in SVG (set forceSVG to true in book.json), but this stops the compiling process each time there's a LaTeX error -> not convenient.

@fsuarez6
Copy link
Member

I think using the option forceSVG = true is a good approach. In any case, one shouldn't push before building the book locally and therefore the LaTeX error won't go unnotice

@quangounet
Copy link
Collaborator Author

These guys have the same problem GitbookIO/plugin-mathjax#34
When forcing SVG output there are other errors (e.g. "Error: TypeError: speech.processExpression is not a function") that I was not able to debug.

@fsuarez6
Copy link
Member

There is another plugin: https://github.com/GitbookIO/plugin-katex
The problem with katex is that it fails when global commands are defined, see this related issue, which is something we are doing here: math.md

@quangounet, Let's assume that katex doesn't force refreshing the page, are we willing to give-up global commands definitions (e.g. \newcommand{\bfp}{\boldsymbol{p}}) ?

@quangounet
Copy link
Collaborator Author

I've also looked into KaTeX but apparently it is still not as stable and well supported as Mathjax, in addition to the problem you mentioned. Let's give ourselves a few more days to see whether we can work around this issue in Mathjax (unless the switch is super-easy to try out).

@quangounet
Copy link
Collaborator Author

I found a (dirty) workaround: force Mathjax to load by adding the javascript command MathJax.Hub.Queue(["Typeset",MathJax.Hub]), see commit 3ee47e3

@fsuarez6
Copy link
Member

fsuarez6 commented Aug 24, 2017

Does it mean that for every page that has any kind of math ($$) we must include math.md?

@fsuarez6
Copy link
Member

In any case, your workaround fixes this issue.

@quangounet
Copy link
Collaborator Author

Yes, for now we must include math.md. We can try and find a way to do cleaner includes.

@jeffrey-cochran
Copy link

jeffrey-cochran commented Jan 12, 2018

I've been looking around to see if this was cleaned up somewhere. Looks like it's still the case that I have to modify each page? That's rough, but thanks for the solution!

@fsuarez6
Copy link
Member

That's right. The issue is still open: GitbookIO/plugin-mathjax#34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants