公式的使用

【上課的筆記內容,用來分享與檢視】

1 行內和行間公式

行內公式:

$。。。$

行間公式:

$$。。。$$

\[\。。。\]

以及以下格式:

\begin

{

equation

}

。。。

\end

{

equation

}

%

會自動編號

2 編號

2。1 自動編號:

\begin

{

equation

}

。。。

\end

{

equation

}

2。2 標籤:\tag

\begin

{

equation

}

\tag

{

。。。

}

eq。

\end

{

equation

}

%例如:

\begin

{

equation

}

\tag

{

*

}

eq。

\end

{

equation

}

2。3 修改編號

一般是以章節為基礎編號,例如(1。1),(1。2)現在修改,需要在導言區進行修改:

\numberwithin

{

equation

}{

section

}

%

對公式以節

{

section

}

為基礎進行編號。變成(1。1。1)

2。4 子編號

並列公式:

\begin

{

subequations

}

\begin

{

equation

}

\tag

{

。。。

}

。。。

%(eq。a)

\end

{

equation

}

\begin

{

equation

}

\tag

{

。。。

}

。。。

%(eq。b)

\end

{

equation

}

\end

{

subequations

}

3 幾個宏包的介紹

amsmath宏包:在導言區使用amsmath宏包。

3。1 字型宏包:

mathrsfs和amsfonts宏包

bm宏包:字型加粗

\usepackage

{

amsmath

}

\usepackage

{

amsfonts

}

\usepackage

{

bm

}

%加粗

\usepackage

{

mathrsfs

}

mathrsfs和amsfonts宏包

\mathscr

\mathcal

\mathbb

$$\mathbb{D}$$

\mathf

LaTeX基本公式使用學習

bm宏包

字型加粗:

$$\bm{}$$

另一種字型加粗的形式:

\mathbf{}

與bm有區別,區別如下:

LaTeX基本公式使用學習

4 公式的環境

4。1 矩陣環境:

array,matrix ,Bmatrix,bmatrix,pmatrix,vmatrix,Vmatrix

array:

\begin

{

equation

}{

ccc

}

%C中間對齊。L左對齊, R右對齊

\left

\bagin

{

array

}

1

&

2

&

3

\\

4

&

5

&

6

\\

7

&

8

&

9

\\

\end

{

array

}

\right

%加括號

\end

{

equation

}

LaTeX基本公式使用學習

array

matrix:

預設中間對齊

\begin

{

equation

}{

ccc

}

%C中間對齊。L左對齊, R右對齊

\left

\bagin

{

matrix

}

1

&

2

&

3

\\

4

&

5

&

6

\\

7

&

8

&

9

\\

\end

{

matrix

}

\right

%加括號

\end

{

equation

}

LaTeX基本公式使用學習

matrix

bmatrix:

生成帶有中括號的矩陣

\begin

{

equation

}

\bagin

{

bmatrix

}

1

&

2

&

3

\\

4

&

5

&

6

\\

7

&

8

&

9

\\

\end

{

bmatrix

}

\end

{

equation

}

LaTeX基本公式使用學習

bmatrix

Bmatrix:

生成帶有大括號的矩陣

\begin

{

equation

}

\bagin

{

Bmatrix

}

1

&

2

&

3

\\

4

&

5

&

6

\\

7

&

8

&

9

\\

\end

{

Bmatrix

}

\end

{

equation

}

LaTeX基本公式使用學習

Bmatrix

pmatrix:

生成帶有小括號的矩陣

\begin

{

equation

}

\bagin

{

pmatrix

}

1

&

2

&

3

\\

4

&

5

&

6

\\

7

&

8

&

9

\\

\end

{

pmatrix

}

\end

{

equation

}

LaTeX基本公式使用學習

pmatrix

vmatrix:

\begin

{

equation

}

\bagin

{

vmatrix

}

1

&

2

&

3

\\

4

&

5

&

6

\\

7

&

8

&

9

\\

\end

{

vmatrix

}

\end

{

equation

}

LaTeX基本公式使用學習

vmatrix

Vmatrix

\begin

{

equation

}

\bagin

{

Vmatrix

}

1

&

2

&

3

\\

4

&

5

&

6

\\

7

&

8

&

9

\\

\end

{

Vmatrix

}

\end

{

equation

}

LaTeX基本公式使用學習

Vmatrix

5 分段函式環境: cases

$$

I_{A}

x

)=

\begin

{cases}

1

,&x

\in

A

\\

