【问题标题】:Create table of content inside table在表格内创建目录
【发布时间】:2012-10-23 01:25:47
【问题描述】:

我希望能够在表格中生成目录。例如。这应该 有边框,看起来像这样:

.. tabularcolumns:: |p{10.5cm}|p{1.1cm}|p{1.4cm}|p{1.1cm}|
+----------------------------------------------------+-------+---------+-----+
|                                                    | hw1   |  hw2    | hw3 |
+====================================================+=======+=========+=====+
| heading 1                                          |       |         |     |
+----------------------------------------------------+-------+---------+-----+
| heading 2                                          |       |         |     |
+----------------------------------------------------+-------+---------+-----+
| heading 3                                          |       |         |     |
+----------------------------------------------------+-------+---------+-----+

我想从以下内容自动生成表格:

.. toctree::
   :maxdepth: 2

file 1
file 2

输出为 html 和 pdf。

这可以吗?还是我必须使用 docutils 解析器或类似的?

【问题讨论】:

    标签: python-sphinx restructuredtext tableofcontents docutils toctree


    【解决方案1】:

    你可以编辑 basic.css 给你的toc 一个边框:

    第 1 步:从您的 Sphinx 构建目录 cp _build/html/_static/basic.css _static/

    第 2 步:将以下行添加到 basic.css

    div.toctree-wrapper {
        border-collapse: collapse;
    }
    
    div.toctree-wrapper li {
        padding: 1px 8px 1px 5px;
        border:1px solid black; 
    }
    

    第 3 步:编辑您的第一个文件,以便在您执行 make html 时启动构建

    .. 你应该在你的目录周围看到边框......像这样

    【讨论】:

    • 感谢您的回答。不幸的是,我需要同时输出 html 页面和 pdf 文档。
    猜你喜欢
    • 1970-01-01
    • 2018-12-05
    • 2015-07-20
    • 2016-05-29
    • 1970-01-01
    • 2012-10-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    相关资源
    最近更新 更多