取决于您试图通过更改表格格式来完成的任务。例如,如果您想定义行颜色并在整个文档中相应地更改表格,您可以使用 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 https://github.com/jterrace/sphinxtr/tree/master/extensions
Jeff Terrace 包含一些很棒的扩展,但要使用的两个主要扩展是numfig https://bitbucket.org/arjones6/sphinx-numfig/wiki/Home and figtable https://github.com/jterrace/sphinxtr/blob/master/extensions/figtable.py。您可以将 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}
更好地定义您希望表格的显示方式。