python-sphinx - csv 表格式通过序言?

标签 python-sphinx

尽我所能,我无法弄清楚如何更改 sphinx 输出的 pdf 中的默认表格格式。

我可以编辑 .tex 文件或 writer.py 源代码...但这两个似乎都是不好的选择。

是否有任何东西可以传递到序言来实现这一点?

最佳答案

取决于您试图通过更改表格格式来完成什么。例如,如果您想要定义行颜色并在整个文档中相应地更改表格,您可以同时使用 xcolor 包并通过更改表格环境来重新定义表格在定义点处理它的方式。

所以在序言中你会做

\usepackage[table]{xcolor}
\definecolor{foo}{RGB}{236,137,29}
\definecolor{bar}{RGB}{232,108,31}

\let\newtabular\tabular
\let\newendtabular\endtabular
\renewenvironment{tabular}{\rowcolors{2}{foo}{bar}\newtabular}{\newendtabular}

这将覆盖默认的表格环境,并在整个文档中应用 foo 和 bar 行颜色,从第二行开始。

有更多与表相关的指令。你应该看看sphinxtr

Jeff Terrace 包含一些很棒的扩展,但要使用的两个主要扩展是 numfigfigtable .您可以将 csv 表包装到 figtable 中。

.. figtable::
   :label: my-csv-label
   :caption: My CSV Table
   :nofig:

   .. csv-table::
     :file: data/foo.csv
     :header-rows: 1

使用下面而不是上面的标题更改标准表格格式。然后,您还可以获得额外的好处,即能够使用 :num: 直接链接到该表。

:num:`Table #my-csv-label`

它会自动相应编号,而不引用标签名称。您还可以使用

.. figtable::
   :spec: {r l r l}

为了更好地定义您希望表格的显示方式。

table

table2

关于python-sphinx - csv 表格式通过序言?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8681236/

相关文章:

python - Sphinx 没有正确更新文档

python - 使用 SPHINX、FURO、AUTODOC 构建 html 文档。错误样式表

python - 如何将 Sphinx 与其他模板一起使用?

python - 让 sphinx 使用 setup.py 中的版本

python - 递归地使用 Sphinx autosummary 生成 API 文档

python - Sphinx 中带有 .. autofunction::的重载函数的文档字符串

python-sphinx - 在 reStructuredText 中格式化链接中的文本

python-sphinx - 在 sphinx 的侧边栏中启用版本阅读文档主题

python - 使用 setuptools 为 Python 项目自动生成文档

python -\r 在 sphinx 中代表什么吗?