classeur / markdown-it-mathjax

Markdown-it plugin to bypass LaTeX math for mathjax processing.
MIT License
68 stars 20 forks source link

'\\' seems to have been translated to '\' which makes multi-line formulas broken #4

Closed simonmysun closed 7 years ago

simonmysun commented 7 years ago

On my computer, this input:

## (a) $N$th Partial Sum
We write out the $N$th partial sum of the Fourier series of $f(x)$ and expand its coefficients:
$$ \begin{align}
S_N(x) &= a_0 + \sum_{n=1}^N \left[ a_n \cos \left(\frac{n\pi x}{L}\right) + b_n \sin \left(\frac{n\pi x}{L}\right) \right] \\
&= \frac{1}{2L} \int_{-L}^L f(t) dt \\
&+ \frac{1}{L} \sum_{n=1}^N \left[ \int_{-L}^L f(t) \cos\left( \frac{n\pi t}{L} \right) dt \right] \cos\left( \frac{n\pi x}{L} \right) \\
&+ \frac{1}{L} \sum_{n=1}^N \left[ \int_{-L}^L f(t) \sin\left( \frac{n\pi t}{L} \right) dt \right] \sin\left( \frac{n\pi x}{L} \right) \\
&= \frac{1}{L} \int_{-L}^L f(t) \left\{ \frac{1}{2} + \sum_{n=1}^N  \cos\left[ \frac{n\pi (t-x)}{L} \right] \right\} dt.
\end{align} $$

leads to this result:

<h2>(a) $N$th Partial Sum</h2>
<p>We write out the $N$th partial sum of the Fourier series of $f(x)$ and expand its coefficients:
$$ \begin{align}
S_N(x) &amp;= a_0 + \sum_{n=1}^N \left[ a_n \cos \left(\frac{n\pi x}{L}\right) + b_n \sin \left(\frac{n\pi x}{L}\right) \right] \
&amp;= \frac{1}{2L} \int_{-L}^L f(t) dt \
&amp;+ \frac{1}{L} \sum_{n=1}^N \left[ \int_{-L}^L f(t) \cos\left( \frac{n\pi t}{L} \right) dt \right] \cos\left( \frac{n\pi x}{L} \right) \
&amp;+ \frac{1}{L} \sum_{n=1}^N \left[ \int_{-L}^L f(t) \sin\left( \frac{n\pi t}{L} \right) dt \right] \sin\left( \frac{n\pi x}{L} \right) \
&amp;= \frac{1}{L} \int_{-L}^L f(t) \left{ \frac{1}{2} + \sum_{n=1}^N  \cos\left[ \frac{n\pi (t-x)}{L} \right] \right} dt.
\end{align} $$</p>

Then it don't work.

Is it my wrong usage or the rule should be improved?

simonmysun commented 7 years ago

Seams that it's my problem.

Sorry for disturbing.

simonmysun commented 7 years ago

Changing from

import markdownMathjax from 'markdown-it-mathjax';
md.use(markdownMathjax)

to

import markdownMathjax from 'markdown-it-mathjax';
md.use(markdownMathjax())

makes it work.

It's a little weird because .use(require('markdown-it-mathjax')) is my original code before I set up Webpack and Babel.