问题
Consider this example for test.md
Markdown file:
---
title: "Testing"
author: Bob Alice
date: July 07, 2010
geometry: margin=2cm
documentclass: extarticle
fontsize: 12pt
output: pdf_document
---
Here is a test of a table:
+----------+-------------------+-----------------+
| Box name | Another parameter | The IP address |
+==========+===================+=================+
| Test 1 | random-string-01 | 10.0.0.20 |
| Test 2 | random-string-02 | 10.0.0.30 |
+----------+-------------------+-----------------+
If I convert this via pandoc:
$ pandoc --version
pandoc.exe 2.10 ...
... with:
pandoc test.md --pdf-engine=xelatex -o test.pdf
... the result is:
That is to say, "Test 1" and "Test 2" were compacted into a single row - even if the documentation is explicit about grid_tables
:
https://pandoc.org/MANUAL.html#tables
Pandoc does not support grid tables with row spans or column spans. This means that neither variable numbers of columns across rows nor variable numbers of rows across columns are supported by Pandoc. All grid tables must have the same number of columns in each row, and the same number of rows in each column.
So, I can't really see how come it managed to merge these rows into one.
Is it possible to get pandoc -> latex -> pdf to keep "Test 1" and "Test 2" in each their own cell? And is it possible to get rid of the blank vertical space at the bottom of the table?
回答1:
Grid tables use explicit vertical lines to separate rows. The fact that there are line breaks in the other cells is incidental, as the contents don't fit into a single line.
Use this instead:
+----------+-------------------+-----------------+
| Box name | Another parameter | The IP address |
+==========+===================+=================+
| Test 1 | random-string-01 | 10.0.0.20 |
+----------+-------------------+-----------------+
| Test 2 | random-string-02 | 10.0.0.30 |
+----------+-------------------+-----------------+
来源:https://stackoverflow.com/questions/62835496/pandoc-markdown-to-latex-pdf-table-merges-rows-in-single-row