数学表达式
简介
LaTeX的数学排版功能使它成为编写技术文档的一个引人注目的选择。本文介绍了开始使用LaTeX编写数学的最基本命令。
例如,用LaTeX写基本方程是很简单的:
home/new.tex
\documentclass{article}
\begin{document}
The well known Pythagorean theorem \(x^2 + y^2 = z^2\) was
proved to be invalid for other exponents.
Meaning the next equation has no integer solutions:
\[ x^n + y^n = z^n \]
\end{document}
正如你所看到的,方程的显示方式取决于分隔符,在本例中为 \[...\] and \(...\)
。
数学模式
LATEX允许两种数学表达式的书写模式:内联数学模式和显示数学模式。
- inline 数学模式是用来写属于段落的公式的。
- 显示数学模式用于编写不属于一个段落的表达式,因此被放在单独的行上。
内联数学模式
你可以使用这些 "定界符 "中的任何一种,以内联模式排版你的数学。
\(...\)
$...$
\begin{math}...\end{math}
它们都是有效的,选择是一个品味问题,所以让我们看看一些例子:
home/new.tex
\documentclass{article}
\begin{document}
\noindent Standard \LaTeX{} practice is to write inline math by enclosing it between \verb|\(...\)|:
\begin{quote}
In physics, the mass-energy equivalence is stated
by the equation \(E=mc^2\), discovered in 1905 by Albert Einstein.
\end{quote}
\noindent Instead if writing (enclosing) inline math between \verb|\(...\)| you can use \texttt{\$...\$} to achieve the same result:
\begin{quote}
In physics, the mass-energy equivalence is stated
by the equation $E=mc^2$, discovered in 1905 by Albert Einstein.
\end{quote}
\noindent Or, you can use \verb|\begin{math}...\end{math}|:
\begin{quote}
In physics, the mass-energy equivalence is stated
by the equation \begin{math}E=mc^2\end{math}, discovered in 1905 by Albert Einstein.
\end{quote}
\end{document}
显示数学模式
使用这些结构之一,在显示模式下对数学进行排版。
\[...\]
\begin{displaymath}...\end{displaymath}
\begin{equation}...\end{equation}
显示数学模式有两个版本,可以产生有编号或无编号的方程式。我们来看看一个基 本的例子:
home/new.tex
\documentclass{article}
\begin{document}
The mass-energy equivalence is described by the famous equation
\[E=mc^2\]
discovered in 1905 by Albert Einstein.
In natural units ($c$ = 1), the formula expresses the identity
\begin{equation}
E=m
\end{equation}
\end{document}
另一个例子
下面的例子使用了由amsmath软件包提供的 equation* 环境--更多信息见amsmath文章:
home/new.tex
\documentclass{article}
\usepackage{amsmath} % for the equation* environment
\begin{document}
This is a simple math expression \(\sqrt{x^2+1}\) inside text.
And this is also the same:
\begin{math}
\sqrt{x^2+1}
\end{math}
but by using another command.
This is a simple math expression without numbering
\[\sqrt{x^2+1}\]
separated from text.
This is also the same:
\begin{displaymath}
\sqrt{x^2+1}
\end{displaymath}
\ldots and this:
\begin{equation*}
\sqrt{x^2+1}
\end{equation*}
\end{document}
参考指南
下面是一个包含一些常见数学符号的表格。更完整的列表见希腊字母和数学符号的列表。
描述 | code |
---|---|
希腊字母 | \alpha \beta \gamma \rho \sigma \delta \epsilon |
二进制运算符 | \times \otimes \oplus \cup \cap |
关系运算符 | < > \subset \supset \subseteq \supseteq |
Others | \int \oint \sum \prod |
不同类别的数学符号具有不同的格式特征(例如,变量是斜体,但运算符不是)和不同的间距。
进一步阅读
LaTeX中的数学模式是非常灵活和强大的,有很多东西可以用它来完成。
- Subscripts and superscripts
- Brackets and Parentheses
- Fractions and Binomials
- Aligning Equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Mathematical fonts
- Display style in math mode
- List of Greek letters and math symbols