Pandoc: Markdown转PDF文档中的长表行没有换行

16

我正在使用Pandoc生成包含大量表格的Markdown->DOCX文档,但希望对布局有更好的控制。

现在我也尝试将Markdown->PDF输出,但遇到了表格输出问题。

在DOCX中,具有文本的长行仅被分成多行。但在PDF文档中,这种情况不会发生;一行始终是单行,不会在右边跨行,而是继续超出页面。正常段落文本根据右边距流动,因此问题可能不是页面大小导致的。

示例Markdown:

This is text that flows according to the page limits. This is text that flows according to the page limits. This is text that flows according to the page limits. 
This is text that flows according to the page limits. This is text that flows according to the page limits. 

| Version | Date  | Comment |
|--------:|-------|---------|
| 1.0.0     | 07.04.2014 | This is a table row that does not flow with the page limits. This is a table row that does not flow with the page limits. |
| 2.0.0     | 07.04.2014 | This is a table row that does not flow with the page limits. This is a table row that does not flow with the page limits. |

This is text that flows according to the page limits. This is text that flows according to the page limits. This is text that flows according to the page limits. 
This is text that flows according to the page limits. This is text that flows according to the page limits. 

生成的PDF 生成的PDF

如何在PDF表格中启用自动换行?

2个回答

13

管道表在LaTeX/PDF输出中不会换行。请使用多行或网格表,如pandoc用户指南中所述。这也将使您控制列的相对宽度。


1
非常感谢,文档中提到“多行表格允许标题和表格行跨越多行文本”,但我认为这是为了在Markdown源中启用多行,而不是输出。也许可以更清楚地说明一下,因为HTML和DOCX输出似乎已经实现了这一点。 - Karl Ivar Dahl
1
是的,它可以更清晰地表达。问题在于LaTeX(与其他格式不同)需要明确指定列宽,如果您希望单元格换行,而在管道表中,所有内容都在一行上,这些信息是不可用的。 - John MacFarlane
我的表格超出了页面底部,超过了底部边距和页码。有没有办法确保表格被推到下一页而不使用分页符? - tonyslowdown
这似乎在pandoc 2.7.3中不再起作用。生成的(La)Tex看起来很好(包括相对列宽),但是生成的PDF将所有内容放在一行上。 - hoijui

0

我不知道为什么,但它有效:

pandoc --columns=10 src.md -o tgt.pdf

(将列设置为非常小的值,然后为72)管道表将自动换行。


如果您有其他问题,请提出一个新的问题,而不是将其发布为答案 :) - Elikill58

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接