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

Centered equations become left aligned if displayed through the markdown display hook #11159

Open
henryiii opened this issue May 25, 2018 · 3 comments

Comments

@henryiii
Copy link
Contributor

henryiii commented May 25, 2018

The following markdown works fine in a markdown cell, centering the equation:

The math is centered: $$x$$

But, when placed inside a markdown display method it becomes left aligned (any way you do it, or any number of blank lines, just using this one for brevity):

from IPython import display
display.display_markdown("The math is not centered: $$x$$", raw=True)

It starts out in the center, then leaps over to the left. I think this was a problem that got fixed for markdown cells, but not for the display output.

Edit: This appears in the output style:

div.output_area .MathJax_Display {
text-align: left !important;
}

It is overriding the explicit style in:

<div class="MathJax_Display" style="text-align: center;">...

Related to #7827, but this is in a vanilla Jupyter notebook with IPython.

It seems to be coming from here:

https://github.com/jupyter/notebook/blob/de92a2b34fc50c090c1c02c3b57dbe882cd64d3c/notebook/static/notebook/less/outputarea.less#L52-L55

@takluyver
Copy link
Member

I guess the idea was that an equation by itself (i.e. displayed with the Math class) should be left aligned, like any other output would be. Possibly it doesn't make sense for block equations in markdown. Can you see a way of making the CSS selector more specific so it would differentiate between those cases?

@henryiii
Copy link
Contributor Author

This is markdown instead of latex, so that's one difference that could be used. output_markdown rendered_html is unique to this case, where as just output_latex is on the output of Math (ignoring attributes they both share).

But, really, even for Math, the output does an irritating jump from middle to left of the screen. I think the Math should be inline style ($x$ in markdown) vs. display style ($$x$$) if it is intended to be left aligned as an output, or it should be able to change the the MathJax HTML output <div class="MathJax_Display" style="text-align: center;"> which is causing the jump and forcing the !important rule.

@ddejohn
Copy link

ddejohn commented Mar 14, 2020

I'm experiencing this very issue in 2020. Seems this bug was just ignored?

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

3 participants