數(shù)學(xué)公式基礎(chǔ)
導(dǎo)言區(qū)(引包)
\usepackage{amsmath} %帶星號的eqution
正文區(qū)
\begin{document}
%數(shù)學(xué)公式初步
\section{簡介}
\LaTeX{}將排版內(nèi)容分為文本模式和數(shù)學(xué)模式。文本模式用于普通文本排版,數(shù)學(xué)模式用于數(shù)學(xué)公式排版。
\section{行內(nèi)公式} %有三種方式可以寫行內(nèi)公式
\subsection{美元符號}
交換律是 $a+b = b+a$,如$1+2=2+1=3$。
\subsection{小括號}
交換律是 \(a+b = b+a\),如\(1+2=2+1=3\)。
\subsection{math環(huán)境}
交換律是 \begin{math}a+b = b+a\end{math},如\begin{math}1+2=2+1=3\end{math}。
\section{上下標(biāo)}
\subsection{上標(biāo)}
$3x^{20}-x+2 = 0$ %大括號最好都加上,無論是一位數(shù)字還是多位數(shù)字
$3x^{3x^{20}-x+2}-x+2=0$ %也可以用已有的公式做上標(biāo)處理不過要加大括號
\subsection{下標(biāo)}
$a_0,a_1,a_2$
$a_0,a_1,a_2,...,a_{100},a_{3x^{20}-x+2}$ %同理,超過一個數(shù)字也要加大括號,也可以代入公式
\section{希臘字母}
$\alpha$ \quad $\beta$ \quad$\gamma$ \quad$\epsilon$ \quad$\pi$ \quad$\omega$ \quad$\Gamma$ \quad$\Delta$ \quad$\Pi$ \quad$\Omega$ \quad %大寫字母開始的希臘字母用于排版大寫的希臘字母
$\alpha^3+\beta^2+\gamma=0$ %希臘字母也可以用在通用公式中
\section{數(shù)學(xué)函數(shù)}
$\log$ \quad $\sin$ \quad$\cos$ \quad$\arcsin$ \quad$\arccos$ \quad$\ln$
$\sin^2 x + \cos^2 x = 1$ %構(gòu)成公式
$y = \sin^{-1} x$ \quad $y = \log_2 x$ \quad $y = \ln x$
$\sqrt{2}$ \quad $\sqrt{x^2+y^2}$ \quad $\sqrt{2+\sqrt{2}}$ \quad $\sqrt[4]{x}$ \quad %用于排版公式,"[]"用于指定開方次數(shù)
\section{分式} %兩種方式
大約是原體積的$3/4$。
大約是原體積的$\frac{3}{4}$。%第一個{}是分子,第二個是分母。
$\frac{x}{x^2+x+1}$ %復(fù)雜公式
$\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環(huán)境}
交換律是
\begin{displaymath}
a+b=b+a,
\end{displaymath}
如
\begin{displaymath}
1+2=2+1=3.
\end{displaymath}
\subsection{自動編號公式equation環(huán)境}
交換律公式見式\ref{eq:commutative}
\begin{equation}
a+b=b+a \label{eq:commutative}
\end{equation}
\subsection{不編號公式equation*環(huán)境}
交換律公式見式\ref{eq:commutative2} %此時的編號為小節(jié)編號
\begin{equation*} %帶星號的quation需要引入宏包:“\usepackage{amsmath}”
a+b=b+a \label{eq:commutative2}
\end{equation*}
公式的編號與交叉引用也是自動實現(xiàn)的,大家在排版中要習(xí)慣采用自動化的方式處理諸如圖、表、公式的編號與交叉引用。再如公式\ref{eq:pol}:
\begin{equation}
x^5-7x^3+4x = 0 \label{eq:pol}
\end{equation}
\end{document}
?
矩陣:
導(dǎo)言區(qū):(自命令)
\newcommand{\adots}{\mathinner{\mkern2mu%
\raisebox{0.1em}{.}\mkern2mu\raisebox{0.4em}{.}%
\mkern2mu\raisebox{0.7em}{.}\mkern1mu}} %adots執(zhí)行后面大括號的內(nèi)容。用不同的方式排版不同的句號
正文區(qū):
\begin{document}
%矩陣
%在latex中使用matrix環(huán)境實現(xiàn)矩陣排版,需要引入amsmath宏包
\[
\begin{matrix} %使用矩陣排版的matrix和使用表格排版的tabular非常相似
0 & 1 \\ %用&分割列,用\\分割行
1 & 0
\end{matrix} \quad
%pmatrix環(huán)境(矩陣兩端加小括號)
\begin{pmatrix}
0 & -i \\
i & 0
\end{pmatrix} \quad
\begin{bmatrix} %加中括號
0 & -1 \\
1 & 0
\end{bmatrix} \quad
\begin{Bmatrix} %加大括號
1 & 0 \\
0 & -1
\end{Bmatrix} \quad
\begin{vmatrix} %加單豎線
a & b \\
c & d
\end{vmatrix} \quad
\begin{Vmatrix} %加雙豎線
i & 0 \\
0 & -i
\end{Vmatrix} \quad
\]
\[
A = \begin{pmatrix}
a_{11}^2 & a_{12}^2 &a_{13}^2 \\ %上下標(biāo)在矩陣中的使用
0 & a_{22} & a_{23} \\
0 & 0 & a_{33}
\end{pmatrix}
\]
\[
B = \begin{bmatrix} %矩陣中常用的省略號(橫豎斜)
a_{11} & \dots & a_{1n} \\
\adots & \ddots & \vdots \\ %adots是自己定義出來的。當(dāng)然往左斜這個省略號也可以直接用命令“\iddots”實現(xiàn),不過需要導(dǎo)包mathdots,具體內(nèi)容可見往期回顧的第一篇內(nèi)容。
0 & & a_{nn}
\end{bmatrix}_{n \times n} %times排版乘號
\]
%利用矩陣的嵌套還可以實現(xiàn)分塊矩陣 ↓↓↓
\[
\begin{pmatrix}
\begin{matrix} 1 & 0 \\ 0 & 1\end{matrix}
& \text{\Large 0} \\ %"\text{\Large 0}"表示臨時切換到文本模式
{\Large 0} & \begin{matrix}1 & 0 \\ 0 & -1 \end{matrix} %不加text輸出的0是不一樣的
\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} %"\multicolumn":合并多列;"\raisebox":調(diào)整高度
\end{pmatrix}
\]
%產(chǎn)生跨列的省略號:\hdotsfor{<列數(shù)>}
\[
\begin{pmatrix}
1 & \frac 12 & \dots & \frac 1n \\
\hdotsfor{4} \\
m & \frac m2 & \dots & \frac mn
\end{pmatrix}
\]
%行內(nèi)小矩陣(smallmatrix)環(huán)境
復(fù)數(shù) $z=(x,y)$ 也可用矩陣
\begin{math}
\left( %math環(huán)境下的括號手動加,也可以改成中括號等
\begin{smallmatrix}
x & -y \\ y & x
\end{smallmatrix}
\right)
\end{math}來表示。%“\left”"\right"命令成對出現(xiàn)
?
%array環(huán)境(類似于表格環(huán)境tabular)
\[
%第一行第1列
\begin{array}{r|r}
\frac12 & 0 \\
\hline
0 & -\frac abc \\ %frac命令,后面直接跟數(shù)字表示分子分母,多位數(shù)需要加花括號,frac后面不能直接跟字母,會報錯,這些細(xì)節(jié)要注意。必要時用花括號進行分組,比如這里的c既不屬于分母也不屬于分子。
\end{array}
\]
?
%利用array環(huán)境構(gòu)造復(fù)雜矩陣
\[
\begin{array}{c@{\hspace{-5pt}}l} %@{<內(nèi)容>}:添加任意內(nèi)容,不占表項計數(shù);向左移-5pt的距離
\left(
\begin{array}{ccc|ccc}
a & \cdots & 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)
&
%第一行第2列
\begin{array}{l}
\left.\rule{0mm}{7mm}\right\}p \\ %"\left."表示與"\right\"配對,\left.什么都不輸出
\\
\left.\rule{0mm}{7mm}\right\}q
\end{array}
\\[-5pt]
%第二行第一列
\begin{array}{cc}
\underbrace{\rule{17mm}{0mm}}_m & %產(chǎn)生下面的橫向大括號,rule指定尺寸
\underbrace{\rule{17mm}{0mm}}_m
\end{array}
& %第二行第二列
\end{array}
\]
\end{document}
多行公式
導(dǎo)言區(qū)(導(dǎo)包):
\usepackage{amsmath} %帶星號的eqution
\usepackage{amssymb}
正文區(qū)文章來源:http://www.zghlxwxcb.cn/news/detail-758768.html
\begin{document}
%多行公式
%gather環(huán)境
\begin{gather} %實現(xiàn)對公示的分行排列及編號
a + b = b + a \\
ab ba
\end{gather}
?
\begin{gather*} %不帶編號
3 + 5 = 5 + 3 = 8 \\
3 \times 5 = 5 \times 3
\end{gather*}
?
\begin{gather}
3^2+4^2=5^2 \notag \\ %在gather環(huán)境中,也可以使用\notag阻止編號(“\\”前使用)
5^2+12^2=13^2 \notag \\
a^2+b^2=c^2
\end{gather}
%align環(huán)境(用&進行對齊)
\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環(huán)境(用&對齊,跟align一樣,編號在中間位置)
\begin{equation}
\begin{split}
\cos 2x &= \cos^2 x -\sin^2 x \\
&= 2\cos^2 x-1
\end{split}
\end{equation}
%case環(huán)境(每行公式中使用&分隔兩部分,通常表示值和后面的條件)【分段公式】
\begin{equation}
D(x) = \begin{cases}
1,&\text{如果 } x\in \mathbb{Q};\\ %"\in"命令表示輸出“∈”符號;“\text”命令表示臨時切換到文本模式,若果不使用該命令,則在數(shù)學(xué)排版公式中無法實現(xiàn)中文排版。
0,&\text{如果 } x\in \mathbb{R}\setminus\mathbb{Q}. %“mathbb”表示輸出花體字符,需要導(dǎo)包:“\usepackage{amssymb}”;“\setminus”:除號
\end{cases}
\end{equation}
\end{document}
文章來源地址http://www.zghlxwxcb.cn/news/detail-758768.html
到了這里,關(guān)于玩轉(zhuǎn)LaTeX(三)【數(shù)學(xué)公式(基礎(chǔ))、?矩陣、多行公式】的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!