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

Multiline equation with alignment not rendered correctly in pdf export #1765

Open
cpraveen opened this issue Jan 11, 2025 · 4 comments
Open
Labels
bug Something isn't working

Comments

@cpraveen
Copy link

Multiline equations like this

$$
a &= b \\
  &= c \\
  &= d
$$

renders correctly in html. I think they are wrapped in align.

But when I export to pdf, the alignments are ignored, and the equation is shown on single line.

$ myst -v
v1.3.20
@cpraveen cpraveen added the bug Something isn't working label Jan 11, 2025
@cpraveen
Copy link
Author

cpraveen commented Jan 11, 2025

E.g., see eq. (9) here https://cpraveen.github.io/numa/intro

and the same in exported pdf is attached in pic below

Image

@rowanc1
Copy link
Member

rowanc1 commented Jan 14, 2025

Are you using typst or latex for the export to PDF? Can you provide the output in either language and what you would expect?

You can wrap in a \begin{align*} I believe, does that fix things?

@cpraveen
Copy link
Author

What I expect is to look as in the html output I have linked.

I am using latex. Using align will work, but I have too many equations using $$, and since it works in html, I hope it can be fixed in pdf output.

This is output from building pdf with latex, see messages related to intro.md file which is what I am showing in the html link above.

$ myst build intro.md --pdf    
📬 Performing exports:
   intro.md -> _build/exports/intro.pdf
⚠️  intro.md:90 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 5: u_0 &̲= 0 \\
- \frac{…
📖 Built intro.md in 599 ms.
📖 Built front.md in 597 ms.
📖 Built hiformula.md in 589 ms.
⛔️ potential.md container of kind undefined contains no valid content besides caption, legend
   Valid content types include image, referenced notebook cell, table, code, iframe, subfigure
⛔️ potential.md container of kind undefined contains no valid content besides caption, legend
   Valid content types include image, referenced notebook cell, table, code, iframe, subfigure
⚠️  potential.md unexpected figure content of type image found in legend node
⚠️  potential.md unexpected figure content of type image found in legend node
⚠️  potential.md missing heading depth 3
⚠️  potential.md missing heading depth 4
📖 Built potential.md in 590 ms.
⚠️  hermite.md missing heading depth 3
⚠️  hermite.md missing heading depth 4
⚠️  hermite.md:59 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 12: f[a,a,b,b] &̲= \frac{f[a,b,b…
⚠️  hermite.md:67 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 8: H_2(b) &̲= f(a) + (b-a)f…
📖 Built hermite.md in 589 ms.
📖 Built approx.md in 586 ms.
📖 Built integrate.md in 586 ms.
⚠️  newton_cotes.md:152 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 15: I(f) - I_n(f) &̲= I(f) - I(f_\e…
📖 Built newton_cotes.md in 586 ms.
⚠️  mid_point.md:49 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 60: …b}{2} \right) 
&̲= \half f''(\et…
📖 Built mid_point.md in 586 ms.
⚠️  gauss1.md:114 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 6: I(f) &̲= \int_{-1}^1 f…
📖 Built gauss1.md in 586 ms.
⚠️  opoly.md:133 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 24: …_{n+1},\phi_i} &̲= 0, \qquad 0 \…
⚠️  opoly.md:205 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 18: …p{\phi_n, x^n} &̲= \ip{\phi_n, \…
⚠️  opoly.md:237 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 51: … \phi_{n+1}(y) &̲= a_n (x-y) \ph…
⚠️  opoly.md:266 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 82: …ma_{0} (x-y)} 
&̲= \frac{(A_1 x …
📖 Built opoly.md in 586 ms.
⚠️  extquad.md missing heading depth 3
⚠️  extquad.md missing heading depth 4
📖 Built extquad.md in 585 ms.
⚠️  float.md:161 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 3: 0 &̲ \le x - \fl{x}…
⚠️  float.md:172 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 3: 0 &̲\le \frac{x - \…
⚠️  float.md:266 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 12: 1 + 2^{-t} &̲= [ (.10\ldots …
⚠️  float.md:273 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 18: …l{1 + 2^{-t}} =&̲ (.10\ldots 10)…
⚠️  float.md:282 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 13: 1 + \delta =&̲ [ (.10\ldots 0…
⚠️  float.md:740 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 13: \rho_{k+1} =&̲ \frac{\hats_{k…
⚠️  float.md:756 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 11: |\rho_1| =&̲ 0 \\
|\rho_2| …
⚠️  float.md:766 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 13: |\rho_n| \le&̲ (1 + \theta + …
⚠️  float.md:779 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 10: \hats_1 =&̲ x_1 \\
\hats_2…
⚠️  float.md:792 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 16: \hats_n - s_n =&̲ s_2 \epsilon_2…
⚠️  float.md:823 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 14: \err{\haty} =&̲ |y - \haty| \\…
📖 Built float.md in 722 ms.
📖 Built roots.md in 720 ms.
📖 Built bisect.md in 721 ms.
📖 Built newton.md in 721 ms.
📖 Built secant.md in 721 ms.
📖 Built fpiter.md in 721 ms.
📖 Built homotopy.md in 721 ms.
📖 Built interp.md in 720 ms.
📖 Built lagrange.md in 721 ms.
📖 Built barycentric.md in 720 ms.
⚠️  newton_interp.md:251 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 54: …dots,x_{k-1}] 
&̲= \sum_{j=0}^k …
⚠️  newton_interp.md:342 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 33: …x_N - x_{N-1}) &̲ f[x_0,x_1,\ldo…
📖 Built newton_interp.md in 721 ms.
📖 Built ppinterp.md in 719 ms.
⚠️  splines.md:94 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 7: s(x) =&̲ \frac{1}{6h_i}…
📖 Built splines.md in 719 ms.
⚠️  fourier.md:41 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 5: a_0 &̲= \frac{1}{2\pi…
📖 Built fourier.md in 719 ms.
⚠️  dft.md:289 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 46: …umfr |\hatu_k| &̲= \order{\frac{…
📖 Built dft.md in 720 ms.
📖 Built trapz.md in 719 ms.
📖 Built simpson.md in 719 ms.
📖 Built peano.md in 719 ms.
⚠️  gauss2.md:96 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 9: e_n(x) 
&̲= f(x) - H_n(x)…
⚠️  gauss2.md:181 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 26: …^n v_j p(z_j) 
&̲= \int_a^b w(x)…
📖 Built gauss2.md in 718 ms.
⚠️  squad.md:276 Wrapping with \begin{align*}
   KaTeX parse error: Expected 'EOF', got '&' at position 6: I_1 
&̲= \int_0^{\epsi…
📖 Built squad.md in 718 ms.
📖 Built aquad.md in 718 ms.
📚 Built 33 pages for export (including 32 dependencies) from /Volumes/Samsung_T5/Teaching/numa in 878 ms.
📑 Exported TeX in 16 ms, copying to _build/temp/mystLd2PBC/intro.tex
⛔️ intro.md 'frontmatter' missing required key: date (at intro.md)
🖨  Rendering PDF (default) to _build/temp/mystZs9S2F/intro.pdf
📄 Exported PDF (default) in 1.86 s, copying to _build/exports/intro.pdf
⛔️ _build/exports/intro.pdf LaTeX reported an error building your PDF (default) for intro.tex

@rowanc1
Copy link
Member

rowanc1 commented Jan 14, 2025

Interesting - we do seem to wrap the equation in align* for the web, but do not update the source of the equation, so latex doesn't get those benefits.

This could likely be updated here to write back to the source.

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

No branches or pull requests

2 participants