简单公式与运算符号

\documentclass{article}
\usepackage{ctex}
\usepackage{amsmath}
% equation*和matrix需要使用这个包
\usepackage{amssymb}
% \mathbb{}需要该包

\begin{document}
	\section{简介}
	\LaTeX{}将排版内筒分为文本模式和数学模式。文本模式用于普通文本排版,数学模式用于公式排版。
	
	%
	\section{行内公式}
	% 可用美元符号:$公式$
	% 或反斜杠引出小括号:\(公式\)
	% 或math环境排版
  \subsection{美元符号}
  交换律是$a+b=b+a$,如$1+2=2+1=3$。
  
  \subsection{小括号}
  交换律是\(a+b=b+a\),如\(1+2=2+1=3\)。
  
  \subsection{math环境}
  交换律是\begin{math}a+b=b+a\end{math},如\begin{math}1+2=2+1=3\end{math}。
  
  
  %
  \section{上下标}
  \subsection{上标}
  $3x^{20} - x + 2 = 0$
  % ^只作用于相邻的数字符号,超过一个指数需用大括号确保作用范围,括号内写什么都可以
  $3x^{3x^{20} - x + 2 = 0} - x + 2 = 0$
  
  \subsection{下标}
  $a_0, a_1, a_2$
  $a_0, a_1, a_2, ..., a_{3x^{20} - x + 2 = 0}$
  
  
  %
  **\section{希腊字母}**
  $\alpha$
  $\beta$
  $\gamma$
  $\epsilon$
  $\pi$
  $\omega$
  
  $\Gamma$
  $\Delta$
  $\Theta$
  $\Pi$
  $\Omega$
  
  $\alpha^3 + \beta^2 + \gamma = 0$
  
  
  **%
  \section{数学函数}**
  $\log$
  $\sin$
  $\cos$
  $\arcsin$
  $\arccos$
  $\ln$
  
  $\sin^2 x + \cos^2 x = 1$
  $y = \arcsin x$
  
  $y = \sin^{-1} x$
  
  $y = \log_2 x$
  
  $y = \ln x$
  
  **$sqrt{2}$
  $sqrt{x^2 + y^2}$
  $sqrt{2 + \sqrt{2}}$
  $sqrt[4]{x}$
  
  
  %
  \section{分式}
  大约是原体积的$3/4$
  大约是原体积的$\frac{3}{4}$
  
  $\frac{x}{x^2 + x +1}$
  
  $\frac{\sqrt{x-1}}{\sqrt{x+1}}$
  
  $\frac{1}{1 + \frac{1}{x}}$
  
  $\sqrt{\frac{x}{x^2 + x + 1}}$
  
  
  %
  \section{行间公式}
  \subsection{美元符号}**
  交换律是$$a+b=b+a$$
  如$$1+2=2+1=3$$
  
  **\subsection{中括号}**
  交换律是
  \[a+b=b+a\]
  如
  \[1+2=2+1=3$$\]
  
  **\subsection{displaymath环境}**
  交换律是
  \begin{displaymath}
	  a+b=b+a,
  \end{displaymath}
  如
  \begin{displaymath}
	  1+2=2+1=3.
  \end{displaymath}
  
	**\subsection{自动编号公式equation环境}**
	交换律见式\ref{eq:commutative}
	****\begin{equation}
	  a+b=b+a \label{eq:commutative}
  \end{equation}
  
	**\subsection{不编号公式equation*环境}**
	交换律见式\ref{eq:commutative2}
	****\begin{equation*}
	  a+b=b+a \label{eq:commutative2}
  \end{equation*}
  
  公式的编号和交叉引用也是自动实现的。
	
****\end{document}

image.png

image.png

image.png

image.png

image.png

image.png

image.png

矩阵

排版与tabular类似,&分列,\\分行

image.png

可生成左侧省略号:

image.png

\documentclass{article}
\usepackage{ctex}
\usepackage{amsmath}
% equation*和matrix需要使用这个包
\usepackage{amssymb}
% \mathbb{}需要该包
\newcommand{\adots}{\mathinner{\mkern2mu%
	\raisebox{0.1em}{.}\mkern2mu\raisebox{0.4em}{.}%
	\mkern2mu\raisebox{0.7em}{.}\mkern1mu}}

\begin{document}
	\[
	\begin{matrix}
		0&1\\
		1&0\\
	\end{matrix} \qquad
	
	% pmatrix加小括号
	\begin{pmatrix}
		0&-i\\
		i&0\\
	\end{pmatrix} \qquad
	
	% bmatrix加中括号
	\begin{bmatrix}
		0&-1\\
		1&0\\
	\end{bmatrix} \qquad
	
	% Bmatrix加大括号
	\begin{Bmatrix}
		0&-1\\
		1&0\\
	\end{Bmatrix} \qquad
	
	% vmatrix加单竖线
	\begin{vmatrix}
		a&b\\
		c&d\\
	\end{vmatrix} \qquad
	
	% Vmatrix加双竖线
	\begin{Vmatrix}
		0&-i\\
		i&0\\
	\end{Vmatrix}
	\]
	
	%可以使用上下标
	\[
	A = \begin{pmatrix}
	a_{11}^2 & a_{12}^2 & a_{13}^2 \\
	0 & a_{22} & a_{23}\\
	0 & 0 & a_{33}
	\end{pmatrix}
	\]
	
	% 常用省略号:\dots、vdots、\dddots
	% \times排版乘号
	\[
	A = begin{bmatrix}
	a_{11} & \dots & a_{1n} \\
	& \ddots & \vdots\\
	0 & & a_{nn}
	\end{bmatrix}_{n \times n}]
	\]
	
	% 分块矩阵(矩阵嵌套)
	\[
	\begin{pmatrix}
	\begin{matrix} 1&0\\0&1 end{matrix}
	& \text{\Large 0}\\
	\text{\Large 0} & \begin{matrix}1&0\\0&-1\end{matrix}
	\end{pmatrix}
	\]
	%其中\text{}命令,让数学模式临时切换成文本模式
	
	%三角矩阵
	\[\begin{pmatrix}
	a_{11} & a_{12} & \cdots & a_{1n} \\
	& a_{22} & \cdots & a_{2n} \\
	& & \ddots & \vdots\\
	\multicolumn{2}{c}{\raisebox{1.3ex}[8pt]{\Huge 0}}
	& & a_{nn}
	\end{pmatrix}\]
	%\multicolumn合并多列,\raisebox调整高度
	
	% 跨列的省略号\hdotsfor{<列数>}
	\[\begin{pmatrix}
	1 & \frac 12 & \dots & \frac 1n \\
	\hdotsfon{4}\\
	m & \frac m2 & \dots & frac mn
	\end{pmatrix}\]
	
	%行内小矩阵(smallmatrix)环境
	复数 $z =(x,y)$ 也可用矩阵
	\begin{math}
	\left( % 需要手动加上左括号
	\begin{smallmatrix}
	x & -y \\ y & x
	\end{smallmatrix}
	\right) % 需要手动加上右括号
	\end{math}来表示。
	
	% array环境(类似于表格环境tabular)
	\[
	\begin{array}{r|r}
	\frac12 & 0 \\ %这里frac没有用{}分组,是因为只有单个数字或字母,见下一行的abc
	\hline
	0 & -\frac abc \\
	\end{array}1]
	
	
	% array环境可以构造复杂矩阵
	\[
	\begin{array}{c@{\hspace{-5pt}}l}
	% @{<内容>}-添加任意内容,不占表项计数
	% 此处添加一个负值空白,表示向左移-5pt的距离
	
	% 第1行,第1列
	\left(
	\begin{array}{ccc|ccc}
	a & \dots & a & b & \cdots & b\\
	& \ddots & \vdots & \vdots & \adots\\
	& & a & b\\ \hline
	& & & c & \cdots & c\\
	& & & \vdots & & \vdots\\
	\multicolumn{3}{c|}{\raisebox{2ex}[0pt]{\Huge 0}} & c & \cdots & c
	\end{array}
	\right)
	&
	% 第1行,第2列(p、q大括号那一列)
	\begin{array}{l}
	%\left.仅表示与\right\}配对,什么都不输出
	\left.\rule{0mm}{7mm}\right\}p\\
	\\
	left.\rule{0mm}{7mm}right\}q
	\end{array}
	\\[-5pt]
	% 第2行,第1列 (m大括号那一行)
	\begin{array}{cc}
	\underbrace{\rule{17mm}{0mm}}_m &
	\underbracef{\rule{17mm}{0mm}}_m
	\end{array}
	& %第2行第2
	\end{array}
	\]
	
\end{document}

image.png

image.png

image.png

image.png

image.png

image.png

image.png

排版多行公式

\documentclass{article}
\usepackage{ctex}
\usepackage{amsmath}
% equation*和matrix需要使用这个包
\usepackage{amssymb}
% \mathbb{}需要该包

\begin{document}
	**\begin{gather}**
	a + b = b + a \\
	ab ba
	**\end{gather}**
	
	% 用gather*,或在\\之前用\notag生成无编号公式
	**\begin{gather*}
	3** + 5 = 5 + 3 = 8 \\
	3 \times 5 = 5 \times 3
	% 用gather*或\notag可以生成无编号公式
	**\end{gather*}
	
	\begin{gather}
	3^2** + 4^2 = 5^2 \notag \\
	5**^2** + 12^2 = 3^2 \notag \\
	a**^2** + b^2 = c^2
	**\end{gather}**
	
	
	% align与align*(用&进行对齐)
	\begin{align}
		x &= t + \cos t + 1 \\
    y &= 2\sin t
  \end{align}
  \begin{align*}
		x &= t & x &= \cos t & x &= t \\
    y &= 2t & y &= \sin (t+1) & y &= \sin t
  \end{align*}
	
	% split实现一个公式的多行排版(对齐采用align环境的方式,编号在中间)
	\begin{equation}
	\begin{split}
		\cos 2x &= \cos^2 x - \sin^2 x \\
    &= 2\cos^2 x -1
  \end{split}
  \end{equation}
	% 以上是由equation排版的一个公式,所以只有一个编号,且编号上下居中
	
	% cases环境
	% 每行公式中使用&分割为两部分
	% 通常表示值和后面的条件
	\begin{equation}
	D(x) = \begin{cases}
	1, & \text{如果 } x \in \mathbb{Q}; \\
	0, & \text{如果 } x \in
	\mathbb{R}\setminus\mathbb{Q}
	\end{cases}
	\end{equation}
	% in表示属于;matbb花体字符,需要amssymb宏包支持
	% 切换文本需要用\text{}

\end{document}