Sphinx:在 LaTeX 构建中隐藏 `{contents}`

问题描述 投票:0回答:1

索引.rst

======================================
MyTitle
======================================
.. raw:: latex

   \section*{MyTitle}

Some text

.. toctree::
      :hidden:
      :titlesonly:
      :caption: Setup

   setup_macos

setup_macos.md

```{contents} On this page:
```

# macOS setup

In this tutorial...

问题是关于 setup_macos.md 中的

{contents}
标签。

这会生成“本地”TOC。这在 HTML 文档中是可取的,但我不希望它出现在 Latexpdf 文档中。

如何将本地目录放入 HTML 页面,但在 LaTeX 输出中隐藏它?

latex python-sphinx restructuredtext myst
1个回答
0
投票

contents
指令嵌套在
only
指令中。按照此处所述使用反引号:https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html#nesting-directives.

````{only} html
```{contents} On this page:
```
````
© www.soinside.com 2019 - 2024. All rights reserved.