【问题标题】:How to make nested lists with automatic numbering in Sphinx?如何在 Sphinx 中使用自动编号制作嵌套列表?
【发布时间】:2015-12-24 09:04:02
【问题描述】:

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

我想得到这样的东西:

这里是一个编号列表

  1. 这是列表的第一项
  2. 这是第二个
    • 第二个项目有一个包含两个项目的嵌套列表
    • 这是嵌套列表的最后一项
  3. 父列表继续其第三项

如果我明确使用数字作为编号列表,一切都会好起来的。当我想使用自动编号时,问题就出现了,因为我想保持灵活性。清单很长,将来可能会发生变化,我不想在介绍新项目时更改所有数字。

我已尝试使用以下代码:

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

我得到的结果如下:

这里是一个编号列表

  1. 这是列表的第一项
  2. 这是第二个

    • 第二个项目有一个包含两个项目的嵌套列表
    • 这是嵌套列表的最后一项

.1。父列表继续其第三项

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

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

【问题讨论】:

标签: python list python-sphinx nested-lists numbered-list


【解决方案1】:

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

#. 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多