16LaTeX學習系列之---LaTeX數學公式的補充
目錄
- 目錄
- 前言
- (一)知識點說明
- 1.基礎細節
- 2.gather環境
- 3.align環境
- 4.split環境
- 5.cases環境
- (二)實例
- 1.源代碼
- 2.輸出效果
目錄
本系列是有關LaTeX的學習系列,共計19篇,本章節是第16篇。
前一篇:15LaTeX學習系列之---LaTeX裏插入數學公式
後一篇:17LaTeX學習系列之---LaTeX的版面設計總目錄:19LaTeX學習系列之---LaTeX的總結
前言
前一節我們學習了怎麽在LaTeX中插入數學公式,本小節,我們補充在LaTeX中長公式的使用。
(一)知識點說明
1.基礎細節
- ** 號問題:在環境中有星號則無編號,無星號有編號。
- \ ?:換行
- \ref{fig:01}引用標簽,\label{fig:01}添加標簽,實現交叉引用
- \text{文字}:在數學模式中輸入文字
2.gather環境
用途:可以寫多行公式,對齊方式是整體中間對齊
(1)帶編號的
%多行公式--帶編號 \begin{gather} a + b +c = b + a \ 1+2 = 2 + 1 \end{gather}
\[ %多行公式--帶編號 \begin{gather} a + b +c = b + a \ 1+2 = 2 + 1 \end{gather} \]
(2)不帶編號
(下面的是否帶編號類似)
%多行公式--不帶編號1
\begin{gather*}
a + b = b + a \ 1+2 = 2 + 1
\end{gather*}
\[ %多行公式--不帶編號1 \begin{gather*} a + b = b + a \ 1+2 = 2 + 1 \end{gather*} \]
(3)阻止編號
%多行公式--帶編號2 \notag 阻止編號
\begin{gather}
a + b = b + a \notag \ 1+2 = 2 + 1 \notag
\end{gather}
\[ %多行公式--帶編號2 \notag 阻止編號 \begin{gather} a + b = b + a \notag \ 1+2 = 2 + 1 \notag \end{gather} \]
3.align環境
按&號對齊,自己指定對齊方式
% 按&號對齊,--帶編號
\begin{align}
a+b &= b+a \ 1+2= & 2+1
\end{align}
\[ % 按&號對齊,--帶編號 \begin{align} a+b &= b+a \ 1+2= & 2+1 \end{align} \]
4.split環境
當一個公式需要多行排版時,對齊方式也是按&對齊
%一個公式的多行排版--帶編號
\begin{equation}
\begin{split}
\cos 2x &= \cos^2 x - \sin^2x \ &=2\cos^2x-1
\end{split}
\end{equation}
\[ %一個公式的多行排版--帶編號 \begin{equation} \begin{split} \cos 2x &= \cos^2 x - \sin^2x \ &=2\cos^2x-1 \end{split} \end{equation} \]
5.cases環境
分段函數或者有左大括號的數學公式
%case環境, text{}在數學模式中處理中文-帶編號
\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}
\[ %case環境, text{}在數學模式中處理中文-帶編號 \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} \]
(二)實例
1.源代碼
%導言區
\documentclass{ctexart}
%導入宏包
\usepackage{amsmath}
\usepackage{amssymb}
%正文區
\begin{document}
%多行公式--帶編號
\begin{gather}
a + b +c = b + a \ 1+2 = 2 + 1
\end{gather}
%多行公式--不帶編號1
\begin{gather*}
a + b = b + a \ 1+2 = 2 + 1
\end{gather*}
%多行公式--帶編號2 \notag 阻止編號
\begin{gather}
a + b = b + a \notag \ 1+2 = 2 + 1 \notag
\end{gather}
% 按&號對齊,--帶編號
\begin{align}
a+b &= b+a \ 1+2= & 2+1
\end{align}
% 按&號對齊,--不帶編號
\begin{align*}
a+b &= b+a \ 1+2 &=2+1
\end{align*}
%一個公式的多行排版--帶編號
\begin{equation}
\begin{split}
\cos 2x &= \cos^2 x - \sin^2x \ &=2\cos^2x-1
\end{split}
\end{equation}
%一個公式的多行排版--不帶編號
\begin{equation*}
\begin{split}
\cos 2x &= \cos^2 x - \sin^2x \ &=2\cos^2x-1
\end{split}
\end{equation*}
%case環境, text{}在數學模式中處理中文-帶編號
\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}
%case環境, text{}在數學模式中處理中文-不帶編號
\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}
2.輸出效果
本系列是有關LaTeX的學習系列,共計19篇,本章節是第16篇。
前一篇:15LaTeX學習系列之---LaTeX裏插入數學公式
後一篇:17LaTeX學習系列之---LaTeX的版面設計
總目錄:19LaTeX學習系列之---LaTeX的總結
作者:Mark
日期:2019/03/06 周三
16LaTeX學習系列之---LaTeX數學公式的補充