数学表达式
简介
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}