Simple Method to Insert Math Equations in SteemIt MarkDown Editor 如何在 SteemIt MarkDown Editor 里添加数学公式?

SteemIt Markdown Editor does not support Latex easily. But one alternative (workaround) is to use the Google Tex Image URL. In particular I like Markdown and Latex because it is what-you-think is what-you-get.

我们都知道 STEEMIT支持HTML和MARKDOWN两种编辑模式,一旦启用了一种就无法使用另一种。我比较喜欢用Markdown, 因为这种是一种比较面向程序员 所想即所得的方式 (What you think is what you get).

I am a math fan, in my last post, I realized that inserting equations in SteemIt Markdown or HTML editor is a pain. The fact is that the Latex is not supported in the SteemIt Markdown editor.

同时,我还是一个伪数学爱好者,在上次的帖子里我就发现STEEMIT的MARKDOWN并不支持LATEX数学公式。实际上Markdown和LATEX也是两个独立的语言,在一般的环境下,需要通过第三方的包来启用在Markdown里Latex公式的支持,但是很明显,在SteemIt里不支持。

In Latex, we use $$ or $ to begin a math equation, but it doesn't work in SteemIt editor, obviously.

比如在Latex里,我们通过 $$ 或者 $ 来启用数学公式,这里明显不可以:

$$ \sum_{i=1}^{100} f(i^2) $$

We can use the Google API to show the image by inputing a math equation in the URL: The documentation can be found: https://developers.google.com/chart/infographics/docs/formulas

你看,还是没法显示。 其实我们完全可以通过图片的方式来插入数学公式,这里需要用 Google 的库支持,官方文档在:https://developers.google.com/chart/infographics/docs/formulas

We need to replace the following MATH-Equation with your intended math equation.
我们只需要替换以下 MATH-Equation 为你需要的数学公式即可:

![](https://chart.googleapis.com/chart?cht=tx&chl=MATH-Equation)

For example,
比如:

![](https://chart.googleapis.com/chart?cht=tx&chl=c=\sqrt{x^2%2By^2})

It shows:
显示效果为:

What the hell is the %2B in the URL? You will need to percentage-encode the URL parameters as some symbols represent special meanings in URL.

但,这里面的%2B 又是什么鬼?因为数学公式里含有的一些在URL中表达特殊的字符,像空格,加号,等号什么都得转义,

Here, I recommend an online tool (written by me) to encode the equation/text:
这里推荐一个我很久以前写的工具

https://helloacm.com/tools/url-encode-decode/

For example:
比如把

$$ \sum_{i=1}^{100} f(i^2) $$

URL-encoded becomes:
转义后就是:

%24%24%20%5Csum_%7Bi%3D1%7D%5E%7B100%7D%20f(i%5E2)%20%24%24

And the final Image URL to insert is:
然后整个图片地址就是:

https://chart.googleapis.com/chart?cht=tx&chl=%24%24%20%5Csum_%7Bi%3D1%7D%5E%7B100%7D%20f(i%5E2)%20%24%24

This is how it looks like:
效果为:

I do hope that the SteemIt team supports Latex in the Markdown one day!

SteemIt里没法原生态支持,这至少目前是个可行的方案,我真心希望SteemIt团队能把LATEX这个功能加上去,这样就能方便广大数学爱好者了,至少像我这种伪数学爱好者也能时不时晒晒公式装装B,是吧?

Originally published at https://steemit.com Thank you for reading my post, feel free to Follow, Upvote, Reply, ReSteem (repost) @justyy which motivates me to create more quality posts.

原创 https://Steemit.com 首发。感谢阅读,如有可能,欢迎Follow, Upvote, Reply, ReSteem (repost) @justyy 激励我创作更多更好的内容。

// 稍后同步到我的中文博客英文博客

近期热贴 Recent Popular Posts

H2
H3
H4
3 columns
2 columns
1 column
17 Comments