equation label
Opened this issue · 8 comments
I have an equation like this
$$\begin{equation}\begin{aligned}my fancy equation\end{aligned}\end{equation}$${#eq:test}
how ever it renders it like this
for it to render properly I have to use it like this
$$\begin{equation}\begin{aligned}my fancy equation\end{aligned}\label{eq:test}\end{equation}$$
doing so, the markdown preview gets corrupted which is apparently a known issue mathjax and obsidian as far as I know.
If I do not use equation environment I will get this error
Error producing PDF. ! Package amsmath Error: \begin{aligned} allowed only in math mode. See asmsmath package documantation for explanation. Type H <return> for immediate help.
I have encountered this before and only solution i could find was using equation.
I don't think you need "\begin{equation}" when you are using Markdown's
$$
to specify an equation. So try this: $$\begin{aligned}my fancy equation\end{aligned}$${#eq:test}
…
On Wed, Nov 15, 2023 at 3:22 AM Amin Gholizad @.> wrote: I have an equation like this $$\begin{equation}\begin{aligned}my fancy equation\end{aligned}\end{equation}$${#eq:test} how ever it renders it like this [image: image] https://user-images.githubusercontent.com/39440488/283058675-6a01316d-8661-43ed-8787-c147e9de3f20.png for it to render properly I have to use it like this $$\begin{equation}\begin{aligned}my fancy equation\end{aligned}\label{eq:test}\end{equation}$$ doing so, the markdown preview gets corrupted which is apparently a known issue mathjax and obsidian as far as I know. — Reply to this email directly, view it on GitHub <#413>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXYRURWANVIITTSAUXSPPX3YESCXBAVCNFSM6AAAAAA7MFH6I2VHI2DSMVQWIX3LMV43ASLTON2WKOZRHE4TIMZXGYYTMNA . You are receiving this because you are subscribed to this thread.Message ID: @.>
I forgot to mention that I am using "obsidian-enhancing-export" plugin which adds this lua filter to the mix
return {
{
Math = function (elem)
if elem.text:find("^%s*\\begin{") ~= nil then
return pandoc.RawInline('tex', elem.text)
else
return elem
end
end,
}
}
Can't reproduce. In fact, the version with
\begin{equation}
fails with a LaTeX error. Here's what I did:
/tmp/test.md
:$$\begin{aligned}my fancy equation\end{aligned}$${#eq:test}
Then run:
pandoc -F pandoc-crossref /tmp/test.md -o /tmp/test.pdfResults in
/tmp/test.pdf
looking like this:
Well, run that filter after pandoc-crossref. It's changing equations to raw TeX, pandoc-crossref doesn't handle raw TeX.
... also, just changing equations to raw TeX sounds like a bad idea, compatibility-wise.
I have several attempts as follows:
$$\begin{equation}\begin{aligned}
y&=2x
\end{aligned}\end{equation}$${#eq:test}
cmd1:
pandoc -F pandoc-crossref /tmp/test.md -o /tmp/test.pdf
cmd2:
pandoc -F pandoc-crossref --lua-filter=/tmp/pdf.lua" /tmp/test.md -o /tmp/test.pdf
now either commands give the same error
Error producing PDF.
! LaTeX Error: Bad math environment delimiter.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.140 ...t\hypertarget{eq:test}{}{\begin{equation}
so adding lua filter after pandoc-crossref does not do much
then I tried:
$$}\begin{aligned}
y&=2x
\end{aligned}$${#eq:test}
now both cmd1 and cmd2 work the same and perfectly.
However not all my equations have a label so
$$}\begin{aligned}
y&=2x
\end{aligned}$$
with cmd1 does not put a equation number
the cmd2 gives this error:
Error producing PDF.
! Package amsmath Error: \begin{aligned} allowed only in math mode.
See the amsmath package documentation for explanation.
Type H <return> for immediate help.
...
l.140 \begin{aligned}
There's an option in pandoc-crossref to number all display math, see the docs (the one you want is autoEqnLabels
). So if you modify your cmd1 or cmd2 by adding -MautoEqnLabels
then your third test should work as you would want, probably.
There's one catch, though, you can't use \begin{equation*}
or other fancy environments this way. In a pinch, you can get by with \nonumber
to suppress numbers for some equations. If you're targeting latex and only latex, and need fancy environments, perhaps consider just using raw latex code and \ref
s.