【发布时间】:2020-12-14 15:29:33
【问题描述】:
问题
我有一个包含 Markdown 和 LaTex 组合的文件,我想将其转换为 PDF。 Pandoc 似乎可以在 Ubuntu 20.04 中工作,但不能在 Debian 10 中工作。
我的安装
# Installing Pandoc and dependencies
apt-get install pandoc texlive-xetex texlive-latex-recommended
我的降价
我在一个名为 test.md 的文件中有以下文本:
\centerline{\Large{\textbf{Test 1}}}
\colorbox{blue!25}{\Large{\textbf{Test 2}}}
**This is a test**
转化
# Conversion
pandoc -V geometry:margin=0.7in -s test.md -o output.pdf
在 Ubuntu 20.04 中,我生成了一个漂亮的 PDF。
在 Debian 10 (Docker) 中,我收到以下错误:
! Undefined control sequence.
l.62 \colorbox
我是否缺少 Debian 10 中的一些依赖项?有没有办法查看默认使用的 Pandoc 引擎?我做错了什么?
当运行详细模式时,安装似乎使用不同的引擎,但是,当我指定几何驱动程序以使其相同时,问题仍然存在。
# Debian 10
*geometry* driver: auto-detecting
*geometry* detected driver: xetex
# Ubuntu 20.04
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
更新:解决方法
阅读了几篇关于类似问题的帖子,我首先尝试将 \usepackage{xcolor} 添加到文档的开头,但这没有用。然后我发现你必须添加一个 YAML-header 然后它才能工作。然而,最初的问题仍然让我感到困惑。
# Adding this to the start of the document fixed the problem
---
header-includes:
- \usepackage{xcolor}
output:
pdf_document
---
【问题讨论】:
标签: pdf debian latex markdown pandoc