%导言区
\documentclass{ctexart}%book report letter article
\title{My First,Document}
\author{\kaishu 张三}
\date{\today}
\usepackage{amsmath}
\usepackage{amssymb}%罗马数字的宏包
%\usepackage{ctex}
\newcommand\degree{^\circ}
\begin{document}
Hello World!%空行表示回车
Let $f(x)$ be defined by the formula $$f(x) = 3x^2+x-1$$.%$$表示公式换行
\begin{equation} %带标号的行间公式
AB^2 = BC^2+AC^2.
\end{equation}
%字体族设置(罗马字体、无衬线字体、打字机字体0
\textrm{Roman Family}
\rmfamily Roman Family
\sffamily Sans Serif Family
\ttfamily Typewriter Family %使用大括号限定字体范围
% 字体系列设置(粗细、宽度)
\textmd{Medium Series} \textbf{Boldface Series}
%字体形状(直立、斜体、仿斜体、小型大写)
\textup{Upright Shape} {\itshape Italic Shape}{\slshape}
\subsection{displaymath 环境}%用于输出行间公式
交换律是
\begin{displaymath}
a+b = b+a
\end{displaymath}
\subsection{自动编号公式equation}%编号并且可以用于引用,\ref与前文之间不能有空格
交换律见式\ref{eq:commutative}
\begin{equation}
a^2 + b^2 = b^2 + a^2 \label{eq:commutative}
\end{equation}
\subsection{不编号公式但是进行引用}%这时引用的是小节编号
新的公式见\ref{eq:commutative1}节
\begin{equation*}%使用equation*要使用环境变量\usepackage{amsmath}
a1+b1 = b1+a1\label{eq:commutative1}
\end{equation*}
\begin{align}
2x + 3y &= 7\\
5x - 2y &= 2
\end{align}
\subsection{希腊字母}
$$\alpha$$%两个美元是居中对齐,一个美元是行内公式
$\beta$
$\gamma$
$\epsilon$
$\pi$
$\omega$
$\cos^2x+sin^2x = 1$
%$\Alpha$%{amsmath}大写希腊字母还是没打出来
%$\Beta$
% $\Gamma$
% %$\Epsilon$
% $\Pi$
% $\Omega$
\[1+2=2+1=3\]
\[%矩阵环境的开始结束都要写上\[\],用&分割列,用\\分割行
\begin{matrix}
0&1\\
2&3
\end{matrix}
\]
\[
\begin{pmatrix}%小括号
0&1\\
2&3
\end{pmatrix}
\]
\[
\begin{bmatrix}%中括号
0&1\\
2&3
\end{bmatrix}
\]
\[
\begin{Bmatrix}%大括号
0&1\\
2&3
\end{Bmatrix}
\]
\[
\begin{vmatrix}%单竖线
0&1\\
2&3
\end{vmatrix}
\]
\[
\begin{Vmatrix}%双竖线
0&1\\
2&3
\end{Vmatrix}
\]
\[
\begin{matrix}
0&1\\
2&3
\end{matrix}\qquad %是空格的意思
\begin{pmatrix}%小括号
0&1\\
2&3
\end{pmatrix}
\]
\[
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 \ddots 实现
\[
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}
\]
%三角矩阵
\[\begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n}\\
& a_{22} & \cdots & a_{2n} \\
& &ddots & \vdots \\
\multicolumn{2}{c}{\raisebox{1.3ex}[0pt]{\Huge 0}}
& & a_{nn}
\end{pmatrix}
\]
%hdotsfor{<>}跨列省略号
\[
\begin{pmatrix}
1 & \frac 12 & \dots & \frac 1n \\
\hdotsfor{4}\\
m & \frac m2 & \dots & \frac mn
\end{pmatrix}
\]
%使用smallmatrix排版行内小矩阵
\begin{math}
\left(
\begin{smallmatrix}
x & -y \\ y & x
\end{smallmatrix}
\right)
\end{math}
\[
\begin{array}{r|r}
\frac12 & 0 \\
a & -\frac abc\\
\end{array}
\]
%多行公式的排版,gather 环境中好像不能使用&,空格使用\quad
\begin{gather}
a+b = b+a\\
ab \quad ba
\end{gather}
\begin{gather} %使用notag命令,使得在gather环境也不编号
3^2+4^2=5^2 \notag\\
5^2+12^2=13^2 \notag\\
5^2+12^2=13^2
\end{gather}
\begin{gather*}%不编号
a+b = b+a\\
ab ba
\end{gather*}
\begin{align}%align用于对齐
x&=t+\cos t+1 \\
y&=2\sin t
\end{align}
\begin{align*}
x&=t+\cos t+1 &x &=\cos t & x&=t\\
y&=2t &y &=\sin(t+1) &y&=\sin t
\end{align*}
%split环境(对齐采用align环境的方式,编号在中间)
\begin{equation}
\begin{split}
x&=t+\cos t+1 \\
x &=\cos t
\end{split}
\end{equation}
%cases 环境边界分段函数,mathbb用于输出花体字符
\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}
\end{document}
一般要包含宏包\usepackge{amamath} 和 \usepackage{amssymb},这些代码是按照b站上的视频教学写的,具体可以参考b站https://www.bilibili.com/video/BV15x411j7k6?p=12