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

Incorrect LaTeX exponent syntax for Typst input in Pandoc conversion #17

Closed
vlashada opened this issue Nov 6, 2023 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@vlashada
Copy link

vlashada commented Nov 6, 2023

Explain the problem.
When converting typst to pandoc, I get that the typst code $n(a)^(b)$ is translated into \(n(a)\hat{}(b)\) and not \(n(a)^{(b)}\)

To reproduce:

echo "\$n(a)^(b)\$" | pandoc -f typst -t latex

Pandoc version?
I am using the online version, which runs 3.1.9

@vlashada vlashada added the bug Something isn't working label Nov 6, 2023
@jgm
Copy link
Owner

jgm commented Nov 6, 2023

Actually it should be:

\(n(a)^{b}\)

right?

@jgm
Copy link
Owner

jgm commented Nov 6, 2023

I'll move this to jgm/typst-hs which is where this part of the conversion gets done.
Note that $a^(b)$ works fine, so the problem is something like a precedence nesting issue.

@jgm jgm transferred this issue from jgm/pandoc Nov 6, 2023
@jgm
Copy link
Owner

jgm commented Nov 6, 2023

Note to self: typst actually distinguishes between these:

$a_1(x)$

$a_f(x)$

In the first, we have {a_1}(x) (using {} to indicate grouping)
In the second, a_{f(x)}.

@jgm jgm closed this as completed in 145bab9 Nov 7, 2023
@jgm jgm reopened this Nov 7, 2023
@jgm
Copy link
Owner

jgm commented Nov 7, 2023

This fix raised an error in the pandoc test suite, so it's not complete.

$sum_(j = 0)^3 j^2$

should render
image

Pandoc previously converted it to

\sum_{j = 0}^{3}j^{2}

which did render that way. With this change in typst-hs, however, pandoc produces

\sum_{(j = 0)^{3}}j^{2}

which does not render properly.

More examination is needed to match typst's parsing precedence behavior.

The problem is that our parser is grouping (j=0)^3 as a unit and treating that as the argument to _.

@jgm jgm closed this as completed in 71c2494 Nov 7, 2023
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