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

v3, SVG: \smash leads to 0 height #2605

Closed
pkra opened this issue Jan 11, 2021 · 8 comments
Closed

v3, SVG: \smash leads to 0 height #2605

pkra opened this issue Jan 11, 2021 · 8 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3 v3.1
Milestone

Comments

@pkra
Copy link
Contributor

pkra commented Jan 11, 2021

E.g., \smash {\mathbb{R}^2} renders to an SVG with height 0 (and similar viewport).

@dpvc
Copy link
Member

dpvc commented Jan 14, 2021

It looks like 0-height SVGs are not displayed, as you probably noted. We should probably make a small minimum height (and width) to prevent that.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Ready for Development v3 labels Jan 14, 2021
@pkra
Copy link
Contributor Author

pkra commented Jan 15, 2021

It looks like 0-height SVGs are not displayed, as you probably noted. We should probably make a small minimum height (and width) to prevent that.

I don't quite understand. Why would the SVG have height 0? I'd expect the output to appear identical to just \mathbb{R}^2 (as in CHTML).

@dpvc
Copy link
Member

dpvc commented Jan 15, 2021

The height is 0 because you asked for the height to be 0 (that is what \smash does). The output will be just \mathbb{R}^2, but it has no height. That is also the case in CHTML. (At least the <mjx-math> element is height 0. The <mjx-container> ends up with a few pixels of height for reasons that I don't fully understand, but it is at least in part because it is an in-line element, and there is a minimum height for those that has something to do with the line-height and font metrics of the surrounding font.)

The CSS for the <svg> elements produced by MathJax v3 have overflow:visible, so even though the height is 0, it should still display the content (unless you have not included the MathJax CSS in your page). The problem is that a 0-height <svg> seems not to be rendered at all, so it needs a small amount of height for that to happen. That is why I said to use a minimum height.

@pkra
Copy link
Contributor Author

pkra commented Jan 15, 2021

The height is 0 because you asked for the height to be 0 (that is what \smash does).

Right, but I was thinking of this as "internally"

The CSS for the elements produced by MathJax v3 have overflow:visible, so even though the height is 0, it should still display the content (unless you have not included the MathJax CSS in your page).

Ah! I had not thought overflow works this way with SVG, especially not with the viewbox height. Thanks for explaining!

dpvc added a commit to mathjax/MathJax-src that referenced this issue Jan 19, 2021
@dpvc
Copy link
Member

dpvc commented Jan 19, 2021

I have made a PR to correct the problem of having a 0 height.

@dpvc dpvc added this to the 3.1.3 milestone Jan 31, 2021
dpvc added a commit to mathjax/MathJax-src that referenced this issue Feb 9, 2021
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Feb 9, 2021
@pkra
Copy link
Contributor Author

pkra commented Mar 9, 2021

This persists for me (on the amermathsoc branch) on both Blink and WebKit based browsers (Gecko is fine).

Since the height was a very small ex value I tried manually changing it to 1px - this seemed to fix it. So it's possibly a rounding issue.

@pkra
Copy link
Contributor Author

pkra commented Mar 11, 2021

As a temporary workaround: svg {min-height: 1px!important;} seems sufficient.

@dpvc
Copy link
Member

dpvc commented Mar 12, 2021

Thanks for the work-around. I think that may be the easiest way to handle it (using a selector that is specific to the MathJax output).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v3 v3.1
Projects
None yet
Development

No branches or pull requests

2 participants