marp-team / marp-core

The core of Marp converter
MIT License
766 stars 129 forks source link

Mathjax formulas looking "bold" when exported to pdf on some pdf viewers #287

Closed Prki42 closed 2 years ago

Prki42 commented 2 years ago

Version of Marp Tool

Marp CLI v1.7.0

Operating System

Windows

Environment

How to reproduce

  1. Use mathjax for math formulas
  2. Export pdf using marp cli
  3. Open pdf in web browser (tried in Firefox, Chrome and Microsoft Edge)

Expected behavior

This is how it looks when using html preview firefox_eRrUJKUK0L

Actual behavior

Looks a bit bolder than when using html preview firefox_vyYMJND3ZP

When zoomed out firefox_7D3HSvDeSk

Additional information

This problem is observed to only happen on web browsers' pdf viewers (Firefox, Chrome, Edge). On some standalone pdf viewers problem is not present. Also, if katex is used the problem doesn't persist.

yhatt commented 2 years ago

I think it is bringing from both of line rendering by viewers and thickening by MathJax. (KaTeX is not affected this problem because it will render math typesettings as text with the custom font)

Yes, there is almost no difference between 1 and 3 when the em-size is 1000. The non-zero amount was to make some very thin areas (like in the italic lower-case "o") less likely to disappear, but I would guess 1 would do just as well. The idea was to have at least some stroke-width, and not just fill, since some areas get very thin.

https://github.com/mathjax/MathJax/issues/2618#issuecomment-768543119

You can tweak its style for PDF output by <style> tag.

<style>
@media print {
  mjx-container[jax="SVG"] :is(use[data-c], path[data-c]) {
    stroke-width: 0;
  }
}
</style>

If this tweak was working well, we may consider to add this style into Marp Core as the default style for MathJax.

Prki42 commented 2 years ago

Thanks for your reply! This solved the problem. Also, for this to work the newer version of chromium is needed (initially I tried on 88 and it didn't work but when I updated to 99 it worked).