前言
总结一些在博客园使用MathJax写数学公式的经验。
博客园
设置使用数学公式
- 进入你的博客:管理 > 选项
里面有个启用数学公式支持,选上后保存。
这时,你就可以在你的博客里写数学公式了。
美化数学公式
本文中数学公式的显示风格和默认的不同。
数学公式的背景色为浅灰;
行间数学公式有个灰色框;
行间数学公式设定为居左;
行间数学公式带编号。
下面是对应的配置。
- 进入你的博客管理 > 配置
在页首脚tml代码中输入一下内容:
<script type="text/x-mathjax-config"> MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']], processEscapes: true }, displayAlign : "left", TeX: { equationNumbers: { autoNumber: "all", useLabelIds: true } }, "HTML-CSS": { linebreaks: { automatic: true }, scale: 100, styles: { ".MathJax_Display": { "text-align": "left", "width" : "auto", "margin": "10px 0px 10px 0px !important", "background-color": "#f5f5f5 !important", "border-radius": "3px !important", border: "1px solid #ccc !important", padding: "5px 5px 5px 5px !important" }, ".MathJax": { "background-color": "#f5f5f5 !important", padding: "2px 2px 2px 2px !important" } } }, SVG: { linebreaks: { automatic: true } } }); </script> <!-- <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> </script> -->
注意:如果你发现保存后,输入的内容丢失了。这是因为默认情况下不能在页脚Html代码使用JS.
配置页面上有个申请使用JS的按钮(具体的按钮标签记不清了),
点击这个按钮,输入申请理由,比如:“需要使用MathJax写数学公式”, 然后等管理员批准之后,就可以输入了。
- 参照
如果你想配置你的特有风格,可以参照这里:- Loading and Configuring MathJax
- The TeX input processor
- CSS Style Objects
LaTex 语法
- 行内
一个行内$f(x)$
函数.
一个行内f(x)f(x)函数 - 行间
一个行间
$$f(x)$$
函数
一个行间
f(x)(1)(1)f(x)
函数
- 一些例子
LaTex Syntax | Sample | Description |
---|---|---|
a \qquad b | abab | double quad space |
a \quad b | abab | quad space |
a\ b$ | xixi | subscript |
\text{subject to} | subject tosubject to | text |
e^{i\pi} | eiπeiπ | upperscript |
x_i^2 | x2ixi2 | subscript and upperscript |
\sqrt{2} | 2–√2 | square root |
\frac{1}{2} | 1212 | fraction |
\textstyle \sum_{i=1}^n w_ix_i | ∑ni=1wixi∑i=1nwixi | sum |
\displaystyle \sum_{i=1}^n w_ix_i | ∑i=1nwixi∑i=1nwixi | sum |
\because | ∵∵ | because |
\therefore | ∴∴ | therefore |
= | == | equal to |
> | >> | great than |
< | << | great than |
\geqslant | ⩾⩾ | great than and equal to |
\leqslant | ⩽⩽ | less than and equal to |
\geq | ≥≥ | great than and equal to |
\leq | ≤≤ | less than and equal to |
\neq | ≠≠ | not equal to |
\lVert w \rVert | ∥w∥‖w‖ | vertical |
\langle x, y \rangle | ⟨x,y⟩⟨x,y⟩ | angle |
\underset{a}{max} | maxamaxa | under set |
\bar{\gamma} | γ¯γ¯ | bar |
- multiple lines
b =
\begin{cases}
b_1, & \text{if}\ b_1 > 0 \\
b_2, & \text{if}\ b_2 > 0 \\ \frac{b_1 + b_2}{2} & \text{otherwise} \end{cases}
b=⎧⎩⎨⎪⎪b1,b2,b1+b22if b1>0if b2>0otherwise(2)(2)b={b1,if b1>0b2,if b2>0b1+b22otherwise
LaTex资源
- Help:Displaying a formula
- LaTeX Wiki
- List of LaTeX symbols
- LaTeX/数学公式
- LaTeX documentation
原文:https://www.cnblogs.com/steven-yang/p/5668125.html