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

bugs about math blocks in markdown environment #94

Closed
yfzhao20 opened this issue Aug 10, 2021 · 2 comments
Closed

bugs about math blocks in markdown environment #94

yfzhao20 opened this issue Aug 10, 2021 · 2 comments
Labels
duplicate feature request lua Related to the Lua interface and implementation

Comments

@yfzhao20
Copy link

Hi! When I use $$...$$ (math blocks) in markdown environment, it gives me a thousand bugs😂 like that:

image

Here is my file:

\documentclass[UTF8]{ctexart}
\usepackage[hybrid]{markdown}
\usepackage{amsmath}
\begin{document}
\begin{markdown}
$$
\begin{aligned}
\cos^n\theta&=\left(\frac{e^{i\theta}+e^{-i\theta}}{2}\right)^n\\
&=(\frac{1}{2})^n(\sum\limits_{m=0}^{n}\tbinom{n}{m}e^{i\theta(n-2m)})\\
&=(\frac{1}{2})^n(\sum\limits_{m=0}^{n}\tbinom{n}{m}\frac{e^{i\theta(n-2m)}+e^{-i\theta(n-2m)}}{2})\\
&=(\frac{1}{2})^n(\sum\limits_{m=0}^{n}\tbinom{n}{m}\cos(n-2m)\theta)\\
\sin^n\theta&=\left(\frac{e^{i\theta}-e^{-i\theta}}{2i}\right)^n\\
&=(\frac{1}{2i})^n(\sum\limits_{m=0}^{n}\tbinom{n}{m}e^{i\theta(n-2m)}(-1)^m)\\
&=(\frac{1}{2i})^2(\sum\limits_{m=1}^{n}\tbinom{n}{m}\frac{e^{i\theta(n-2m)}i^{2m}+e^{i\theta(2m-n)}i^{2(n-m)}}{2})\\
&=(\frac{1}{2})^n(\sum\limits_{m=1}^{n}\tbinom{n}{m}\frac{e^{i\theta(n-2m)}(-i)^{n-2m}+e^{-i\theta(n-2m)}i^{n-2m}}{2})\\
&=(\frac{1}{2})^n(\sum\limits_{m=0}^{n}\tbinom{n}{m}\frac{e^{i(\theta-\frac{\pi}{2})(n-2m)}+e^{-i(\theta-\frac{\pi}{2})(n-2m)}}{2})\\
&=(\frac{1}{2})^n(\sum\limits_{m=0}^{n}\tbinom{n}{m}\cos(n-2m)(\theta-\frac{\pi}{2}))\\
\end{aligned}
$$
\end{markdown}
\end{document}

however if I only keep the first two lines of my math formula, everything will be okay:

\documentclass[UTF8]{ctexart}
\usepackage[hybrid]{markdown}
\usepackage{amsmath}
\begin{document}
\begin{markdown}
$$
\begin{aligned}
\cos^n\theta&=\left(\frac{e^{i\theta}+e^{-i\theta}}{2}\right)^n\\
&=(\frac{1}{2})^n(\sum\limits_{m=0}^{n}\tbinom{n}{m}e^{i\theta(n-2m)})\\
\end{aligned}
$$
\end{markdown}
\end{document}

The code of math block should be okay because I have tested it in Markdown editor. It should be displayed like this:

image

What's the matter? Is it the bug of markdown package, or my fault?🤔

by the way: I find only \\\\ can give me correct line break in math block but not \\, even I open "hybrid".

Thanks!!

@Witiko
Copy link
Owner

Witiko commented Aug 10, 2021

@yfzhao20 I am sorry to hear about your trouble. It's best to drop out of markdown before math blocks:

\documentclass[UTF8]{ctexart}
\usepackage[hybrid]{markdown}
\usepackage{amsmath}
\begin{document}
\begin{markdown}
Here is a formula:
\end{markdown}
$$
\begin{aligned}
\cos^n\theta&=\left(\frac{e^{i\theta}+e^{-i\theta}}{2}\right)^n\\
... trimmed for brevity
\end{aligned}
$$
\begin{markdown}
Let's talk about something else ...
\end{markdown}
\end{document}

As you have noticed, \\ and _ will get interpreted by Markdown as \ and the beginning of emphasized text, respectively. You can disable the interpretation of _ by specifying the underscores=false option, but you still have to write \\\\ for \\.

I am closing this issue as a duplicate of #61. Please, feel free to direct further questions and ideas there.

@Witiko Witiko closed this as completed Aug 10, 2021
@Witiko Witiko added lua Related to the Lua interface and implementation duplicate feature request labels Aug 10, 2021
@yfzhao20
Copy link
Author

Ah! It works after I let underscores=false✅. But I still have to write \\\\ for \\ . Thanks🎉!
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate feature request lua Related to the Lua interface and implementation
Projects
None yet
Development

No branches or pull requests

2 participants