> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/zh-cn/latex-ji-chu/04-lists.md).

# 列表

## 在 Overleaf 中插入列表的三种方式

Overleaf 提供了 3 种使用 LaTeX 创建列表的方法：

1. 使用 **插入项目符号列表** (![Image of the menu icon for insert a bulleted list in Overleaf](/files/76a7a163eb5d4be7c4ae5e9116e4ca7a34ee6608)）或 **插入编号列表** (![Image of the menu icon for insert a numbered list in Overleaf](/files/d912b359a54d95ee6914f889178d44df5f8af9a8)）在编辑器工具栏上可将列表插入到 **可视化编辑器** 或 **代码编辑器**.
2. [将格式化列表粘贴到 **可视化编辑器**](/latex/zh-cn/zhi-shi-ku/075-how-to-paste-formatted-content-into-overleaf.md#pasteformattedlist).
3. 使用 **代码编辑器**.

选项 1 和 2 旨在自动生成列表排版所需的 LaTeX 代码。不过，对于那些希望自己编写 LaTeX 代码的人来说，选项 3 可能是更合适的选择。它提供了最大的灵活性，也是本文的重点。

## 引言

本文介绍了在 LaTeX 中排版和自定义各种类型列表的入门内容：

* 该 `itemize` 用于创建带项目符号（无序）列表的环境
* 该 `enumerate` 用于创建编号（有序）列表的环境
* 该 `描述` 用于创建描述列表的环境

列表排版是一个很大的主题，因为 LaTeX 的列表是 *极其* 可配置的，这使得可以创建种类和结构极其丰富的列表。我们将概览并演示一些你可以用来 [配置和自定义列表的方法](#customizing-lists).

## 基本列表示例

### 用于项目符号（无序）列表的 itemize 环境

无序（项目符号）列表由 `itemize` 环境生成，其中每个列表条目都以 `\item` 命令开始，它也会生成项目符号。

```latex
列表很容易创建：
\begin{itemize}
  \item 列表项以 \verb|\item| 命令开始。
  \item 各个条目用黑点表示，即所谓的项目符号。
  \item 条目中的文本可以是任意长度。
\end{itemize}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+unordered+list+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0ALists+are+easy+to+create%3A%0A%5Cbegin%7Bitemize%7D%0A++%5Citem+List+entries+start+with+the+%5Cverb%7C%5Citem%7C+command.%0A++%5Citem+Individual+entries+are+indicated+with+a+black+dot%2C+a+so-called+bullet.%0A++%5Citem+The+text+in+the+entries+may+be+of+any+length.%0A%5Cend%7Bitemize%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![List1bOLV2.png](/files/6796cd78b730e8d8ef424f2969ec31a2dda4dea6)

### 用于编号（有序）列表的 enumerate 环境

编号（有序）列表具有相同的语法，但使用 `enumerate` 环境：每个条目前必须加上控制序列 `\item`，它会自动生成数字来标记条目。每次使用 `enumerate` 环境时，这种默认的 LaTeX 编号行为都可以通过 [`enumitem` 宏包](https://ctan.org/pkg/enumitem).

```latex
编号（有序）列表很容易创建：
\begin{enumerate}
  \item 项目会自动编号。
  \item 每次使用 \texttt{enumerate} 环境时，编号都从 1 开始。
  \item 列表中的另一个条目
\end{enumerate}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+ordered+list+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0ANumbered+%28ordered%29+lists+are+easy+to+create%3A%0A%5Cbegin%7Benumerate%7D%0A++%5Citem+Items+are+numbered+automatically.%0A++%5Citem+The+numbers+start+at+1+with+each+use+of+the+%5Ctexttt%7Benumerate%7D+environment.%0A++%5Citem+Another+entry+in+the+list%0A%5Cend%7Benumerate%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![List2OLV2.png](/files/43b4e961eb0bbda9ca2e27b72fb71645f70b29ac)

### description 环境

下面的示例演示了 `描述` 环境。每个条目的（可选）标签写在 `\item` 命令设置为特定值：

```latex
\item[label text] 你的描述文本写在这里...
```

我们还使用 `blindtext` 宏包在第三个条目中生成一些虚拟英文文本。要获得英文文本，我们需要使用 `babel` 宏包，并使用语言选项 `[english]`:

```latex
\usepackage[english]{babel}
```

示例如下：

```latex
\documentclass{article}
\usepackage[english]{babel} % 为了使用 blindtext 宏包获取英文文本
\usepackage{blindtext}
\begin{document}

\begin{description}
   \item 这是一个\textit{没有}标签的条目。
   \item[Something short] 一个简短的一行描述。
   \item[Something long] 一个长得多的描述。 \blindtext[1]
\end{description}
\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+description+list+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D+%25+To+obtain+English+text+with+the+blindtext+package%0A%5Cusepackage%7Bblindtext%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cbegin%7Bdescription%7D%0A+++%5Citem+This+is+an+entry+%5Ctextit%7Bwithout%7D+a+label.%0A+++%5Citem%5BSomething+short%5D+A+short+one-line+description.%0A+++%5Citem%5BSomething+long%5D+A+much+longer+description.+%5Cblindtext%5B1%5D%0A%5Cend%7Bdescription%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![Descriptionlist2.png](/files/ac91c417bf636b0829fb129ba214a50308147074)

## 更改单个条目的标签

如在 `描述` 环境示例中所示， `\item` 命令接受一个可选参数，写在方括号中。你可以在 `itemize` 和 `enumerate` 环境中使用此特性来更改列表中单个条目的默认标签：

```latex
\item[label text] 你的条目文本写在这里...
```

该 `标签文本` 将用于生成该条目的标签。

```latex
在 \texttt{itemize} 环境中使用 \verb|\item[label text]| 更改标签
\begin{itemize}
  \item 这是我的第一个要点
  \item 我想提出的另一个要点
  \item[!] 一个用来强调某事的要点！
  \item[$\blacksquare$] 让这个要点明明白白、正正当当。
  \item[NOTE] 这个条目没有项目符号
  \item[] 一个空白标签？
\end{itemize}

\vspace{10pt}

在 \texttt{enumerate} 环境中使用 \verb|\item[label text]| 更改标签
\begin{enumerate}
  \item 这是我的第一个要点
  \item 我想提出的另一个要点
  \item[!] 一个用来强调某事的要点！
  \item[$\blacksquare$] 让这个要点明明白白、正正当当。
  \item[NOTE] 这个条目没有项目符号
  \item[] 一个空白标签？
\end{enumerate}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Changing+list+labels\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamssymb%7D%25+to+access+%24%5Cblacksquare%24%0A%5Cbegin%7Bdocument%7D%0AChange+the+labels+using+%5Cverb%7C%5Citem%5Blabel+text%5D%7C+in+an+%5Ctexttt%7Bitemize%7D+environment%0A%5Cbegin%7Bitemize%7D%0A++%5Citem+This+is+my+first+point%0A++%5Citem+Another+point+I+want+to+make+%0A++%5Citem%5B%21%5D+A+point+to+exclaim+something%21%0A++%5Citem%5B%24%5Cblacksquare%24%5D+Make+the+point+fair+and+square.%0A++%5Citem%5BNOTE%5D+This+entry+has+no+bullet%0A++%5Citem%5B%5D+A+blank+label%3F%0A%5Cend%7Bitemize%7D%0A%0A%5Cvspace%7B10pt%7D%0A%0AChange+the+labels+using+%5Cverb%7C%5Citem%5Blabel+text%5D%7C+in+an+%5Ctexttt%7Benumerate%7D+environment%0A%5Cbegin%7Benumerate%7D%0A++%5Citem+This+is+my+first+point%0A++%5Citem+Another+point+I+want+to+make+%0A++%5Citem%5B%21%5D+A+point+to+exclaim+something%21%0A++%5Citem%5B%24%5Cblacksquare%24%5D+Make+the+point+fair+and+square.%0A++%5Citem%5BNOTE%5D+This+entry+has+no+bullet%0A++%5Citem%5B%5D+A+blank+label%3F%0A%5Cend%7Benumerate%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![ChangeBullets.png](/files/fe52fe17e40d4f37f4b2f1dd64e72212491d0441)

## 嵌套列表

在 LaTeX 中，你可以在一个列表中插入另一个列表。上面的列表类型可以相互嵌套，既可以混合嵌套，也可以同类嵌套，最多 4 层。

```latex
\begin{enumerate}
   \item 标签由连续编号组成
   \begin{itemize}
     \item 各个条目用黑点表示，即所谓的项目符号
     \item 条目中的文本可以是任意长度
     \begin{description}
     \item[Note:] 我想在这里描述一些内容
     \item[Caveat!] 并在这里给出一个警告
     \end{description}
   \end{itemize}
   \item 每次使用 \texttt{enumerate} 环境时，编号都从 1 开始
\end{enumerate}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+nested+list+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Benumerate%7D%0A+++%5Citem+The+labels+consists+of+sequential+numbers%0A+++%5Cbegin%7Bitemize%7D%0A+++++%5Citem+The+individual+entries+are+indicated+with+a+black+dot%2C+a+so-called+bullet%0A+++++%5Citem+The+text+in+the+entries+may+be+of+any+length%0A+++++%5Cbegin%7Bdescription%7D%0A+++++%5Citem%5BNote%3A%5D+I+would+like+to+describe+something+here%0A+++++%5Citem%5BCaveat%21%5D+And+give+a+warning+here%0A+++++%5Cend%7Bdescription%7D%0A+++%5Cend%7Bitemize%7D%0A+++%5Citem+The+numbers+starts+at+1+with+each+use+of+the+%5Ctexttt%7Benumerate%7D+environment%0A%5Cend%7Benumerate%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![List3bOLV2.png](/files/6affb1ce62b55f28572cc1d30cb944eadcc53e43)

### 嵌套列表：标签样式

嵌套列表条目的标签样式会随着在列表中的深度而变化。对于嵌套 `itemize` 列表，项目符号的类型会变化；对于 `enumerate` 列表，编号格式会随着嵌套深度增加而变化。两者都限制在 4 层深度以内。

#### 嵌套的 enumerate 列表：编号格式

```latex
\begin{enumerate}
   \item 第一层条目
   \item 第一层条目
   \begin{enumerate}
     \item 第二层条目
     \item 第二层条目
     \begin{enumerate}
       \item 第三层条目
       \item 第三层条目
       \begin{enumerate}
         \item 第四层条目
         \item 第四层条目
       \end{enumerate}
     \end{enumerate}
   \end{enumerate}
 \end{enumerate}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+nested+ordered+list+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Benumerate%7D%0A+++%5Citem+First+level+item%0A+++%5Citem+First+level+item%0A+++%5Cbegin%7Benumerate%7D%0A+++++%5Citem+Second+level+item%0A+++++%5Citem+Second+level+item%0A+++++%5Cbegin%7Benumerate%7D%0A+++++++%5Citem+Third+level+item%0A+++++++%5Citem+Third+level+item%0A+++++++%5Cbegin%7Benumerate%7D%0A+++++++++%5Citem+Fourth+level+item%0A+++++++++%5Citem+Fourth+level+item%0A+++++++%5Cend%7Benumerate%7D%0A+++++%5Cend%7Benumerate%7D%0A+++%5Cend%7Benumerate%7D%0A+%5Cend%7Benumerate%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![List4OLV2.png](/files/af6c7fc54629fadd92a16a776884f1e488d82305)

#### 嵌套的 itemize 列表：项目符号样式

项目符号样式会根据嵌套列表的深度而变化：

```latex
\begin{itemize}
   \item 第一层条目
   \item 第一层条目
   \begin{itemize}
     \item 第二层条目
     \item 第二层条目
     \begin{itemize}
       \item 第三层条目
       \item 第三层条目
       \begin{itemize}
         \item 第四层条目
         \item 第四层条目
       \end{itemize}
     \end{itemize}
   \end{itemize}
 \end{itemize}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Basic+nested+ordered+list+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bitemize%7D%0A+++%5Citem+First+level+item%0A+++%5Citem+First+level+item%0A+++%5Cbegin%7Bitemize%7D%0A+++++%5Citem+Second+level+item%0A+++++%5Citem+Second+level+item%0A+++++%5Cbegin%7Bitemize%7D%0A+++++++%5Citem+Third+level+item%0A+++++++%5Citem+Third+level+item%0A+++++++%5Cbegin%7Bitemize%7D%0A+++++++++%5Citem+Fourth+level+item%0A+++++++++%5Citem+Fourth+level+item%0A+++++++%5Cend%7Bitemize%7D%0A+++++%5Cend%7Bitemize%7D%0A+++%5Cend%7Bitemize%7D%0A+%5Cend%7Bitemize%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![List5OLV2.png](/files/6c66540fe0feacc7db1d180170167944d17a9ff4)

## 自定义列表

LaTeX 的列表是 *高度* 可配置的，这为创建许多不同类型的自定义列表提供了很大的空间。你既可以直接修改 LaTeX 的标准列表类型，或者， *更推荐的是*，使用功能极其灵活的 [enumitem 宏包](https://ctan.org/pkg/enumitem) 来替你完成。

CTAN 上托管了许多 [与列表相关的宏包](https://ctan.org/topic/list) ，如果你有特定的自定义需求，它们值得研究。此外，tex.stackexchange 还提供了大量 [与列表相关的问题](https://tex.stackexchange.com/questions/tagged/lists) 以及提供有用见解和精彩示例的答案！

我们将先看一些修改列表标签的示例，然后再进行列表布局的自定义。

### 自定义列表：更改标签

首先，我们将展示如何在不使用 [enumitem 宏包](https://ctan.org/pkg/enumitem).

#### 标准标签生成命令

可以通过使用 [enumitem](https://ctan.org/pkg/enumitem) 宏包，或者直接修改标准列表来创建自定义列表。这里，我们将总结一些你可能需要了解的标准 LaTeX 命令、计数器变量和列表参数。

下表显示了用于在各级 `itemize` 和 `enumerate` 列表环境中生成标签的 LaTeX 命令：

|        |                      |                    |
| ------ | -------------------- | ------------------ |
| **层级** | **`enumerate`** 标签命令 | **`itemize`** 标签命令 |
| 第 1 层  | `\labelenumi`        | `\labelitemi`      |
| 第 2 层  | `\labelenumii`       | `\labelitemii`     |
| 第 3 层  | `\labelenumiii`      | `\labelitemiii`    |
| 第 4 层  | `\labelenumiv`       | `\labelitemiv`     |

#### enumerate 的计数器变量

该 `enumerate` 列表环境也使用四个 *计数器* 变量，用于跟踪每一层当前的标签值：

|        |                       |
| ------ | --------------------- |
| **层级** | **`enumerate`** 计数器变量 |
| 第 1 层  | `enumi`               |
| 第 2 层  | `enumii`              |
| 第 3 层  | `enumiii`             |
| 第 4 层  | `enumiv`              |

#### 示例：自定义 enumerate 列表的标签

你可以通过使用 `\renewcommand` 来重新定义标签生成命令；而对于 `enumerate` 环境，你还可以使用相应的计数器变量。

下面是一些在不使用 `enumitem` 宏包。

**实用示例**

```latex
\documentclass{article}
\begin{document}
\renewcommand{\labelenumii}{\arabic{enumi}.\arabic{enumii}}
\renewcommand{\labelenumiii}{\arabic{enumi}.\arabic{enumii}.\arabic{enumiii}}
\renewcommand{\labelenumiv}{\arabic{enumi}.\arabic{enumii}.\arabic{enumiii}.\arabic{enumiv}}

\begin{enumerate}
\item 一
\item 二
\item 三
\begin{enumerate}
    \item 三点一
    \begin{enumerate}
    \item 三点一，点一
        \begin{enumerate}
        \item 三点一，点一，点一
        \item 三点一，点一，点二
        \end{enumerate}
    \end{enumerate}
\end{enumerate}
\item 四
\item 五
\end{enumerate}

\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Configuring+list+layout\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5Crenewcommand%7B%5Clabelenumii%7D%7B%5Carabic%7Benumi%7D.%5Carabic%7Benumii%7D%7D%0A%5Crenewcommand%7B%5Clabelenumiii%7D%7B%5Carabic%7Benumi%7D.%5Carabic%7Benumii%7D.%5Carabic%7Benumiii%7D%7D%0A%5Crenewcommand%7B%5Clabelenumiv%7D%7B%5Carabic%7Benumi%7D.%5Carabic%7Benumii%7D.%5Carabic%7Benumiii%7D.%5Carabic%7Benumiv%7D%7D%0A%0A%5Cbegin%7Benumerate%7D%0A%5Citem+One%0A%5Citem+Two%0A%5Citem+Three%0A%5Cbegin%7Benumerate%7D%0A++++%5Citem+Three+point+one%0A++++%5Cbegin%7Benumerate%7D%0A++++%5Citem+Three+point+one%2C+point+one%0A++++++++%5Cbegin%7Benumerate%7D%0A++++++++%5Citem+Three+point+one%2C+point+one%2C+point+one%0A++++++++%5Citem+Three+point+one%2C+point+one%2C+point+two%0A++++++++%5Cend%7Benumerate%7D%0A++++%5Cend%7Benumerate%7D%0A%5Cend%7Benumerate%7D%0A%5Citem+Four%0A%5Citem+Five%0A%5Cend%7Benumerate%7D%0A%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![List8OLV2.png](/files/dc4ba2d1b2dc1f6418ea85ba344e80b09c288134)

**打印计数器变量**

在前面的示例中，命令 `\arabic` 用于排版各种标签 *计数器变量*的当前值。请注意，“阿拉伯数字”，以及命令 `\arabic`，指的是 0 到 9 这些数字：请参见这篇 [维基百科上的阿拉伯数字文章](https://en.wikipedia.org/wiki/Arabic_numerals) 以了解更多背景。

一般来说，一个 *计数器变量* 可以通过以下 5 个命令之一以各种格式打印：

* `\arabic{*counter variable*}`
* `\roman{*counter variable*}`
* `\Roman{*counter variable*}`
* `\Alph{*counter variable*}`
* `\alph{*counter variable*}`

例如：

```latex
\documentclass{article}
\begin{document}
\begin{verbatim}
\newcounter{foo}
\setcounter{foo}{5}
\end{verbatim}
\newcounter{foo}
\setcounter{foo}{5}

\begin{itemize}
\item \verb|\arabic{foo}| 生成 \arabic{foo}
\item \verb|\roman{foo}| 生成 \roman{foo}
\item \verb|\Roman{foo}| 生成 \Roman{foo}
\item \verb|\Alph{foo}| 生成 \Alph{foo}
\item \verb|\alph{foo}| 生成 \alph{foo}
\end{itemize}

\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Configuring+list+layout\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bverbatim%7D%0A%5Cnewcounter%7Bfoo%7D%0A%5Csetcounter%7Bfoo%7D%7B5%7D++++%0A%5Cend%7Bverbatim%7D%0A%5Cnewcounter%7Bfoo%7D%0A%5Csetcounter%7Bfoo%7D%7B5%7D+%0A%0A%5Cbegin%7Bitemize%7D%0A%5Citem+%5Cverb%7C%5Carabic%7Bfoo%7D%7C+produces+%5Carabic%7Bfoo%7D%0A%5Citem+%5Cverb%7C%5Croman%7Bfoo%7D%7C+produces+%5Croman%7Bfoo%7D+%0A%5Citem+%5Cverb%7C%5CRoman%7Bfoo%7D%7C+produces+%5CRoman%7Bfoo%7D%0A%5Citem+%5Cverb%7C%5CAlph%7Bfoo%7D%7C+produces+%5CAlph%7Bfoo%7D%0A%5Citem+%5Cverb%7C%5Calph%7Bfoo%7D%7C+produces+%5Calph%7Bfoo%7D%0A%5Cend%7Bitemize%7D%0A%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![List8OLV2.png](/files/2840fca4e6cb69c9eb378190ccb9d26158affe1a)

**非实用（有趣的）示例**

本示例使用 OpenType 彩色字体排版表情符号，因此它将 *只能在 LuaLaTeX 中运行*。请参阅 Overleaf 文章 [LaTeX 中支持使用彩色表情符号字体的技术概述](/latex/zh-cn/shen-ru-wen-zhang/10-an-overview-of-technologies-supporting-the-use-of-colour-emoji-fonts-in-latex.md) 以了解有关表情符号排版的更多信息。

虽然这只是一个有趣的示例，并且使用 LuaLaTeX，但它演示了如何自定义全部四个标签生成命令，并使用标签计数器变量来创建一些不寻常的标签……点击“Open in Overleaf”链接查看完整代码。

```latex
\renewcommand{\labelenumi}{\duck{enumi}}
\renewcommand{\labelenumii}{\duck{enumi}.\duckegg{enumii}}
\renewcommand{\labelenumiii}{\duck{enumi}.\duckegg{enumii}.\duckegg{enumiii}}
\renewcommand{\labelenumiv}{\duck{enumi}.\duckegg{enumii}.\duckegg{enumiii}.\duckchick{enumiv}}

\begin{enumerate}
\item 一只鸭子
\item 更多鸭子
\item 一大群鸭子
\begin{enumerate}
    \item 鸭子和蛋
    \begin{enumerate}
    \item 我看到……
    \item 鸭子和预鸭子
       \begin{enumerate}
       \item 哇……
       \item 太可爱了！
       \end{enumerate}
    \end{enumerate}
\end{enumerate}
\item 回到鸭子
\item 再来一次
\end{enumerate}
```

[要查看 ***完整代码***，请在 Overleaf 中打开此 LuaLaTeX 示例。](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Fun+example+of+configuring+a+list\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bfontspec%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewfontfamily%5Cemojifont%5BRenderer%3DHarfbuzz%2CSizeFeatures%3D%7BSize%3D6%7D%5D%7BNotoColorEmoji.ttf%7D%0A%0A%5Cnewcount%5Cduckcount%0A%5Cnewcount%5Ceggcount%0A%5Cnewcount%5Cchickcount%0A%0A%5Cdef%5Cduck%231%7B%25%0A%5Cduckcount%3D%5Cvalue%7B%231%7D%25%0A%5Cloop%7B%5Cemojifont%5CUchar%221F986%7D%25%0A%5Cadvance%5Cduckcount+by+-1%0A%5Cunless%5Cifnum%5Cduckcount%3D0+%0A%5Crepeat%7D%0A%0A%5Cdef%5Cduckegg%231%7B%25%0A%5Ceggcount%3D%5Cvalue%7B%231%7D%25%0A%5Cloop%7B%5Cemojifont%5CUchar%221F95A%7D%25%0A%5Cadvance%5Ceggcount+by+-1%0A%5Cunless%5Cifnum%5Ceggcount%3D0+%0A%5Crepeat%7D%0A%0A%5Cdef%5Cduckchick%231%7B%25%0A%5Cchickcount%3D%5Cvalue%7B%231%7D%25%0A%5Cloop%7B%5Cemojifont%5CUchar%221F424%7D%25%0A%5Cadvance%5Cchickcount+by+-1%0A%5Cunless%5Cifnum%5Cchickcount%3D0+%0A%5Crepeat%7D%0A%5Crenewcommand%7B%5Clabelenumi%7D%7B%5Cduck%7Benumi%7D%7D%0A%5Crenewcommand%7B%5Clabelenumii%7D%7B%5Cduck%7Benumi%7D.%5Cduckegg%7Benumii%7D%7D%0A%5Crenewcommand%7B%5Clabelenumiii%7D%7B%5Cduck%7Benumi%7D.%5Cduckegg%7Benumii%7D.%5Cduckegg%7Benumiii%7D%7D%0A%5Crenewcommand%7B%5Clabelenumiv%7D%7B%5Cduck%7Benumi%7D.%5Cduckegg%7Benumii%7D.%5Cduckegg%7Benumiii%7D.%5Cduckchick%7Benumiv%7D%7D+%0A%0A%5Cbegin%7Benumerate%7D%0A%5Citem+A+duck%0A%5Citem+More+ducks%0A%5Citem+A+flurry+of+ducks%0A%5Cbegin%7Benumerate%7D%0A++++%5Citem+Ducks+and+eggs%0A++++%5Cbegin%7Benumerate%7D%0A++++%5Citem+Do+I+see...+%0A++++%5Citem+Ducks+and+pre-ducks+%0A+++++++%5Cbegin%7Benumerate%7D%0A+++++++%5Citem+Awww...%0A+++++++%5Citem+So+cute%21%0A+++++++%5Cend%7Benumerate%7D%0A++++%5Cend%7Benumerate%7D%0A%5Cend%7Benumerate%7D%0A%5Citem+Back+to+ducks%0A%5Citem+Again%0A%5Cend%7Benumerate%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出

![Ducklist.png](/files/bc4538ae507c12189f24ff5c64549d2c7e3ef87d)

### 自定义列表：更改布局

除了自定义标签之外，还可以修改列表间距和布局，但首先我们需要了解决定列表排版和布局的各种 LaTeX 参数。

#### LaTeX 列表参数

你可以使用 [layouts 宏包](https://ctan.org/pkg/layouts?lang=en) 来生成一张显示 LaTeX 列表参数的图表：

```latex
\documentclass{article}
\usepackage{layouts}
\begin{document}
\begin{figure}
\listdiagram
\caption{定义列表排版和布局的 \LaTeX{} 参数。}
\end{figure}
\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+the+layout+package+to+view+list+structures\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Blayouts%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Bfigure%7D%0A%5Clistdiagram%0A%5Ccaption%7BThe+%5CLaTeX%7B%7D+parameters+which+define+typesetting+and+layout+of+lists.%7D+%0A%5Cend%7Bfigure%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![](/files/575fe1b52ff095d58d38384d51f597cd951ddaf8)

这些参数的含义见 [LaTeX2e 非官方参考手册的列表部分](https://tug.org/texinfohtml/latex2e.html#list) ，因此这里不再赘述。

#### 使用 list 环境创建自定义列表

LaTeX 提供了通用的 `list` 环境，它提供了一个用于创建你自己的列表类型的框架。利用上图中的信息，下面的示例是对 [列表部分](https://tug.org/texinfohtml/latex2e.html#list) 的 [LaTeX2e 非官方参考手册](https://tug.org/texinfohtml/latex2e.html)

```latex
\documentclass{article}
\begin{document}
\newcounter{boxlblcounter}
\newcommand{\makeboxlabel}[1]{\fbox{#1.}\hfill}% \hfill 填充标签框
\newenvironment{boxlabel}
  {\begin{list}
    {\arabic{boxlblcounter}}
    {\usecounter{boxlblcounter}
     \setlength{\labelwidth}{3em}
     \setlength{\labelsep}{0em}
     \setlength{\itemsep}{2pt}
     \setlength{\leftmargin}{1.5cm}
     \setlength{\rightmargin}{2cm}
     \setlength{\itemindent}{0em}
     \let\makelabel=\makeboxlabel
    }
  }
{\end{list}}

\newcommand{\randomtext}{你好，这里有一些没有意义的文本。 你好，这里有一些没有意义的文本。 你好，这里有一些没有意义的文本。}

\noindent\randomtext

\begin{boxlabel}
\item \randomtext
\item \randomtext
\item \randomtext
\end{boxlabel}
\end{document}
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+the+list+environment\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewcounter%7Bboxlblcounter%7D++%0A%5Cnewcommand%7B%5Cmakeboxlabel%7D%5B1%5D%7B%5Cfbox%7B%231.%7D%5Chfill%7D%25+%5Chfill+fills+the+label+box%0A%5Cnewenvironment%7Bboxlabel%7D%0A++%7B%5Cbegin%7Blist%7D%0A++++%7B%5Carabic%7Bboxlblcounter%7D%7D%0A++++%7B%5Cusecounter%7Bboxlblcounter%7D%0A+++++%5Csetlength%7B%5Clabelwidth%7D%7B3em%7D%0A+++++%5Csetlength%7B%5Clabelsep%7D%7B0em%7D%0A+++++%5Csetlength%7B%5Citemsep%7D%7B2pt%7D%0A+++++%5Csetlength%7B%5Cleftmargin%7D%7B1.5cm%7D%0A+++++%5Csetlength%7B%5Crightmargin%7D%7B2cm%7D%0A+++++%5Csetlength%7B%5Citemindent%7D%7B0em%7D+%0A+++++%5Clet%5Cmakelabel%3D%5Cmakeboxlabel%0A++++%7D%0A++%7D%0A%7B%5Cend%7Blist%7D%7D%0A%0A%5Cnewcommand%7B%5Crandomtext%7D%7BHello%2C+here+is+some+text+without+a+meaning.+Hello%2C+here+is+some+text+without+a+meaning.+Hello%2C+here+is+some+text+without+a+meaning.%7D%0A%0A%5Cnoindent%5Crandomtext%0A%0A%5Cbegin%7Bboxlabel%7D%0A%5Citem+%5Crandomtext%0A%5Citem+%5Crandomtext%0A%5Citem+%5Crandomtext%0A%5Cend%7Bboxlabel%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![Listenvironmemt2.png](/files/a19e1d10ac8f673bf99674899e4b21b17aef54b8)

### 使用 enumitem 宏包修改和创建列表

该 [`enumitem` 宏包](https://ctan.org/pkg/enumitem?lang=en) 是修改标准 LaTeX 列表或创建你自己的自定义列表格式的推荐方法。 `enumitem` 提供了 *丰富的* 功能，因此我们无法全部涵盖，但可以提供一些基础示例帮助你上手。任何希望更深入探索这个功能多样的宏包的人都 *强烈* 建议浏览 tex.stackexchange，查找 [与……相关的问题、答案（和示例） `enumitem` 宏包](https://tex.stackexchange.com/questions/tagged/enumitem)，并阅读 [包文档](http://mirrors.ctan.org/macros/latex/contrib/enumitem/enumitem.pdf).

#### enumitem 宏包选项 shortlabels

该 `enumitem` 提供一个名为 `shortlabels` 的可选配置参数，你可以通过以下方式使用：

```latex
\usepackage[shortlabels]{enumitem}
```

该 `shortlabels` 该选项模仿了 `enumerate` 宏包的行为，为定义 enumerate 环境的编号方案提供了一种简洁方法。请参阅 [`enumerate` 包文档](https://ctan.org/pkg/enumerate?lang=en) 以获取更多信息。

#### 修改标准列表

参考 [LaTeX 参数图示](#latex-list-parameters) 中的值，我们可以使用 `enumitem` ，即可轻松自定义标准 LaTeX 列表，例如 `itemize`:

```latex
\documentclass{article}
\usepackage{enumitem}

\begin{document}

\newcommand{\randomtext}{你好，这里有一些没有意义的文本。 你好，这里有一些没有意义的文本。}

\section*{使用 LaTeX 的 \texttt{itemize} 默认设置}

\randomtext

\begin{itemize}
\item \randomtext
   \begin{itemize}
      \item \randomtext
        \begin{itemize}
        \item \randomtext
        \end{itemize}
   \item \randomtext
   \end{itemize}
\item \randomtext
\end{itemize}

\section*{通过 \texttt{enumitem} 使用自定义 \texttt{itemize}}

\subsection*{注意左、右边距设置的影响}

\randomtext

\begin{itemize}[leftmargin=30pt, rightmargin=2cm]
\item \randomtext
   \begin{itemize}
      \item \randomtext
        \begin{itemize}
        \item \randomtext
        \end{itemize}
   \item \randomtext
   \end{itemize}
\item \randomtext
\end{itemize}

\end{document}
```

[在 Overleaf 中打开此 `enumitem` Overleaf 中的示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Modifying+a+LaTeX+list+with+enumitem\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Benumitem%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cnewcommand%7B%5Crandomtext%7D%7BHello%2C+here+is+some+text+without+a+meaning.+Hello%2C+here+is+some+text+without+a+meaning.%7D%0A%0A%5Csection%2A%7BUsing+LaTeX%27s+default+settings+for+%5Ctexttt%7Bitemize%7D%7D%0A%0A%5Crandomtext%0A%0A%5Cbegin%7Bitemize%7D%0A%5Citem+%5Crandomtext%0A+++%5Cbegin%7Bitemize%7D%0A++++++%5Citem+%5Crandomtext%0A++++++++%5Cbegin%7Bitemize%7D%0A++++++++%5Citem+%5Crandomtext%0A++++++++%5Cend%7Bitemize%7D%0A+++%5Citem+%5Crandomtext%0A+++%5Cend%7Bitemize%7D%0A%5Citem+%5Crandomtext%0A%5Cend%7Bitemize%7D%0A%0A%5Csection%2A%7BUsing+a+custom+%5Ctexttt%7Bitemize%7D+via+%5Ctexttt%7Benumitem%7D%7D%0A%0A%5Csubsection%2A%7BNote+the+effect+of+left+and+right+margin+settings%7D%0A%0A%5Crandomtext%0A%0A%5Cbegin%7Bitemize%7D%5Bleftmargin%3D30pt%2C+rightmargin%3D2cm%5D%0A%5Citem+%5Crandomtext%0A+++%5Cbegin%7Bitemize%7D%0A++++++%5Citem+%5Crandomtext%0A++++++++%5Cbegin%7Bitemize%7D%0A++++++++%5Citem+%5Crandomtext%0A++++++++%5Cend%7Bitemize%7D%0A+++%5Citem+%5Crandomtext%0A+++%5Cend%7Bitemize%7D%0A%5Citem+%5Crandomtext%0A%5Cend%7Bitemize%7D%0A%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![Tweakitemize2.png](/files/c4b7ea4b28c9d5b769a53cfd622c831c9feba587)

#### 使用 enumitem 创建新列表

要使用 `enumitem` 创建新的列表类型，你使用 `\newlist` 命令，它需要 3 个参数：

```latex
\newlist{name}{list-type}{max-depth}
```

* **`名称`**：你的列表名称，将作为环境名称使用：

  ```
  \begin{name}
  ...
  \end{name}
  ```
* **`列表类型`** 这必须是标准 LaTeX 列表类型之一：
* `enumerate`
* `itemize`
* `描述`
* **`最大深度`**：该列表允许嵌套的最大深度。 **注意** 对于超过 LaTeX 默认 4 层嵌套限制的列表，你还必须使用命令 `\setlistdepth{*integer*}` 其中 `*整数*` 是你打算使用的最大嵌套深度。请参阅 [律师列表](#lists-for-lawyers-nesting-lists-to-an-arbitrary-depth) 示例以查看演示。

创建新列表后，你可以使用 `\setlist` 命令。

**使用 \setlist 配置用 enumitem 创建的自定义列表**

在这个示例中，我们将创建一个名为 `myitems` 的列表，它基于 `enumerate`。我们将把 [`**最大深度**`](#maxdepth) 设为 3：

```latex
\newlist{myitems}{enumerate}{3}
```

最低要求是使用 `\setlist` 命令为这个自定义列表定义标签。对于基于 enumerate 的列表，一种做法是使用由 `enumitem` 宏包创建的计数器变量——这些计数器变量使用 `**名称**` 作为你的列表： `myitems` 在我们的示例中。

下面是我们在标签配置中如何使用相应的计数器变量：

* `myitems**i**` 用于第 1 层条目
* `myitems**ii**` 用于第 2 层条目
* `myitems**iii**` 用于第 3 层条目

如果我们有超过 3 层，那么相应的计数器变量将被称为 `myitems**iv**` （第 4 层）， `myitems**v**` （第 5 层）等等，继续使用小写罗马数字。

除了标签之外，我们还将为 `leftmargin` 和 `rightmargin` 导入（见 [LaTeX 参数图示](#latex-list-parameters)).

```latex
\documentclass{article}
\usepackage{enumitem}
\begin{document}

\newcommand{\randomtext}{你好，这里有一些没有意义的文本。 你好，这里有一些没有意义的文本。}

\newcommand{\shortrandomtext}{你好，这里有一些文本。}
% 基于 enumerate 创建一个自定义列表
% 它被称为“myitems”
% 我们将创建一个 3 层深的列表
\newlist{myitems}{enumerate}{3}

% 配置第 1 层条目的行为
% 注意：我们使用列表计数器“myitemsi”
\setlist[myitems, 1]
{label=\arabic{myitemsi}., %1., 2., 3., ...
leftmargin=\parindent,
rightmargin=10pt
}

% 配置第 2 层条目的行为
% 注意：我们使用列表计数器“myitemsii”
\setlist[myitems, 2]
{label=\arabic{myitemsi}.\arabic{myitemsii}, %1.1, 1.2, 1.3...
leftmargin=15pt,
rightmargin=15pt}

% 配置第 3 层条目的行为
% 注意：我们使用列表计数器“myitemsiii”
\setlist[myitems, 3]
% 使用 1.1:<kern>(a), 1.1:<kern>(b) 等标签
{label=\arabic{myitemsi}.\arabic{myitemsii}:\kern1.5pt(\alph{myitemsiii}),
leftmargin=30pt,
rightmargin=30pt}

\randomtext
\begin{myitems}
\item \randomtext
    \begin{myitems}
    \item \randomtext
        \begin{myitems}
        \item \randomtext
        \item \randomtext
        \end{myitems}
    \item \shortrandomtext
    \item \shortrandomtext
    \end{myitems}
\item \randomtext
\end{myitems}
\end{document}
```

[在 Overleaf 中打开此 `enumitem` Overleaf 中的示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Create+a+custom+list+with+enumitem\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Benumitem%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cnewcommand%7B%5Crandomtext%7D%7BHello%2C+here+is+some+text+without+a+meaning.+Hello%2C+here+is+some+text+without+a+meaning.%7D%0A%0A%5Cnewcommand%7B%5Cshortrandomtext%7D%7BHello%2C+here+is+some+text.%7D%0A%25+Create+a+custom+list+based+on+enumerate%0A%25+It+is+called+%22myitems%22%0A%25+We%27ll+create+a+list+that+is+3+levels+deep%0A%5Cnewlist%7Bmyitems%7D%7Benumerate%7D%7B3%7D%0A%0A%25+Configure+the+behaviour+of+level+1+entries%0A%25+NOTE%3A+we+use+the+list+counter+%22myitemsi%22%0A%5Csetlist%5Bmyitems%2C+1%5D%0A%7Blabel%3D%5Carabic%7Bmyitemsi%7D.%2C+%251.%2C+2.%2C+3.%2C+...%0Aleftmargin%3D%5Cparindent%2C%0Arightmargin%3D10pt%0A%7D%0A%0A%25+Configure+the+behaviour+of+level+2+entries%0A%25+NOTE%3A+we+use+the+list+counter+%22myitemsii%22%0A%5Csetlist%5Bmyitems%2C+2%5D%0A%7Blabel%3D%5Carabic%7Bmyitemsi%7D.%5Carabic%7Bmyitemsii%7D%2C+%251.1%2C+1.2%2C+1.3...%0Aleftmargin%3D15pt%2C%0Arightmargin%3D15pt%7D%0A%0A%25+Configure+the+behaviour+of+level+3+entries%0A%25+NOTE%3A+we+use+the+list+counter+%22myitemsiii%22%0A%5Csetlist%5Bmyitems%2C+3%5D%0A%25+Use+a+label+of+1.1%3A%3Ckern%3E%28a%29%2C+1.1%3A%3Ckern%3E%28b%29+etc++%0A%7Blabel%3D%5Carabic%7Bmyitemsi%7D.%5Carabic%7Bmyitemsii%7D%3A%5Ckern1.5pt%28%5Calph%7Bmyitemsiii%7D%29%2C%0Aleftmargin%3D30pt%2C%0Arightmargin%3D30pt%7D%0A%0A%5Crandomtext%0A%5Cbegin%7Bmyitems%7D%0A%5Citem+%5Crandomtext%0A++++%5Cbegin%7Bmyitems%7D%0A++++%5Citem+%5Crandomtext%0A++++++++%5Cbegin%7Bmyitems%7D%0A++++++++%5Citem+%5Crandomtext%0A++++++++%5Citem+%5Crandomtext%0A++++++++%5Cend%7Bmyitems%7D%0A++++%5Citem+%5Cshortrandomtext%0A++++%5Citem+%5Cshortrandomtext%0A++++%5Cend%7Bmyitems%7D%0A%5Citem+%5Crandomtext%0A%5Cend%7Bmyitems%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![CustomItemizeList.png](/files/77e0613c95f56cf851eabf4a5d04ec7a4fa0a570)

#### 律师用列表：将列表嵌套到任意深度

该 `enumitem` 宏包可让你创建可嵌套到任意深度的列表，去除 LaTeX 4 层的限制。任何正在准备具有复杂（深度嵌套）条款结构合同的人都可能从中受益，尽管这些嵌套代码看起来确实有点吓人……

```latex
\documentclass{article}
\usepackage{enumitem}

\begin{document}

\newlist{contract}{enumerate}{10}
\setlist[contract]{label*=\arabic*.}
\setlistdepth{10}

\section*{嵌套到 10 层深的自定义列表！}

\begin{contract}
\item 第 1 层
 \begin{contract}
 \item 第 2 层
   \begin{contract}
   \item 第 3 层
     \begin{contract}
     \item 第 4 层
       \begin{contract}
       \item 第 5 层
        \begin{contract}
        \item 第 6 层
         \begin{contract}
         \item 第 7 层
          \begin{contract}
          \item 第 8 层
           \begin{contract}
           \item 第 9 层
            \begin{contract}
            \item 第 10 层
          \end{contract}
         \end{contract}
        \end{contract}
       \end{contract}
      \end{contract}
     \end{contract}
    \end{contract}
   \end{contract}
  \end{contract}
 \end{contract}
\end{document}
```

[在 Overleaf 中打开此 `enumitem` Overleaf 中的示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Using+the+enumitem+package+to+create+deeply+nested+lists\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Benumitem%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cnewlist%7Bcontract%7D%7Benumerate%7D%7B10%7D%0A%5Csetlist%5Bcontract%5D%7Blabel%2A%3D%5Carabic%2A.%7D%0A%5Csetlistdepth%7B10%7D+%0A%0A%5Csection%2A%7BCustom+list+nested+to+10+levels+deep%21%7D%0A%0A%5Cbegin%7Bcontract%7D%0A%5Citem+Level+1%0A+%5Cbegin%7Bcontract%7D%0A+%5Citem+Level+2%0A+++%5Cbegin%7Bcontract%7D%0A+++%5Citem+Level+3%0A+++++%5Cbegin%7Bcontract%7D%0A+++++%5Citem+Level+4%0A+++++++%5Cbegin%7Bcontract%7D%0A+++++++%5Citem+Level+5%0A++++++++%5Cbegin%7Bcontract%7D%0A++++++++%5Citem+Level+6%0A+++++++++%5Cbegin%7Bcontract%7D%0A+++++++++%5Citem+Level+7%0A++++++++++%5Cbegin%7Bcontract%7D%0A++++++++++%5Citem+Level+8%0A+++++++++++%5Cbegin%7Bcontract%7D%0A+++++++++++%5Citem+Level+9%0A++++++++++++%5Cbegin%7Bcontract%7D%0A++++++++++++%5Citem+Level+10%0A++++++++++%5Cend%7Bcontract%7D%0A+++++++++%5Cend%7Bcontract%7D%0A++++++++%5Cend%7Bcontract%7D%0A+++++++%5Cend%7Bcontract%7D%0A++++++%5Cend%7Bcontract%7D%0A+++++%5Cend%7Bcontract%7D%0A++++%5Cend%7Bcontract%7D%0A+++%5Cend%7Bcontract%7D%0A++%5Cend%7Bcontract%7D%0A+%5Cend%7Bcontract%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![10levels.png](/files/8ff28339771e9299e4c1710bd0e422e7d26face0)

#### 使用 enumitem 宏包和 MetaPost 的自定义项目符号

下面的示例仅适用于 LuaLaTeX，并旨在提供一些可能性的示意——当然，你也可以用你喜欢的绘图应用/工具替换 MetaPost！

这些示例使用 `luamplib` 宏包，并且还演示了可展开命令，例如 `\\the` 和 `\directlua`，可以在 MetaPost 代码中使用。

**示例 1：自动缩放项目符号**

这个示例生成的项目符号会随着列表深度增加而变小。点击“在 Overleaf 中打开”链接运行示例并查看完整代码。

```latex
% 通过 enumitem 声明一个新的基于 itemize 的列表
\newlist{myEnumerate}{itemize}{6}

% nosep 选项会移除所有垂直间距
% label=\protect\mpbullet 会使所有项目符号都被
% 由使用 MetaPost 代码的宏绘制。\protect
% 如 enumitem 手册所述，这是必需的

\setlist[myEnumerate]{nosep,label=\protect\mpbullet}
\setlistdepth{6}

\begin{myEnumerate}
\item 第 1 层
  \begin{myEnumerate}
   \item 第 2 层
    \begin{myEnumerate}
     \item 第 3 层
      \begin{myEnumerate}
       \item 第 4 层
        \begin{myEnumerate}
         \item 第 5 层
          \begin{myEnumerate}
           \item 第 6 层
           \end{myEnumerate}
        \end{myEnumerate}
       \end{myEnumerate}
    \end{myEnumerate}
   \end{myEnumerate}
\end{myEnumerate}
```

[要查看 ***完整代码***，请在 Overleaf 中打开此 LuaLaTeX 示例。](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Using+MetaPost+with+the+enumitem+package\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bluamplib%7D%0A%5Cusepackage%7Benumitem%7D%0A%5Ceverymplib%7Bbeginfig%280%29%3B%7D%0A%5Ceveryendmplib%7Bendfig%3B%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0AThis+list+configuration+example+uses+MetaPost+code+that+contains+Lua+code+via+%5Cverb%7C%5Cdirectlua%7C.+Bullets+are+created+by+MetaPost+code%2C+size+is+calculated+from+the+depth+of+the+entry.%0A%0A%25+It+is+convenient+to+use+%5Clet%5Cmpdepth%5C%40listdepth%3A+makes+it+%0A%25+easier+to+use+in+MetaPost+code%0A%0A%5Ccatcode%60%40%3D11%0A%5Clet%5Cmpdepth%5C%40listdepth%0A%5Ccatcode%60%40%3D12%0A%0A%5Cnewcommand%7B%5Cmpbullet%7D%7B%25%0A%5Cbegin%7Bmplibcode%7D%25%0Adraw+%280%2C0%29..%280%2C-%5Cdirectlua%7Btex.print%28%5Cthe%5Cmpdepth%2F2%29%7D%29+withpen+pencircle+scaled+2pt+withcolor+white%3B%0Adrawdot%280%2C0%29+withpen+pencircle+scaled+%5Cdirectlua%7Btex.print%285%2Fmath.sqrt%28%5Cthe%5Cmpdepth%29%29%7Dbp%3B%0A%5Cend%7Bmplibcode%7D%7D%0A%25+Declare+a+new+itemize-based+list+via+enumitem%0A%5Cnewlist%7BmyEnumerate%7D%7Bitemize%7D%7B6%7D%0A%0A%25+The+nosep+option+removes+all+vertical+spacing%0A%25+the+label%3D%5Cprotect%5Cmpbullet+causes+all+bullets+to+be+%0A%25+drawn+by+a+macro+that+uses+MetaPost+code.+%5Cprotect%0A%25+is+required+as+noted+in+the+enumitem+manual+%0A%0A%5Csetlist%5BmyEnumerate%5D%7Bnosep%2Clabel%3D%5Cprotect%5Cmpbullet%7D%0A%5Csetlistdepth%7B6%7D%0A%0A%5Cbegin%7BmyEnumerate%7D%0A%5Citem+Level+1%0A++%5Cbegin%7BmyEnumerate%7D%0A+++%5Citem+Level+2%0A++++%5Cbegin%7BmyEnumerate%7D%0A+++++%5Citem+Level+3%0A++++++%5Cbegin%7BmyEnumerate%7D%0A+++++++%5Citem+Level+4%0A++++++++%5Cbegin%7BmyEnumerate%7D%0A+++++++++%5Citem+Level+5%0A++++++++++%5Cbegin%7BmyEnumerate%7D%0A+++++++++++%5Citem+Level+6%0A+++++++++++%5Cend%7BmyEnumerate%7D%0A++++++++%5Cend%7BmyEnumerate%7D%0A+++++++%5Cend%7BmyEnumerate%7D%0A++++%5Cend%7BmyEnumerate%7D%0A+++%5Cend%7BmyEnumerate%7D%0A%5Cend%7BmyEnumerate%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![Autosize.png](/files/973f224878e6d3f7f89fa91ea61d99d9800f17ad)

**示例 2：古怪的自定义项目符号**

这个示例的灵感来自一个 [tex.stackexchange 上的示例](https://tex.stackexchange.com/a/313337) ，Overleaf 对其进行了修改，以使用 MetaPost 代码创建自定义项目符号。点击“在 Overleaf 中打开”链接运行示例并查看完整代码。

```latex
\newlist{todolist}{itemize}{2}

\begin{itemize}
  \item 开始思考我们希望实现什么
  \begin{todolist}
  \item[\mpdot] 确定目标
  \item[\mpyingyang] 平衡环境影响
  \item[\mpsquare{0}{5}{0}] 实施计划
    \begin{todolist}
    \item[\mpsquare{-0.5}{4}{0}] 第一阶段计划
    \item[\mpsquare{-0.5}{4}{-20}] 第二阶段计划
    \item[\mpsquare{-0.5}{4}{-40}] 第三阶段计划
    \item[\mpsquare{-0.5}{4}{-60}] 第四阶段计划
    \end{todolist}
  \end{todolist}
\end{itemize}
```

[要查看 ***完整代码***，请在 Overleaf 中打开此 LuaLaTeX 示例。](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Second+example+using+MetaPost+with+the+enumitem+package\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Benumitem%7D%0A%5Cusepackage%7Bluamplib%7D%0A%5Ceverymplib%7Bbeginfig%280%29%3B%7D%0A%5Ceveryendmplib%7Bendfig%3B%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%5Cnewcommand%7B%5Cmpyingyang%7D%7B%25%0A%5Clower1.5pt%5Chbox%7B%5Cbegin%7Bmplibcode%7D%25%0Apath+p%3B%0Ap%3A%3D%28-1%2C0%29..%280%2C-1%29..%281%2C0%29%3B%0Afill+%28p%7Bup%7D..%7Bdown%7D%280%2C0%29%7Bdown%7D..%7Bup%7Dcycle%29+scaled+0.15cm%3B%0Adraw+%28p..%280%2C1%29..cycle%29+scaled+0.15cm+%3B%0A%5Cend%7Bmplibcode%7D%7D%25%0A%7D%25%0A%5Cnewcommand%7B%5Cmpdot%7D%7B%25%0A%5Clower1.5pt%5Chbox%7B%5Cbegin%7Bmplibcode%7D%25%0Adrawdot%280%2C0%29+withpen+pencircle+scaled+2bp%3B%0Adraw+fullcircle+scaled+0.2cm%3B%0Adraw+fullcircle+scaled+0.3cm%3B%0A%5Cend%7Bmplibcode%7D%7D%25%0A%7D%25%0A%5Cnewcommand%7B%5Cmpsquare%7D%5B3%5D%7B%25%0A%5Clower%231pt%5Chbox%7B%5Cbegin%7Bmplibcode%7D%25%0Adraw+unitsquare+rotated+%233+scaled+%232pt%3B%0A%5Cend%7Bmplibcode%7D%25%0A%7D%7D%25%0A%5Cnewlist%7Btodolist%7D%7Bitemize%7D%7B2%7D%0A%0A%5Cbegin%7Bitemize%7D%0A++%5Citem+Start+thinking+about+what+we+hope+to+achieve%0A++%5Cbegin%7Btodolist%7D%0A++%5Citem%5B%5Cmpdot%5D+Identify+objectives%0A++%5Citem%5B%5Cmpyingyang%5D+Balance+environmental+impact+%0A++%5Citem%5B%5Cmpsquare%7B0%7D%7B5%7D%7B0%7D%5D+Implement+plans%0A++++%5Cbegin%7Btodolist%7D%0A++++%5Citem%5B%5Cmpsquare%7B-0.5%7D%7B4%7D%7B0%7D%5D+Stage+1+plans%0A++++%5Citem%5B%5Cmpsquare%7B-0.5%7D%7B4%7D%7B-20%7D%5D+Stage+2+plans%0A++++%5Citem%5B%5Cmpsquare%7B-0.5%7D%7B4%7D%7B-40%7D%5D+Stage+3+plans%0A++++%5Citem%5B%5Cmpsquare%7B-0.5%7D%7B4%7D%7B-60%7D%5D+Stage+4+plans%0A++++%5Cend%7Btodolist%7D%0A++%5Cend%7Btodolist%7D%0A%5Cend%7Bitemize%7D%0A%5Cend%7Bdocument%7D)

此示例生成以下输出：

![CustomBullets2.png](/files/d457dcd7648b88a77012157888aaf3d740faae80)

## enumitem 宏包的其他特性

如前所述， `enumitem` 宏包极其灵活，为列表的使用和自定义提供了许多功能。例如，我们尚未介绍的功能包括：

* 引用列表条目：例如，参见这个 [tex.stackexchane 问题和示例](https://tex.stackexchange.com/questions/524822/help-for-formatting-the-ref-of-nested-enumerate)
* 控制 `enumerate` 列表编号：
  * 设置第一个条目的起始编号
  * 继续不同 `enumerate` 列表

还有很多！浏览 [tex.stackexchange，查找许多很棒的示例](https://tex.stackexchange.com/questions/tagged/enumitem) 了解你可以通过 `enumitem`——当然， [阅读宏包文档](https://ctan.org/pkg/enumitem).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/zh-cn/latex-ji-chu/04-lists.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
