zoukankan      html  css  js  c++  java
  • 在博客中使用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) ]

    函数

    • 一些例子
    LaTex Syntax Sample Description
    a qquad b (a qquad b) double quad space
    a quad b (a quad b) quad space
    a b$ (x_i) subscript
    ext{subject to} ( ext{subject to}) text
    e^{ipi} (e^{ipi}) upperscript
    x_i^2 (x_i^2) subscript and upperscript
    sqrt{2} (sqrt{2}) square root
    frac{1}{2} (frac{1}{2}) fraction
    extstyle sum_{i=1}^n w_ix_i ( extstyle sum_{i=1}^n w_ix_i) sum
    displaystyle sum_{i=1}^n w_ix_i (displaystyle sum_{i=1}^n w_ix_i) sum
    ecause (ecause) because
    herefore ( herefore) therefore
    = (=) equal to
    > (>) great than
    < (<) great than
    geqslant (geqslant) great than and equal to
    leqslant (leqslant) less than and equal to
    geq (geq) great than and equal to
    leq (leq) less than and equal to
    eq ( eq) not equal to
    lVert w Vert (lVert w Vert) vertical
    langle x, y angle (langle x, y angle) angle
    underset{a}{max} (underset{a}{max}) under set
    ar{gamma} (ar{gamma}) bar
    • multiple lines
    b = 
    egin{cases}
        b_1, & 	ext{if} b_1 > 0  \
        b_2, & 	ext{if} b_2 > 0  \
        frac{b_1 + b_2}{2} & 	ext{otherwise}
    end{cases}
    

    [b = egin{cases} b_1, & ext{if} b_1 > 0 \ b_2, & ext{if} b_2 > 0 \ frac{b_1 + b_2}{2} & ext{otherwise} end{cases} ]

    LaTex资源

  • 相关阅读:
    重构29-Remove Middle Man(去掉中间人)
    重构30-Return ASAP(尽快返回)
    重构26-Remove Double Negative(去掉双重否定)
    yaml语法学习3
    运行原理探究2
    SpringBoot简介 1
    SpringMVC项目所引用的一切依赖jar包和自定义设置
    2020/07/03 初始mybatis
    json数据格式字符串在java中的转移
    项目中遇到的一些异常
  • 原文地址:https://www.cnblogs.com/steven-yang/p/5668125.html
Copyright © 2011-2022 走看看