如何在Sphinx的reStructuredText中设置toctree目录的标题?
解决Sphinx toctree 添加标题的问题
直接在toctree上方添加普通标题无效,因为Sphinx对toctree的渲染逻辑特殊,你可以试试以下三种有效方法:
方法一:使用toctree自带的
:caption:参数
这是最官方的解决方案,直接给toctree设置标题,代码示例:.. toctree:: :caption: My table of content self doc/windows doc/macos doc/linux方法二:用
.. rubric::指令生成关联小标题
如果需要一个非正式的小标题,可使用rubric指令,它会和下方的toctree块关联显示:.. rubric:: My table of content .. toctree:: self doc/windows doc/macos doc/linux方法三:将toctree包裹在正式章节中
若要把标题作为正式章节标题,可直接用章节标题+toctree的组合,若不想重复显示目录,可给toctree加:hidden:参数,再手动引出内容:My table of content =================== .. toctree:: :hidden: self doc/windows doc/macos doc/linux 这里可以添加目录的说明文字,下方会自动展示各个子页面的链接(如果未设置:hidden),或者你可以手动列出需要显示的内容。
内容的提问来源于stack exchange,提问作者tony_merguez
相关产品推荐
相关产品推荐

