同一源文档中的不同表格样式

Tra*_*cer 5 markdown cpu-word pandoc

我正在使用 Pandoc 2.10.1 从 Markdown 转换为 DOCX。我的源文件中有 2 个表,它们的样式应该不同。我知道:

  • 表格的默认样式是Table
  • 我可以提供一个参考文档,其中可以收集样式
  • 我可以修改Table这个样式参考文档中的样式
  • 我可以将自己的表格样式添加到此参考文档中

但我无法弄清楚的是,一个表应如何具有默认Table样式,而另一个表应如何具有MyGoodTable样式。我尝试过对一张桌子什么都不做,并将另一张桌子围在一个有围栏的 div 中,如下所示:

:::{custom-style=MyTableStyle}

+-----+-----+-----+
| A   | B   | C   |
+=====+=====+=====+
| 10  | 11  | 12  |
+-----+-----+-----+
| 20  | 21  | 22  |
+-----+-----+-----+
| 30  | 31  | 33  | 
+-----+-----+-----+

:::
Run Code Online (Sandbox Code Playgroud)

然而,这不起作用,即使我的参考文档具有MyTableStyle表格样式。

那么,文档中的一个表格如何具有一种样式,而同一文档中的另一个表格具有另一种样式呢?

Ale*_*lex -2

这实际上是Python-Markdown的解决方案,而不是 DOCX 的解决方案。但也许它可以以某种方式进行调整,或者对那些通过标题发现这个问题的人有用。

The default table stile: 

Item No | Name | Description | Price
--------|------|-------------|------
1       | Chair | Kitchen chair | 101.50
2       | Table | Kitchen table | 450.00

The "plated" table style:

<div class="tablePlated"></div>

|Item No | Name | Description | Price|
|--------|------|-------------|------|
|1       | Chair | Kitchen chair | 101.50|
|2       | Table | Kitchen table | 450.00|

And the "gridded" table style:

<div class="tableGridded"></div>

Item No | Name | Description | Price
--------|------|-------------|------
1       | Chair | Kitchen chair | 101.50
2       | Table | Kitchen table | 450.00
Run Code Online (Sandbox Code Playgroud)

以下是 CSS 规则:

The default table stile: 

Item No | Name | Description | Price
--------|------|-------------|------
1       | Chair | Kitchen chair | 101.50
2       | Table | Kitchen table | 450.00

The "plated" table style:

<div class="tablePlated"></div>

|Item No | Name | Description | Price|
|--------|------|-------------|------|
|1       | Chair | Kitchen chair | 101.50|
|2       | Table | Kitchen table | 450.00|

And the "gridded" table style:

<div class="tableGridded"></div>

Item No | Name | Description | Price
--------|------|-------------|------
1       | Chair | Kitchen chair | 101.50
2       | Table | Kitchen table | 450.00
Run Code Online (Sandbox Code Playgroud)

这是结果:

在此输入图像描述

  • 这是一个很好且结构良好的答案,但针对的是不同的问题。它实际上并没有回答这个问题,这个问题具体是关于通过 pandoc 生成的 docx 输出。 (2认同)