【问题标题】:Horizontal rule in R Markdown / Bookdown causing errorsR Markdown / Bookdown中的水平规则导致错误
【发布时间】:2020-02-23 12:59:50
【问题描述】:

突然,我在 Markdown/Bookdown 中编织 PDF 时遇到错误。我的系统没有任何改变。

该错误是由“水平规则”引起的,即 --- 或 *** 在 markdown 中的任何位置,尽管两边有行空格。

我包含一个简单的违规示例 --- 不会编织到 PDF。

顺便说一句,编织到另一种格式不会导致问题,并且编织到 PDF 没有水平线不会产生错误。此外,将 --- 换成 *** 以探索这是否解决了错误。它没有。

有人可以提供任何见解吗?

分别使用 TinyTex 和 MikteX(不一起安装)。既不能解决问题。 才遇到这个问题。以前没有问题的文件现在在遇到 --- 或 *** 时会失败。


## R Markdown

Some text, then I want horizontal rule

---

Some text after the horizonatal rule.



! Missing number, treated as zero.
<to be read again> 
                   \protect 
l.146 ...nter}\rule{0.5\linewidth}{\linethickness}
                                                  \end{center} 

Error: Failed to compile K.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See K.log for more info.
Execution halted

【问题讨论】:

  • 仅供参考,我刚刚在 rmarkdown 中解决了这个问题:github.com/rstudio/rmarkdown/commit/…。如果您安装 rmarkdown 的开发版本,或者等待 rmarkdown 的下一个 CRAN 版本,问题应该会消失。谢谢!

标签: r r-markdown bookdown


【解决方案1】:

所以,一个对我有用的临时解决方案是:

\begin{center}\rule{3in}{0.4pt}\end{center}

用这个代替---***

【讨论】:

    【解决方案2】:

    更新:此问题已在 rmarkdown v2.1 中修复,如果您(重新)安装来自 CRAN 的最新版本的 rmarkdown,该问题应该会消失。


    这是 pandoc 中一个已知且已修复的错误。 https://github.com/jgm/pandoc/issues/5801

    它发生在较新版本的 TexLive 上。

    这将在下一个 pandoc 版本中修复。您必须等待或使用每晚构建。

    您现在也可以通过在 tex 文档的标题中添加它来使用一个技巧。

    \renewcommand{\linethickness}{0.05em}
    

    使用 rmarkdown 你可以做到

    ---
    title: "Untitled"
    output: 
      pdf_document:
        keep_tex: true
        includes:
          in_header: header.tex
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = TRUE)
    ```
    
    
    ```{cat, engine.opts = list(file = "header.tex")}
    \renewcommand{\linethickness}{0.05em}
    ```
    
    
    lalalala
    
    ---
    
    lilili
    

    您也可以手动编写header.tex 文件,或将其添加到您的模板中。

    这对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 2014-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-24
      相关资源
      最近更新 更多