将 Pandoc 与 Markdown 一起使用时出现紧缩列表错误

tightlist error using Pandoc with Markdown

我在 Mac OS 10.12 上使用 pandoc v. 1.18 将此 markdown 文件转换为 pdf,使用一个简单的命令行:

# A list that does not work
- one
- two
- three

我得到这个错误:

! Undefined control sequence.
l.53 \tightlist

pandoc: Error producing PDF

如何解决?

\tightlist 是在 pandoc 1.14 中引入的(请参阅以前版本的 this commit). The most probable cause for this error is that you are using a template 并且没有更新它。这可以通过在乳胶模板中添加几行来解决。它们可以是在 $DATA-DIR/templates/default.latex 找到常规乳胶,在 $DATA-DIR/templates/default.beamer 找到 beamer。您需要添加这两行(在 \begin{document} 之前):

\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}

为了确保这种情况不会在模板的未来发展中再次发生,最好分叉 pandoc-templates repository