retina不为1时如何在R

retina不为1时如何在R

本文介绍了当fig.retina不为1时如何在R Markdown中保留图形标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having trouble with figure captions in html documents generated using R Markdown. If I don't specify the fig.retina option, or if I set it to 1, the output document has a figure caption. If I set it to a value that isn't 1, however, the future caption is missing but the text for it is present as the alt text for the figure. How can I keep the figure captions?

一个例子:

---
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,也会发生同样的事情.

Renders to give a document with no figure caption, but if I change the value for fig.retina to 1 I get a figure caption. The same thing happens if I set fig.retina in the chunk rather than globally.

推荐答案

以下是相关文档

#' @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.我确实发现,如果我将代码更改为

So if you don't specify the default will be 2. I did find that if I changed your code to

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

---


Text text text

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

它显示了标题.

更新

环顾四周后,我发现了

因此,您可能只需要使用普通的markdown来为标题添加html.

So probably you need to just use normal markdown for adding html for the caption.

这篇关于当fig.retina不为1时如何在R Markdown中保留图形标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 18:44