美文网首页
LaTex语法与实例

LaTex语法与实例

作者: victorsungo | 来源:发表于2016-11-01 20:00 被阅读0次

<font size=4>前言:最近没课在看一些书,博客搭好了所以想写一些笔记/分享,但是发现公式的编辑很是一个问题,怎样才能用比较简单快速的方法编辑出美观规范的数学公式呢?语法+工具</font>

1.配置hexo-math插件

我使用的是NexT主题,对于大多数主题来说,推荐可以使用hexo-math插件来完成对LaTex公式的渲染。只需一步即可完成:
$ npm install hexo-math --save
是不是很省心~

2.常用LaTex语法

在这里我按照现有的文档总结了几个实用的LaTex语法:

段落处理

操作 方式
空格 不起作用
换行 \
分段 \par
换页 \newpage

西文字符转换表

实用为主,不赘述,可以用工具完成,工具下面会介绍

字号转换命令表

中文字号 控制命令
一号 \Huge
二号 \huge
三号 \LARGE
四号 \Large
小四号 \large
五号 \normalsize
小五号 \small
六号 \footnotesize
小六号 \scriptsize

页面控制命令

系统默认:字号10pt= 五号字;西文字体为罗马字体;textwidth=12.2cm,textheight=18.6cm。相当于美国标准信纸大小。
可以通过以下操作改变页面尺寸:

\textwidth=
\textheight=
3.LaTex 公式渲染与 Markdown 渲染冲突问题

如LaTex 中的下划线_就会出现解析错误。解决方法有很多,这里介绍两种:

  • 将LaTex 语法公式中的所有_加反斜线 \转义,即\_可以解析成功。
    但是,这样的方式将导致所有的下标都修改一遍。
  • 将公式前后的一对$分别换成{% math %}和{% endmath %}。
    这种的方法实例将在5中给出。
4.在线LaTex编辑器

即使掌握了LaTex语法,但是编辑公式仍然是费时费力的,这里推荐在线LaTex编辑器,可以实现实时预览功能的同时还提供了图形辅助操作,节省了记忆和查询语法的时间。相信你在第一眼看到它的时候就会用啦~
但是,最基本的语法还是要掌握的,工具不是万能的,有些生僻的格式还需要语法知识,相辅相成嘛。
OK,用下面展示一些常用的代码实例。

5.常用公式代码实例

上下标

 {% math %}
\begin{aligned}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{aligned}
{% endmath %}  

{% math %}
\begin{aligned}
\dot{x} & = \sigma(y-x) \
\dot{y} & = \rho x - y - xz \
\dot{z} & = -\beta z + xy
\end{aligned}
{% endmath %}

积分与求和

{% math %}
\begin{aligned}
\sum_{i=1}^{n}x_{i}=\int_{0}^{1}f(x)\mathrm{d}x 
\end{aligned}
{% endmath %} 

{% math %}
\begin{aligned}
\sum_{i=1}{n}x_{i}=\int_{0}{1}f(x)\mathrm{d}x
\end{aligned}
{% endmath %}

{% math %}
\begin{aligned}
\sum_{
1\leqslant i\leq n \atop
1\leqslant j\leq n
}a_{ij}
\end{aligned}
{% endmath %}

{% math %}
\begin{aligned}
\sum_{
1\leqslant i\leq n \atop
1\leqslant j\leq n
}a_{ij}
\end{aligned}
{% endmath %}

极限

{% math %}
\begin{aligned}
\lim_{n \to \infty }\sin x_{n}=0 
\end{aligned}
{% endmath %} 

{% math %}
\begin{aligned}
\lim_{n \to \infty }\sin x_{n}=0
\end{aligned}
{% endmath %}

根式

 {% math %}
\begin{aligned}
x=\sqrt[m]{1+x^{p}}
\end{aligned}
{% endmath %} 

{% math %}
\begin{aligned}
x=\sqrt[m]{1+x^{p}}
\end{aligned}
{% endmath %}

绝对值

 {% math %}
\begin{aligned}
\left | a+b \right |=\coprod_{m}^{n} \frac{e}{f}
\end{aligned}
{% endmath %}

{% math %}
\begin{aligned}
\left | a+b \right |=\coprod_{m}^{n} \frac{e}{f}
\end{aligned}
{% endmath %}

矩阵

{% math %}
\begin{aligned}
\begin{pmatrix}
1 & 3 & 5 \\ 
2 & 4 & 6
\end{pmatrix}
\end{aligned}
{% endmath %}  

{% math %}
\begin{aligned}
\begin{pmatrix}
1 & 3 & 5 \
2 & 4 & 6
\end{pmatrix}
\end{aligned}
{% endmath %}

花括号

{% math %}
\begin{aligned}
\overbrace{a+b+\cdots +y+z}^{26}_{=\alpha +\beta} 
\end{aligned}
{% endmath %} 

{% math %}
\begin{aligned}
\overbrace{a+b+\cdots +y+z}^{26}_{=\alpha +\beta}
\end{aligned}
{% endmath %}

{% math %}
\begin{aligned}
a+\underbrace{b+\cdots +y}_{24}+z 
\end{aligned}
{% endmath %}

{% math %}
\begin{aligned}
a+\underbrace{b+\cdots +y}_{24}+z
\end{aligned}
{% endmath %}

堆砌

{% math %}
\begin{aligned}
y\stackrel{\rm def}{=} f(x) \stackrel{x\rightarrow 0}{\rightarrow} A 
\end{aligned}
{% endmath %}

{% math %}
\begin{aligned}
y\stackrel{\rm def}{=} f(x) \stackrel{x\rightarrow 0}{\rightarrow} A
\end{aligned}
{% endmath %}


相关文章

  • LaTex语法与实例

    前言:最近没课在看一些书,博客搭好了所以想写一些笔记/分享,但是发现公式的编辑很是一个问题,怎样才能用比较简单快速...

  • Markdown分段函数及其相似(Latex)

    一、语法: 二、效果: 三、参考文章: 1、【LaTeX】分段函数与LaTex[https://www.jians...

  • sql教程6分组、转义与模糊匹配、正则表达式

    GROUP BY 语法 实例 转义与模糊匹配 语法 实例 正则表达式 语法 实例

  • 在简书中使用Latex书写数学公式

    开宗明义 简书中使用Latex写法: Latex语法基础: 1.LaTeX文件的通常语法如下: \document...

  • latex语法

    1. latex 语法 latex笔记:基本语法[https://zhuanlan.zhihu.com/p/243...

  • LaTeX语法介绍

    LaTeX语法介绍 什么是LaTeX LaTeX(LATEX,音译"拉泰赫")是一种基于TeX的排版系统,最大的特...

  • markdown数学公式latex语法

    作者:魏文应 时间:2019-03-21 latex 语法需要相关插件的支持,查看 latex 语法,最直接的方...

  • lateX 实例

    画矩阵需要用到特殊的语法(1)画普通矩阵,不带括号的 (2)画带中括号的矩阵 (3) 画带大括号的矩阵 (4)矩阵...

  • latex

    简介:这里写几个latex常用的语法示例以供参考。 ###1. latex代码 ``` \documentclas...

  • LaTex语法

    参考链接 1. 内联公式 使用$...$,需要单行显示的公式,使用$$...$$。例如:$\sum_{i=0}^n...

网友评论

      本文标题:LaTex语法与实例

      本文链接:https://www.haomeiwen.com/subject/whsmuttx.html