在博客中使用MathJax写数学公式

前言

总结一些在博客园使用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写数学公式”, 然后等管理员批准之后,就可以输入了。

LaTex 语法

  • 行内
    一个行内$f(x)$函数.
    一个行内f(x)f(x)函数
  • 行间
    一个行间
$$f(x)$$

函数
一个行间

f(x)(1)(1)f(x)


函数

 

  • 一些例子
LaTex SyntaxSampleDescription
a \qquad bababdouble quad space
a \quad bababquad space
a\ b$xixisubscript
\text{subject to}subject tosubject totext
e^{i\pi}eiπeiπupperscript
x_i^2x2ixi2subscript and upperscript
\sqrt{2}2–√2square root
\frac{1}{2}1212fraction
\textstyle \sum_{i=1}^n w_ix_ini=1wixi∑i=1nwixisum
\displaystyle \sum_{i=1}^n w_ix_ii=1nwixi∑i=1nwixisum
\becausebecause
\thereforetherefore
===equal to
>>>great than
<<<great than
\geqslantgreat than and equal to
\leqslantless than and equal to
\geqgreat than and equal to
\leqless than and equal to
\neqnot equal to
\lVert w \rVertw‖w‖vertical
\langle x, y \ranglex,y⟨x,y⟩angle
\underset{a}{max}maxamaxaunder 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资源

原文:https://www.cnblogs.com/steven-yang/p/5668125.html

转载于:https://www.cnblogs.com/Ph-one/p/11064570.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值