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 Rendering Issues #12

Closed
dcroce opened this issue Jul 24, 2018 · 18 comments
Closed

MathJax Rendering Issues #12

dcroce opened this issue Jul 24, 2018 · 18 comments

Comments

@dcroce
Copy link

dcroce commented Jul 24, 2018

I have about 8~10 issues with MathJax reading certain parts of a notebook incorrectly. Does this require a case by case fix? They are showing up as intended in the ipython notebooks.

Examples: 14.1 see technical note, 14.4 midway down the page.
See original notebooks here

Is there a basic methodology for trouble shooting? I'm not well rehearsed in MathJax syntax.

@dcroce
Copy link
Author

dcroce commented Jul 24, 2018

Is it possible that MathJax needs updating? If so where can I do that?

@choldgraf
Copy link
Collaborator

I agree that MathJax is still a little bit buggy. Ideally I'd like to just replicate whatever MathJax logic is used in the Notebook / JupyterLab interfaces.

Perhaps @minrk or @ian-r-rose or @Carreau knows something about MathJax in the notebook?
I'm configuring and loading my MathJax here:

https://github.com/choldgraf/textbooks-with-jupyter/blob/master/_includes/mathjax.html

but it still only works sometimes (e.g., on the notebooks demo page)

@ian-r-rose
Copy link

I'm not sure what could be causing the rendering issues here.
This is where MathJax is configured in JupyterLab.

@Carreau
Copy link
Collaborator

Carreau commented Jul 31, 2018

The last equation at the end is because the ... |s| .... It interprets the full paragraph as a table, and end up being the follwing html:


$</td>
--
  | <td>s</td>
  | <td>\le 1$ so that it converges.</td>

Thus mathjax does not find the math correctly. Try to deactivate the Markdown table extension ?

@Carreau
Copy link
Collaborator

Carreau commented Jul 31, 2018

Same for 14.4, it thinks |...| is a table which screw up the HTML and thus mathjax.

@choldgraf
Copy link
Collaborator

hmmmm....so I guess the question is: is it better to support more complete mathjax equations but mess up markdown tables, or vice versa...

@Carreau
Copy link
Collaborator

Carreau commented Jul 31, 2018

Well notebook does not support markdown table. So if you are doing table they won't render in notebook. You can still make raw html table...

So deactivating the table extension will still allow you to do table (but in raw html), and not screw up math.

The only drawback will be no table export in PDF.

Is markdown table even used in this book ?

@choldgraf
Copy link
Collaborator

not in this book, but the point is be a generic "create any textbook with your jupyter notebooks" repository, so I don't want to preclude people from this functionality if I don't have to.

However, I think a solution is to disable markdown tables only for the pages that were converted from notebooks, that way the behavior is the same on both platforms.

@choldgraf
Copy link
Collaborator

actually, I'm not sure if it's possible to disable table auto-generation in jekyll? seems like this is something built-in to kramdown...

@Carreau
Copy link
Collaborator

Carreau commented Aug 1, 2018

You may be able to tell Jekyll to use redcarpet instead of Kramdown.

@choldgraf
Copy link
Collaborator

do you have any opinions on using one vs. the other? I'm a bit hesitant since I don't know what kinds of downstream effects that would have...

@Carreau
Copy link
Collaborator

Carreau commented Aug 1, 2018

do you have any opinions on using one vs. the other? I'm a bit hesitant since I don't know what kinds of downstream effects that would have...

I don't remember which is which. I had issue with both.

@choldgraf
Copy link
Collaborator

haha yep that sounds like markdown to me ;-)

@choldgraf
Copy link
Collaborator

@dcroce it looks like all of the issues you describe are because of markdown auto-formatting of in-line equations. Could you try:

  1. Make sure every block equation has $$ around it.
  2. Make sure every inline equation has | characters escaped with \. So $P(|\bar{X}_n - \mu| \ge \epsilon) becomes $P(\|\bar{X}_n - \mu\| \ge \epsilon)?

@dcroce
Copy link
Author

dcroce commented Aug 7, 2018

Alright I will see if that makes the difference.

@dcroce
Copy link
Author

dcroce commented Aug 16, 2018

In addition to |, _ and * also needs to be escaped. That was able to fix all the errors I had, although it makes the textbook look different from the ipynbs. Thanks for the help!

@dcroce dcroce closed this as completed Aug 16, 2018
@choldgraf
Copy link
Collaborator

@dcroce could you go into more detail on what you mean by "different from the ipynbs"? :-)

@dcroce
Copy link
Author

dcroce commented Aug 16, 2018

When opening the ipython notebook, the math shows up slightly different. For example the \ to escape the * will show up in the ipython notebook but on the textbook turns out as desired. There are other minor differences too. See 9.3 of the textbook and compare to the notebook for a specific example (New url is http://prob140.org/textbook/chapters/README)

choldgraf added a commit to choldgraf/jupyter-book that referenced this issue Apr 28, 2020
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

No branches or pull requests

4 participants