我想通过pandoc
在Markdown文档的(xe)latex PDF输出中创建一个表格,并使用交替的行颜色-如此处所述:
https://tex.stackexchange.com/questions/518097/booktabs-but-with-enclosing-border-around-the-table
...和
xcolor
和table
选项添加交替的行颜色
所以,我正在尝试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文档中具有交替行颜色的所有表格-无需使用自定义模板?
答案 0 :(得分:1)
通过@ user1759789在注释中的链接,似乎足以传递Latex文档类选项table
,然后在加载时将其传递给xcolor
;请注意,如果您离开\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 |
...,输出为: