\直通,r,r-markdown,pandoc,bookdown,listings"/>

首页 > 解决方案 > 预订!未定义的控制序列。\直通

问题描述

我发现当使用pandoc --listings, 来渲染带有乳胶列表包的代码块时,它会改变字符,正如github所说,这是一个错误。所以 pandoc 引入\passthrough了处理它。

我决定将我的 pandoc 更新到最新的 2.2.1 版本。但它会弹出这样的错误,

! Undefined control sequence.
<recently read> \passthrough

我想可能是因为listings包太旧而没有\passthrough. 所以我更新到 texlive 2018。它仍然有这个问题。我在https://github.com/rstudio/bookdown/issues/591提交了这个问题

我搜索了一些结果,

但没有人能解决。有什么建议吗?谢谢你。

我想我应该自己添加这个命令。texupdate 太慢了。

标签: rr-markdownpandocbookdownlistings

解决方案


此问题与您的 LaTeX 发行版无关,因此无需重新安装或更新 LaTeX。

如果在命令行中使用了标志,Pandoc 2.x 将逐字输入\passthrough{}定义在 https://github.com/jgm/pandoc-templates/blob/052428151/default.latex#L169中。--listings

$ echo '`text`' | pandoc -f markdown -t latex --listings
\passthrough{\lstinline!text!}

一些可能的解决方案(从最简单到最难):

  • 将选项设置templatenullin bookdown::pdf_book,即

    bookdown::pdf_book:
      template: null
    

    这意味着使用 Pandoc 的内置 Pandoc 模板,该模板定义了\passthrough.

  • 安装rmarkdown :的开发版本devtools::install_github('rstudio/rmarkdown'),我在其中添加了命令

  • \passthrough在自定义 Pandoc LaTeX 模板(https://bookdown.org/yihui/bookdown/templates.htmltemplate )中定义命令,并通过bookdown::pdf_book().


推荐阅读