% &之後表示條件

0

,&x

\notin

A

\end

{cases}

$$

LaTeX基本公式使用學習

利用矩陣的形式來重現以上操作:

$$

I_{A}

x

)=

\{\begin

{matrix}

%會少{,加一個\{

1

,&x

\in

A

\\

%之後表示條件

0

,&x

\notin

A

\end

{matrix}

$$

\[

I_{A}

x

)=

\left\{\begin

{matrix}

1

,&x

\in

A

\\

%之後表示條件

0

,&x

\notin

A

\end

{matrix}

\right

\]

6 公式對齊環境

split,align,eqnarray,gathered

公式特別長,超過排版頁面。

$$

a

+

b

^

4

=(

a

+

b

^

2

a

+

b

^

2

=(

a^

2

+

2

ab

+

b^

2

$$

split環境來分割公式:

\[

\begin

{split}

a

+

b

^

4

&

=(

a

+

b

^

2

a

+

b

^

2

\\

% \:分行

&

=(

a^

2

+

2

ab

+

b^

2

)(

a^

2

+

2

ab

+

b^

2

\\

% &:用於等號對齊

&

=

a^

4

+

4

a^

3

b

+

6

a^

2

b^

2

+

4

ab^

3

+

b^

4

\end

{split}

\]

$$ \begin{split} (a+b)^4&=(a+b)^2(a+b)^2\ &=(a^2+2ab+b^2)(a^2+2ab+b^2)\ &=a^4+4a^3b+6a^2b^2+4ab^3+b^4 \end{split} $$

\begin

{

equation

}

\begin

{

split

}

(a+b)

^

4

&

=(a+b)

^

2(a+b)

^

2

\\

% \:分行

&

=(a

^

2+2ab+b

^

2)(a

^

2+2ab+b

^

2)

\\

% &:用於等號對齊

&

=a

^

4+4a

^

3b+6a

^

2b

^

2+4ab

^

3+b

^

4

\end

{

split

}

\end

{

equation

}

LaTeX基本公式使用學習

只有一個編號。

align環境分割

不需要公式環境

$。。。$

\begin{equation}

\begin

{

align

}

(a+b)

^

4

&

=(a+b)

^

2(a+b)

^

2

\\

% \:分行

&

=(a

^

2+2ab+b

^

2)(a

^

2+2ab+b

^

2)

\\

% &:用於等號對齊

&

=a

^

4+4a

^

3b+6a

^

2b

^

2+4ab

^

3+b

^

4

\end

{

align

}

每一行都有編號

LaTeX基本公式使用學習

刪除第一行的編號(刪除編號的那行末尾用

\nonumber

\begin

{

align

}

(a+b)

^

4

&

=(a+b)

^

2(a+b)

^

2

\nonumber\\

% \:分行

&

=(a

^

2+2ab+b

^

2)(a

^

2+2ab+b

^

2)

\\

% &:用於等號對齊

&

=a

^

4+4a

^

3b+6a

^

2b

^

2+4ab

^

3+b

^

4

\end

{

align

}

eqnarray環境

類似於align環境,將公式以矩陣的方式進行,每次都是以居中的格式對齊。

\begin

{

eqnarray

}

(a+b)

^

4

&

=(a+b)

^

2(a+b)

^

2

\nonumber\\

% \:分行

&

=(a

^

2+2ab+b

^

2)(a

^

2+2ab+b

^

2)

\\

% &:用於等號對齊

&

=a

^

4+4a

^

3b+6a

^

2b

^

2+4ab

^

3+b

^

4

\end

{

eqnarray

}

LaTeX基本公式使用學習

可以對齊進行修改,變成以上align的形式,利用

&=&

的方法將其變成以下形式:

\begin

{

eqnarray

}

(a+b)

^

4

&

=

&

(a+b)

^

2(a+b)

^

2

\nonumber\\

% \:分行

&

=

&

(a

^

2+2ab+b

^

2)(a

^

2+2ab+b

^

2)

\\

% &:用於等號對齊

&

=

&

a

^

4+4a

^

3b+6a

^

2b

^

2+4ab

^

3+b

^

4

\end

{

eqnarray

}

LaTeX基本公式使用學習

(等號間隔會比align有點大)

gather環境

不需要任何對齊符號

&

(不需要公式環境,在Texstudio中直接可以給出結果,不需要

$。。。$

\begin

{

gather

}

(a+b)

^

4=(a+b)

^

2(a+b)

^

2

\\

% \:分行

=(a

^

2+2ab+b

^

2)(a

^

2+2ab+b

^

2)

\\

% &:用於等號對齊

=a

^

4+4a

^

3b+6a

^

2b

^

2+4ab

^

3+b

^

4

\end

{

gather

}

LaTeX基本公式使用學習

全部以中間對齊的格式呈現。

gathered環境

不需要任何對齊符號

&

(需要公式環境,不能在Texstudio中直接可以給出結果,需要

$。。。$

\[

\begin

{gathered}

a

+

b

^

4

=(

a

+

b

^

2

a

+

b

^

2

\\

% \:分行

=(

a^

2

+

2

ab

+

b^

2

)(

a^

2

+

2

ab

+

b^

2

\\

% &:用於等號對齊

=

a^

4

+

4

a^

3

b

+

6

a^

2

b^

2

+

4

ab^

3

+

b^

4

\end

{gathered}

\]

LaTeX基本公式使用學習

全部以中間對齊的格式呈現。

7 定理引理環境

一般使用以下幾個宏包:

amsthm宏包

ntheorem宏包

\usepackage

{

amsthm

}

%

\usepackage

{

ntheorem

}

使用這個會使

\maketitle

版式出問題警告

定理環境的設定

導言區進行設定

\newtheorem

{

thm

}{

定理

}

[chapter]

%中文顯示定理,這個題頭可以修改,定理以章為基礎

\newtheorem

{

defn

}{

定義

}

\newtheorem

{

lemma

}

[thm]

{

引理

}

%加入的thm,可以使得定理和引理的計數器一樣

\newtheorem

{

thm

}{

Theorem

}

[chapter]

%顯示Theorem,這個題頭可以修改,定理以章為基礎

\newtheorem

{

defn

}{

Definition

}

\newtheorem

{

lemma

}

[thm]

{

lemma

}

%

加入的thm,可以使得定理和引理的計數器一樣

導言區加上以下內容:

\usepackage

{

amsthm

}

%\usepackage{ntheorem}使用這個會使\maketitle版式出問題

\newtheorem

{

thm

}{

定理

}

[chapter]

%中文顯示定理,這個題頭可以修改,定理以章為基礎或者section等

\newtheorem

{

defn

}{

定義

}

%[]也可加入chapter section進行編號

\newtheorem

{

lemma

}

[thm]

{

引理

}

%

加入的thm,可以使得定理和引理的計數器一樣

例子:

\section

{

定理環境

}

\subsection

{

定理

}

\begin

{

thm

}

This is a theorem。

\end

{

thm

}

\begin

{

thm

}

This is also a theorem。

\end

{

thm

}

\subsection

{

引理

}

\begin

{

lemma

}

This is a lemma。

\end

{

lemma

}

\begin

{

lemma

}

This is also a lemma。

\end

{

lemma

}

\subsection

{

定義

}

\begin

{

defn

}

This is a definition。

\end

{

defn

}

\begin

{

defn

}

This is also a definition。

\end

{

defn

}

LaTeX基本公式使用學習

對定理或引理進行說明:

\begin

{

lemma

}

[NEWTON]

%在後面加[]

This is a lemma。

\end

{

lemma

}

以上的設定中,定理、定義以及引理的字型均一致,下面進行修改字型:

修改字型

修改定理、引理以及定義的格式:

\theoremstyle

{

plain

}

%latex預設的版式

\theoremstyle

{

definition

}

%

\theoremstyle

{

remark

}

%

例子:

\theoremstyle

{

plain

}

%定理用latex預設的版式

\newtheorem

{

thm

}{

Theorem

}

[section]

\theoremstyle

{

definition

}

%定義用definition格式

\newtheorem

{

defn

}{

Definition

}

\theoremstyle

{

remark

}

%引言用remark格式

\newtheorem

{

lemma

}

[thm]

{

lemma

}

LaTeX基本公式使用學習

8 證明環境

amsthm

環境中。

proof環境

證明結尾符號

\qed

\qedhere

:方框□

\usepackage

{

amsthm

}

\subsection

{

證明

}

\begin

{

proof

}

This is a proof

\end

{

proof

}

%

\qed

LaTeX基本公式使用學習

後面的方框□代表證明結束

出現以下情況時:英文的proof,要改為中文的

證明

LaTeX基本公式使用學習

在導言區加入以下內容即可:

\renewcommand

{

\proofname

}{

證明

}

%

對已有的命令進行修改,將

\proofname

修改成證明