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/KaTeX rendering issue for PDF exports only #393

Closed
lettersforword365 opened this issue Dec 24, 2022 · 3 comments · Fixed by #397
Closed

LaTeX/KaTeX rendering issue for PDF exports only #393

lettersforword365 opened this issue Dec 24, 2022 · 3 comments · Fixed by #397
Labels
bug Something isn't working

Comments

@lettersforword365
Copy link

I was testing out Marp and tried some LaTeX code for mathematical formulae.

I found that sigma notation does not seem to render correctly in PDF exports:

PDF Export:
image

HTML/PPTX Export:
image

I am running Marp for VS Code v1.5.2 on VS Code 1.70.1; device is on Windows 11 22H2.
The code for the formula I am using is:

# Some $\LaTeX$ Code

<br>

$$
\sum_{k=1}^{n}k^2 = \frac{n(n+1)(2n+1)}{6}
$$

This appears to be the case when I have not declared the math typesetting, or if it is declared as katex.

This is not the case when math typesetting is declared as mathjax, which is odd, as this says mathjax is used in rendering if there is no declaration (there is also a stylistic difference in rendering; no declaration appears to be using katex.)

PDF using MathJax:
image

I prefer usage of katex. Is there any "quick fix" for this, or a way in which different rendering engines could be used for different parts of the same equation?

@yhatt
Copy link
Member

yhatt commented Dec 25, 2022

It seems to reproduce only in Chrome if exported to HTML. Firefox and Safari does not reproduce. (Marp's PDF export is depending on Chrome)

Marp has applied auto-shrink the size to KaTeX block, and it may be a one of incompatible parts with the auto scaling feature, as same as marp-team/marp-core#159 and marp-team/marp-core#236.

Workaround

Add following global style in Markdown.

<style>
  .katex .delimcenter,
  .katex .op-symbol {
    display: inline-block;
  }
</style>

If this workaround is working well, going to consider to add into KaTeX default style by Marp Core.

@yhatt yhatt added the bug Something isn't working label Dec 25, 2022
@yhatt
Copy link
Member

yhatt commented Dec 25, 2022

This appears to be the case when I have not declared the math typesetting, or if it is declared as katex.

This is not the case when math typesetting is declared as mathjax, which is odd, as this says mathjax is used in rendering if there is no declaration (there is also a stylistic difference in rendering; no declaration appears to be using katex.)

In Marp for VS Code, use the library preferred in the extension settings if not defined math directive. You says "I prefer usage of katex" so you may be setting markdown.marp.mathTypesetting as katex. In this case, it's expected behavior that uses KaTeX when there is not set math directive.

@lettersforword365
Copy link
Author

you may be setting markdown.marp.mathTypesetting as katex

just had a look at extension settings; looks like that is the default.

the workaround seems to work well for me as well; thanks for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants