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: printing fails with version 2.1, works fine with 2.0.3 #386

Closed
q4 opened this issue Feb 5, 2013 · 14 comments

Comments

Projects
None yet
3 participants
@q4
Copy link

commented Feb 5, 2013

Concrete example:
http://www.inference.phy.cam.ac.uk/tcs27/talks/ceq.html#dir

Viewing this page in the browser (Chrome, Firefox, Safari) works fine, but when printing, the spacing and scaling of all MathJax elements is messed up and incorrect.

Interesting fact:
When opening the same webpage with MathJax 2.0.3 loaded (rather than MathJax 2.1), the problem does not occur.

What changed between 2.0.3 and 2.1 which could have this side effect?

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 5, 2013

I don't have any theories at the moment. Can you provide a second copy that uses 2.0 so I can compare them?

@q4

This comment has been minimized.

Copy link
Author

commented Feb 5, 2013

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 5, 2013

Thanks. I can confirm the difference in Safari (haven't tried anything else). I'll look into it.

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 7, 2013

It looks like the change that is affecting you is the following: in v2.0, the space reserved for the math is given in em's and in v2.0 it is in pixels. This was done to avoid some problems with the spacing on screen, but it seems to have adversely affected your printing. Your pages are pretty complex, and I haven't tried to track down exactly why the spacing is so big for pixels in your output, but perhaps you have some ideas. I suspect there is something in the CSS that is behind it, as printing seems to work fine for other test pages.

I will look into it further when I have time, but I was hoping you might know of something in your CSS that might affect the pixel size?

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 7, 2013

OK, it looks like it is the following lines in your CSS file:

@media screen and (min-width: 50em) { body { font-size: 200%; } }
@media screen and (max-width: 50em) { body { font-size: 180%; } }
@media screen and (max-width: 45em) { body { font-size: 160%; } }
@media screen and (max-width: 40em) { body { font-size: 140%; } }
@media screen and (max-width: 35em) { body { font-size: 120%; } }
@media screen and (max-width: 32em) { body { font-size: 110%; } }
@media screen and (max-width: 30em) { body { font-size: 100%; } }
@media screen and (max-width: 24em) { body { font-size: 95%; } }

which scales the screen version differently from the print version. Apparently, the pixel size is scaled for the screen size when it is printed, and that is throwing off the spacing.

I've done some testing, and it appears that if the screen and print media have the font-size set differently for the body, then you get this issue. If you use @media all above, it works fine in Safari and Firefox, but not Chrome (though the printed slides are larger than you would want).

I will have to look into is some more.

@q4

This comment has been minimized.

Copy link
Author

commented Feb 7, 2013

Yes, it's correct that the print version has a different font-size from the screen version, and that the font-size is scaled dynamically as the max-width of the page changes relative to the current font size. [In fact I just realised that the spacing bug also affects the screen rendering, when the window is resized so that it triggers one of the dynamic CSS rules.]

An easy first question: could one make "em" vs "px" a config option of MathJax? :)

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 11, 2013

An easy first question: could one make "em" vs "px" a config option of MathJax?

I have a slightly different solution in mind, but need to try it out. It will end up using em's again, but may be able to avoid the placement issues anyway.

@q4

This comment has been minimized.

Copy link
Author

commented Feb 11, 2013

That sounds great.
Let me know if I can help in some way.

@ghost ghost assigned dpvc Feb 11, 2013

@fred-wang

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2013

I set this "Do not write Automated Test". I think there are already some tests to verify the spacing issues anyway.

dpvc pushed a commit to dpvc/MathJax that referenced this issue Apr 17, 2013

Davide P. Cervone
Make final math size be in relative units so that it prints even if p…
…rint media has a different font size. Resolves issue mathjax#386.
@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 17, 2013

The issue386 branch of my fork of MathJax includes a fix for this. It was a bit tricky to get it to work even when there is a minimum font size in effect (which was why it had been switched to pixels from em's originally).

I still need to check it with IE, but it looks good in Firefox, Safari, and Opera.

I also want to change Chrome back from using pixels to using em's again (I think I know how to get around the placement issues), since that also causes bad printing in this case.

@fred-wang

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2013

I also want to change Chrome back from using pixels to using em's again (I think I know how to get around the placement issues), since that also causes bad printing in this case.

So should we merge the branch now and see if that makes some tests fail? Or should we wait the changes to Chrome?

@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 19, 2013

So should we merge the branch now and see if that makes some tests fail? Or should we wait the changes to Chrome?

The Chrome pixel changes should probably be a separate issue. I'd go ahead and merge this, as it is not really related directly to the Chrome changes I'm talking about. (I changed Chrome to using size and position values in pixels to avoid some placement problems in Chrome staring with around Chrome 20, but it turns out that the pixel size causes problems in other situations, like when MathJax appears in an animation that enlarges the size, or when printing a page like the one above that different font sizes for screen and print media. So I'd like to change it back to em's, and I think I can improve the spacing in a different way.)

@fred-wang

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2013

OK, I've set it "Ready for release"

dpvc pushed a commit to dpvc/MathJax that referenced this issue Apr 19, 2013

@dpvc

This comment has been minimized.

Copy link
Member

commented Apr 19, 2013

=> Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.