Pandoc: Long tablerows in Markdown->PDF documents do not get linewrap
Asked Answered
B

2

19

I am using Pandoc to generate markdown->DOCX documents with a lot of tables but would like better control over the layout.

I am now trying to output markdown->PDF as well, but have run into problems with table output.

In DOCX, long rows with text are simply broken up into multiple lines. In the PDF document this does not happen; a row is always a single line that do not wrap at the right margin but continue outside of the page. Normal paragraph text flows according to the right margin, so the problem is probably not the page size.

Example 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. 

Resulting PDF Resulting PDF

How do I enable line-wrapping in PDF tables?

Bride answered 30/7, 2014 at 12:52 Comment(0)
D
13

Pipe tables don't wrap in LaTeX/PDF output. Use multiline or grid tables, as described in the pandoc User's Guide. This will also give you control over relative widths of columns.

Daynadays answered 31/7, 2014 at 3:41 Comment(4)
Thanks a lot, the doc mentions "Multiline tables allow headers and table rows to span multiple lines of text" but I thought this was to enable multiple lines in the Markdown source, and not the output. Maybe this can be made clearer, as HTML and DOCX output seem to do this anyway.Bride
Yes, it could be made clearer. The issue is that LaTeX (unlike the other formats) requires explicit specification of column widths if you want the cells to wrap, and that information is not available in pipe tables where all the content is on one line.Daynadays
My tables go off page on the bottom, past the bottom margin and page number. Is there a way to make sure tables are pushed to the next page without using page breaks?Aude
This seems not to work anymore in pandoc 2.7.3. The generated (La)Tex looks fine (includes relative column widths, but the resulting PDF puts everything on one line regardless.Jujitsu
U
-1

I don't know why but it work:

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

(set columns a very small value then 72) the pipe table will wrap.

Unfasten answered 2/11, 2021 at 9:41 Comment(1)
If you have another problem, ask a new question instead of posting it as answer :)Cappella

© 2022 - 2024 — McMap. All rights reserved.