【问题标题】:Pandoc Markdown to Latex PDF: table merges rows in single row?Pandoc Markdown to Latex PDF:表格合并单行中的行?
【发布时间】:2020-07-10 13:36:42
【问题描述】:

test.md Markdown 文件为例:

---
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 |
+----------+-------------------+-----------------+

如果我通过 pandoc 进行转换:

$ pandoc --version
pandoc.exe 2.10 ...

...与:

pandoc test.md --pdf-engine=xelatex -o test.pdf

...结果是:

也就是说,“Test 1”和“Test 2”被压缩成一行——即使文档明确提到了grid_tables

https://pandoc.org/MANUAL.html#tables

Pandoc 不支持具有行跨度或列跨度的网格表。这意味着 Pandoc 不支持跨行的可变列数和跨列的可变行数。所有网格表的每一行中的列数必须相同,并且每列中的行数必须相同。

所以,我真的不明白它是如何将这些行合并为一个的。

是否有可能让 pandoc -> latex -> pdf 在各自的单元格中保留“测试 1”和“测试 2”?以及是否可以摆脱表格底部的空白垂直空间?

【问题讨论】:

    标签: pdf latex markdown pandoc


    【解决方案1】:

    Grid tables 使用明确的垂直线来分隔行。其他单元格中有换行符的事实是偶然的,因为内容不适合单行。

    改用这个:

    +----------+-------------------+-----------------+
    | 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 |
    +----------+-------------------+-----------------+
    

    【讨论】:

    • 谢谢 - 效果很好;虽然每行文字下方都有相当多的垂直空间:i.stack.imgur.com/UMoKq.png
    • 造成这种情况的原因是IP地址缩进超过4个空格,导致pandoc将它们视为代码块。在= 行中使用: 字符表示对齐。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-26
    • 2011-01-14
    • 1970-01-01
    • 2021-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多