katex.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Tex 科学公式语言 (TeX/LaTeX) - Editor.md examples</title>
  6. <link rel="stylesheet" href="css/style.css" />
  7. <link rel="stylesheet" href="../css/editormd.css" />
  8. <link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
  9. </head>
  10. <body>
  11. <div id="layout">
  12. <header>
  13. <h1>Tex 科学公式语言 (TeX/LaTeX)</h1>
  14. <p>Based on KaTeX.js:<a href="http://khan.github.io/KaTeX/" target="_blank">http://khan.github.io/KaTeX/</a></p>
  15. <p>P.S. Default using CloudFlare KaTeX's CDN. (注:默认使用 CloudFlare 的 CDN,有时加载速度会比较慢,可自定义加载地址。)</p>
  16. <br/>
  17. <p><a href="https://jsperf.com/katex-vs-mathjax" target="_blank">KaTeX vs MathJax</a></p>
  18. </header>
  19. <div id="test-editormd">
  20. <textarea style="display:none;">[TOC]
  21. #### Setting
  22. {
  23. tex : true
  24. }
  25. #### Custom KaTeX source URL
  26. ```javascript
  27. // Default using CloudFlare KaTeX's CDN
  28. // You can custom url
  29. editormd.katexURL = {
  30. js : "your url", // default: //cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min
  31. css : "your url" // default: //cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min
  32. };
  33. ```
  34. #### Examples
  35. ##### 行内的公式 Inline
  36. $$E=mc^2$$
  37. Inline 行内的公式 $$E=mc^2$$ 行内的公式,行内的$$E=mc^2$$公式。
  38. $$c = \\pm\\sqrt{a^2 + b^2}$$
  39. $$x &gt; y$$
  40. $$f(x) = x^2$$
  41. $$\alpha = \sqrt{1-e^2}$$
  42. $$\(\sqrt{3x-1}+(1+x)^2\)$$
  43. $$\sin(\alpha)^{\theta}=\sum_{i=0}^{n}(x^i + \cos(f))$$
  44. $$\\dfrac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}$$
  45. $$f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi$$
  46. $$\displaystyle \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }$$
  47. $$\displaystyle \left( \sum\_{k=1}^n a\_k b\_k \right)^2 \leq \left( \sum\_{k=1}^n a\_k^2 \right) \left( \sum\_{k=1}^n b\_k^2 \right)$$
  48. $$a^2$$
  49. $$a^{2+2}$$
  50. $$a_2$$
  51. $${x_2}^3$$
  52. $$x_2^3$$
  53. $$10^{10^{8}}$$
  54. $$a_{i,j}$$
  55. $$_nP_k$$
  56. $$c = \pm\sqrt{a^2 + b^2}$$
  57. $$\frac{1}{2}=0.5$$
  58. $$\dfrac{k}{k-1} = 0.5$$
  59. $$\dbinom{n}{k} \binom{n}{k}$$
  60. $$\oint_C x^3\, dx + 4y^2\, dy$$
  61. $$\bigcap_1^n p \bigcup_1^k p$$
  62. $$e^{i \pi} + 1 = 0$$
  63. $$\left ( \frac{1}{2} \right )$$
  64. $$x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}$$
  65. $${\color{Blue}x^2}+{\color{YellowOrange}2x}-{\color{OliveGreen}1}$$
  66. $$\textstyle \sum_{k=1}^N k^2$$
  67. $$\dfrac{ \tfrac{1}{2}[1-(\tfrac{1}{2})^n] }{ 1-\tfrac{1}{2} } = s_n$$
  68. $$\binom{n}{k}$$
  69. $$0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+\cdots$$
  70. $$\sum_{k=1}^N k^2$$
  71. $$\textstyle \sum_{k=1}^N k^2$$
  72. $$\prod_{i=1}^N x_i$$
  73. $$\textstyle \prod_{i=1}^N x_i$$
  74. $$\coprod_{i=1}^N x_i$$
  75. $$\textstyle \coprod_{i=1}^N x_i$$
  76. $$\int_{1}^{3}\frac{e^3/x}{x^2}\, dx$$
  77. $$\int_C x^3\, dx + 4y^2\, dy$$
  78. $${}_1^2\!\Omega_3^4$$
  79. ##### 多行公式 Multi line
  80. > \`\`\`math or \`\`\`latex or \`\`\`katex
  81. ```math
  82. f(x) = \int_{-\infty}^\infty
  83. \hat f(\xi)\,e^{2 \pi i \xi x}
  84. \,d\xi
  85. ```
  86. ```math
  87. \displaystyle
  88. \left( \sum\_{k=1}^n a\_k b\_k \right)^2
  89. \leq
  90. \left( \sum\_{k=1}^n a\_k^2 \right)
  91. \left( \sum\_{k=1}^n b\_k^2 \right)
  92. ```
  93. ```math
  94. \dfrac{
  95. \tfrac{1}{2}[1-(\tfrac{1}{2})^n] }
  96. { 1-\tfrac{1}{2} } = s_n
  97. ```
  98. ```katex
  99. \displaystyle
  100. \frac{1}{
  101. \Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{
  102. \frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {
  103. 1+\frac{e^{-6\pi}}
  104. {1+\frac{e^{-8\pi}}
  105. {1+\cdots} }
  106. }
  107. }
  108. ```
  109. ```latex
  110. f(x) = \int_{-\infty}^\infty
  111. \hat f(\xi)\,e^{2 \pi i \xi x}
  112. \,d\xi
  113. ```
  114. #### KaTeX vs MathJax
  115. [https://jsperf.com/katex-vs-mathjax](https://jsperf.com/katex-vs-mathjax "KaTeX vs MathJax")
  116. </textarea>
  117. </div>
  118. </div>
  119. <script src="js/jquery.min.js"></script>
  120. <script src="../editormd.js"></script>
  121. <script type="text/javascript">
  122. $(function() {
  123. var testEditor = editormd("test-editormd", {
  124. width: "90%",
  125. height: 640,
  126. path : '../lib/',
  127. tex : true
  128. });
  129. });
  130. </script>
  131. </body>
  132. </html>