【问题标题】:bookdown! Undefined control sequence. <recently read> \passthrough预订!未定义的控制序列。 <最近阅读> \passthrough
【发布时间】:2018-06-14 09:45:02
【问题描述】:

我发现当使用pandoc --listings 来渲染带有latex 列表包的代码块时,它会改变字符,正如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 太慢了。

【问题讨论】:

    标签: r r-markdown pandoc bookdown listings


    【解决方案1】:

    此问题与您的 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!}
    

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

    • bookdown::pdf_book中的选项template设置为null,即,

      bookdown::pdf_book:
        template: null
      

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

    • 安装rmarkdown的开发版:devtools::install_github('rstudio/rmarkdown'),其中我有added the command

    • 在自定义 Pandoc LaTeX 模板 (https://bookdown.org/yihui/bookdown/templates.html) 中定义命令 \passthrough,并通过 bookdown::pdf_book()template 选项使用自定义模板。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多