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

Latex spacing bug in HTML output #392

Open
kennysong opened this issue Sep 4, 2015 · 3 comments
Open

Latex spacing bug in HTML output #392

kennysong opened this issue Sep 4, 2015 · 3 comments
Milestone

Comments

@kennysong
Copy link

In the HTML output of a notebook, there is no spacing between a Latex equation and the line above.

In notebook (correct):
screen shot 2015-09-04 at 12 43 10 pm

In HTML output (incorrect):
screen shot 2015-09-04 at 12 43 01 pm

A quick look at the source shows that this is because the MathJax span and div are not wrapped in a <p> in the generated HTML, as in the actual notebook.

@minrk
Copy link
Member

minrk commented Sep 10, 2015

This is presumably a difference between mistune and marked's markdown rendering. We may be able to deal with it, though, in our custom handling of math in mistune.

This is definitely an nbconvert issue, though, and not a notebook one.

@Carreau Carreau added this to the wishlist milestone Sep 14, 2015
@mherrmann3
Copy link

mherrmann3 commented Oct 18, 2016

Had the same issue today. Solved it conveniently by modifying the MathJax template file mathjax.tpl (should be located in python3.5/site-packages/nbconvert/templates/html/. Just look for the following snippet:

displayAlign: 'center',
        "HTML-CSS": {
            styles: {'.MathJax_Display': {"margin": 0}},
            linebreaks: { automatic: true }
        }

and change {"margin": 0} to {"margin-top": "10px", "margin-bottom": "10px"}.
(FYI: {"margin": "10px"} would also increase the margin at the sides (left and right) which can bring you a horizontal scrolling bar in the HTML if your equations are too wide.

I really wonder why 0 is the default here... It looks really ugly and un-LaTeX-ish...

@ketch
Copy link

ketch commented Mar 8, 2018

This is a problem for me, too. It's easy to add a space above an equation in the notebook by inserting a blank line, but when converting to latex this becomes a paragraph break, which is often undesired.

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

No branches or pull requests

5 participants