MyST-Parser
MyST-Parser copied to clipboard
Latex Block Math Displays are Broken
Describe the bug
Writing a Markdown file with math to be Compiled into Latex
When I do a block equation like $$...$$
.
expectation
I expected no errors to occur when running myst-docutils-latex
bug But instead the resulting equation environment has empty lines in it which is a syntax error. I have already submitted a bug over at docutil's bug report page on Soruceforge.
It will also wrap my latex code into a eqation*
environment even when using environments like eqnarray
which should be standalone, which is also a syntax error. However in this instance I'm not sure if this is a bug with docutils or myst-parser.
problem I wanted to use this as a document typesetting solution because markdown is so much better than troff, but the latex conversion is completely broken when using displayed math of any form due to errors in docutils and possibly also myst. I would like to fix these but docutils uses that shitty svn shit-forge site which I can't do anything on.
In short, my only options are:
- Go back to groff.
- Try the html parser.
Reproduce the bug
I already explained that.
List your environment
I'm not using jupyter book.
- Python 3.10.5
- Manjaro Linux
- The newest version of Myst-Parser and docutils.
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Heya, please could you provide working examples of the source text, and what commands you used to convert it
It happens when using myst-docutils-latex
with any block math using either the dollarmath
or amsmath
extensions.
It occurs on every math block that you try, but I'll give an explicit example.
First example (docutils bug)
This is the beginning of the RSA algorithm with p = 41 and q = 23:
$$
n & = & 41*23 = 943 \\
(p-1)(q-1) & = & 40*22 = 880 \\
e & = & 753
$$
Then I run myst-docutils-latex --myst-enable-extensions=dollarmath math.md > math.tex
.
math.tex
converts that snippet into
\begin{align*}
n & = & 41*23 = 943 \\
(p-1)(q-1) & = & 40*22 = 880 \\
e & = & 753
\end{align*}
But there cannot be any blank lines in the align* environment because that is a syntax error in latex. Fortunately this is very easy to fix within the docutils source code.
Second example
Okay, let's try something else. This is taken directly from your documentation that I found here.
$$
\begin{eqnarray}
y & = & ax^2 + bx + c \\
f(x) & = & x^2 + 2xy + y^2
\end{eqnarray}
$$
Running the same command (myst-docutils-latex --myst-enable-extensions=dollarmath math.md > math.tex
) yields the following:
\begin{equation*}
\begin{eqnarray}
y & = & ax^2 + bx + c \\
f(x) & = & x^2 + 2xy + y^2
\end{eqnarray}
\end{equation*}
Now there are two errors:
- The one described from the first example is still present, and...
- The
eqnarray
environment is wrapped in aequation\*
environment which is also incorrect[^1]
I'm not sure if the second one is the fault of myst
or docutils; the two packages combined (along with the markdown-it stuff) make for a lot of code to read through, and my paper is due tonight. So I simply can't afford to spend anymore time on this. I love the project when it works though.
[^1]: eqnarray
should be standalone