如果fig.retina不是1

时间:2015-05-17 09:51:57

标签: r knitr r-markdown

我在使用R Markdown生成的html文档中遇到图标题问题。如果我没有指定fig.retina选项,或者我将其设置为1,则输出文档具有数字标题。但是,如果我将其设置为不是1的值,则会丢失未来的标题,但其文本将作为图形的替代文本显示。如何保留数字标题?

一个例子:

---
title: "Example"
output:
  html_document:
    fig_caption: yes
    fig_retina: 2
---


Text text text

```{r fig.cap="Figure 1. Some random numbers"}
plot(rnorm(25),runif(25)) 
```

渲染给出一个没有数字标题的文档,但是如果我将fig.retina的值更改为1,我会得到一个数字标题。如果我在块中设置fig.retina而不是全局,也会发生同样的事情。

1 个答案:

答案 0 :(得分:1)

以下是相关文档

#' @param fig_retina Scaling to perform for retina displays (defaults to 2 when
#'   \code{fig_caption} is \code{FALSE}, which currently works for all widely
#'   used retina displays). Set to \code{NULL} to prevent retina scaling. Note
#'   that this will always be \code{NULL} when \code{keep_md} is specified (this
#'   is because \code{fig_retina} relies on outputting HTML directly into the
#'   markdown document).
#' @param fig_caption \code{TRUE} to render figures with captions

因此,如果您没有指定默认值为2.我确实发现如果我将代码更改为

---
title: "Example"
output:
  html_document:
    fig_caption: yes

---


Text text text

```{r fig.cap="Figure 1. Some random numbers"}
plot(rnorm(25),runif(25)) 
```

它显示了标题。

<强>更新

环顾四周之后我发现了这个

  

注意块选项fig.retina = 1:没有它,rmarkdown :: render()   将生成Retina显示的图,这意味着图   用原始<img>代码而不是![]()编写,而Pandoc则不会   能够在这种情况下生成数字标题。

所以你可能需要使用正常的降价来为标题添加html。