Latex 笔记

公式使用

多行公式

  1. 多个公式换行,有左大括号,整体编号

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    
    \usepackage{amsmath}
    \begin{document}
    
    \begin{equation}
        \left\{
        \begin{aligned}
            A=1 \\
            B=2 \\
            C=3 \\
            D=4
        \end{aligned}
        \right.\label{eq1}
    \end{equation}
    \end{document}

    20220325153624

  2. 多个公式换行,有左大括号,并且每行公式都有子编号

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    
    \usepackage{amsmath}
    \usepackage{cases}
    \begin{document}
    
    \begin{subnumcases}
        {}
        A=1 \\
        B=2 \\
        C=3 \\
        D=4
    \end{subnumcases}\label{eq1}
    \end{document}

    20220326183121

  3. 多个公式换行,有左大括号,并且每行公式都有独立编号

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    \usepackage{amsmath}
    \usepackage{cases}
    \begin{document}
    
    \begin{numcases}
    {}
    x_1 = eq1 \label{eq1} \\
    x_2 = eq2 \label{eq2}
    \end{numcases}
    \end{document}

    20220326183214

  4. 多行公式,不加左大括号,独立编号

    1
    2
    3
    4
    5
    6
    7
    8
    
    \usepackage{amsmath}
    
    \begin{document}
    \begin{align}
    x&=eq1 \label{eq1} \\
    y&=eq2 \label{eq2}
    \end{align}
    \end{document}

    20220325154401

  5. 多行公式,加左大括号,不编号

    1
    2
    3
    4
    5
    6
    7
    8
    
    \usepackage{amsmath}
    
    \begin{document}
    \[\begin{cases}
    x = eq1 \\
    y = eq2
    \end{cases}\]
    \end{document}

    20220325154537

无序列表

默认的小圆点

1
2
3
4
5
\begin{itemize}
    \item one
    \item two
    \item ...
\end{itemize}

自定义项目符号

例如使用星号 *

1
2
3
4
5
\begin{itemize}[label={*}]
    \item one
    \item two
    \item ...
\end{itemize}

或者如下(效果相同,但不够优雅):

1
2
3
4
5
\begin{itemize}[label={*}]
    \item[*] one
    \item[*] two
    \item[*] ...
\end{itemize}

有序列表

默认为 1. 2. 3.

1
2
3
4
5
\begin{enumerate}
    \item one
    \item two
    \item ...
\end{enumerate}

自定义编号样式

例如使用中文括号括起来的阿拉伯数字(1)(2)(3)

1
2
3
4
5
\begin{enumerate}[label={\arabic*}]
    \item one
    \item two
    \item ...
\end{enumerate}

使用英文半括号括起来的阿拉伯数字1) 2) 3)

1
2
3
4
5
\begin{enumerate}[label={\arabic*)}]
    \item one
    \item two
    \item ...
\end{enumerate}

使用小写罗马数字:

1
2
3
4
5
\begin{enumerate}[label={\roman*}]
    \item one
    \item two
    \item ...
\end{enumerate}

此外,还可以将 \roman 换成 \Roman\Alph\alph,分别使用大写罗马数字、大写英文字母、小写英文字母。

效果展示

无序列表

有序列表 1

有序列表 2

本部分 latex 代码

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
\documentclass[UTF8]{ctexart}
\usepackage{enumitem}
\begin{document}

\subsection*{无序列表}

\subsubsection*{默认的小圆点}

\begin{itemize}
    \item one
    \item two
    \item ...
\end{itemize}

\subsubsection*{自定义项目符号}

例如使用星号:

\begin{itemize}[label={*}]
    \item one
    \item two
    \item ...
\end{itemize}

或者如下(效果相同,但不够优雅):

\begin{itemize}[label={*}]
    \item[*] one
    \item[*] two
    \item[*] ...
\end{itemize}

\subsubsection*{有序列表}

\subsubsection*{默认为 1. 2. 3.}

\begin{enumerate}
    \item one
    \item two
    \item ...
\end{enumerate}

\subsubsection*{自定义编号样式}

例如使用中文括号括起来的阿拉伯数字:

\begin{enumerate}[label={\arabic*}]
    \item one
    \item two
    \item ...
\end{enumerate}

使用英文半括号括起来的阿拉伯数字:

\begin{enumerate}[label={\arabic*)}]
    \item one
    \item two
    \item ...
\end{enumerate}

使用小写罗马数字:

\begin{enumerate}[label={\roman*.}]
    \item one
    \item two
    \item ...
\end{enumerate}

此外,还可以将 \texttt{\textbackslash roman} 换成 \texttt{\textbackslash Roman}\texttt{\textbackslash Alph}\texttt{\textbackslash alph},分别使用大写罗马数字、大写英文字母、小写英文字母。

例如使用大写字母:

\begin{enumerate}[label={\Alph*.}]
    \item one
    \item two
    \item ...
\end{enumerate}

\end{document}

使用 Latexindent 格式化 Latex 代码

VSCode

在设置 json 中添加以下内容,路径换为 TEX-Live 安装路径下 latexindent 的位置。

1
2
3
{
"latex-workshop.latexindent.path": "C:/Users/Chris/scoop/apps/texlive-full/2021/bin/win32/latexindent.exe"
}

或者环境变量配置正确的话,使用 latexindent 也可行。

1
2
3
{
"latex-workshop.latexindent.path": "latexindent"
}

TeXstudio

TeXStudio > 选项 > 设置 TeXstudio > 构建 > 用户命令中添加一条新的命令:"C: \Users\Chris\scoop\apps\texlive-full\2021\bin\win32\latexindent.exe" -w -s %.tex,路径需要换成 latexindent.exe 的路径。 如果不需要格式化时自动生成备份文件,可以使用 -s -o %.tex" %.tex",如果还要应用于除了 .tex 之外的扩展名 ( 例如 .bib ) ,使用 -s -o ?c:me" ?c:me"。详见 TeXstudio 官方文档

20220326183317

设置好之后,在工具 > 用户中就可以找到该命令。

0%