gpt4 book ai didi

pdf - Pandoc Markdown 到 Latex PDF : table with alternating row colors?

转载 作者:行者123 更新时间:2023-12-04 01:19:02 30 4
gpt4 key购买 nike

我想要一个表格,在通过 pandoc 的 Markdown 文档的 (xe)latex PDF 输出中,具有交替的行颜色 - 如此处所述:

https://tex.stackexchange.com/questions/518097/booktabs-but-with-enclosing-border-around-the-table

... and xcolor with the table option to add alternating row colors

所以,我正在尝试这个 test.md:

---
title: "Testing"
author: Bob Alice
date: July 13, 2010
geometry: margin=2cm
documentclass: extarticle
fontsize: 12pt
header-includes: |
\usepackage[table]{xcolor}
\rowcolors{2}{white}{gray!25}
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

...结果是:

Error producing PDF.
! LaTeX Error: Option clash for package xcolor.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.60 \rowcolors

因此,显然 xcolor 在此设置中加载了其他选项,这些选项与 [table] 选项冲突。

是否可以在不使用自定义模板的情况下诱导 pandoc 生成具有交替行颜色的 Latex/PDF 文档中的所有表格?

最佳答案

感谢 @user1759789 在评论中的链接,似乎传递 Latex 文档类选项 table 就足够了,然后传递给 xcolor when已加载;请注意,如果您离开 \usepackage[table]{xcolor} 行,代码仍会生成此错误。所以有效的 Markdown 是这样的:

---
title: "Testing"
author: Bob Alice
date: July 13, 2010
geometry: margin=2cm
classoption: table
documentclass: extarticle
urlcolor: blue
fontsize: 12pt
header-includes: |
\rowcolors{2}{gray!10}{gray!25}
output: pdf_document
---

Here is a test of a table ( [buggy](https://stackoverflow.com/questions/62835496/) ):

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

and another grid 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 |
+----------+-------------------+-----------------+

and pipe 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 |

...输出为:

test.pdf

关于pdf - Pandoc Markdown 到 Latex PDF : table with alternating row colors?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62875350/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com