Skip to content

Math mode confusion when reading latex #2743

Open
mdjurfeldt opened this Issue · 5 comments

2 participants

@mdjurfeldt

When trying to convert

http://trac.sacrideo.us/wg/raw-attachment/wiki/WikiStart/r7rs-small-spec.zip

to epub format through

pandoc r7rs.tex -f latex -t epub -o r7rs.epub

pandoc gets confused at multiple locations in the code regarding whether we are in math mode or not and fails, complaining about an unexpected "^".

This was tested also with the latest release 1.16.0.2.

@jgm
Owner

Small sample case:

pandoc -f latex
$$ \vr{z} = \vri{x} + \vrii{x}\hbox{$i$} = \vriii{x} \cdot e^{i x_4}$$
^D

If you change $i$ to i it works, so that might be a clue.
Looks like the parsers for display math and inline math don't expect $ characters inside.
See mathChars in src/Text/Pandoc/Readers/LaTeX.hs.
It should be possible to fix this by having mathChars swallow anything in balanced braces.

@mdjurfeldt
@jgm jgm added a commit that referenced this issue
@jgm LaTeX reader: handle interior `$` characters in math.
e.g. `$$\hbox{$i$}$$`.

Partially addresses #2743.
7c6a3c0
@jgm
Owner

It would be helpful if you could isolate this a bit more, and give a short test case where pandoc fails.

@mdjurfeldt

[Wrote last message from my cell phone.]

Please find test case enclosed. The pattern used in parts of r7rs.tex is to define an environment derived from tabbing but with math mode switched on. This is correct latex, so pandoc should handle it.

test.tex.txt

@jgm
Owner
@c-forster c-forster pushed a commit to c-forster/pandoc that referenced this issue
@jgm LaTeX reader: handle interior `$` characters in math.
e.g. `$$\hbox{$i$}$$`.

Partially addresses #2743.
96b6616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.