gpt4 book ai didi

python - 如何在 Sphinx 中使用自动编号制作嵌套列表?

转载 作者:行者123 更新时间:2023-12-03 20:19:29 27 4
gpt4 key购买 nike

我正在使用 Sphinx 为 Python 程序编写文档。
我想创建一个带有嵌套列表和自动编号的有序列表。

我想获得这样的东西:

Here it follows a numbered list

  1. This is the first item of the list
  2. This is the second one
    • The second item has a nested list with two items
    • this is the last item of the nested list
  3. The parent list continues with its third item


如果我明确使用数字作为编号列表,一切都会好起来的。当我想使用自动编号时会出现这个问题,因为我想保持灵活性。列表很长,将来可能会更改,我不想在引入新项目时更改所有数字。

我尝试使用以下代码:
Here it follows a numbered list

#. This is the first item of the list
#. This is the second one

* The second item has a nested list with two items
* this is the last item of the nested list

#. The parent list continues with its third item

我得到的结果如下:

Here it follows a numbered list

  1. This is the first item of the list
  2. This is the second one

    • The second item has a nested list with two items
    • this is the last item of the nested list

.1. The parent list continues with its third item



[我必须添加一些字符,这里是一个点,用于第三项或 stackoverflow 中的 Markdown 系统显示 3!]

如您所见,嵌套列表从头开始重新启动后的编号。

最佳答案

您必须正确缩进嵌套项目符号列表的两个项目以匹配父列表的文本,因此只需添加如下空格:

#. This is the first item of the list
#. This is the second one

* The second item has a nested list with two items
* this is the last item of the nested list

#. The parent list continues with its third item

完整说明 here

关于python - 如何在 Sphinx 中使用自动编号制作嵌套列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34450064/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com