Rmarkdown with html,如何引用数字?
Rmarkdown with html, how to reference figures?
使用 RMarkdown 我总是通过 Rmd -> pandoc -> TeX -> pdflatex -> pdf 生成 pdf 文档,并在 fig.cap
中使用 \label{something}
完成图形引用,如下例所示:
---
title: "Foo"
author: "Mark Andrews"
date: "10 January 2019"
output: pdf_document
---
See Figure \ref{figfoo} and see Figure \ref{figbar}.
```{r fig1, fig.cap='A figure\label{figfoo}'}
plot(rnorm(10))
```
```{r fig2, fig.cap='Another figure\label{figbar}'}
plot(rnorm(10))
```
如果我将 output: pdf_document
更改为 output: html_document
,那将不起作用,这是可以理解的,因为它依赖于 LaTeX 的交叉引用系统。
那么在 RMarkdown 中 Figure 引用如何与 html_document
一起使用?
以下不起作用:
---
title: "Foo"
author: "Mark Andrews"
date: "10 January 2019"
output: html_document
---
See Figure \@ref(fig:fig1) and see Figure \@ref(fig:fig2).
```{r fig1, fig.cap='A figure}'}
plot(rnorm(10))
```
```{r fig2, fig.cap='Another figure'}
plot(rnorm(10))
```
但以下确实有效:
---
title: "Foo"
author: "Mark Andrews"
date: "10 January 2019"
output: bookdown::html_document2
---
See Figure \@ref(fig:fig1) and see Figure \@ref(fig:fig2).
```{r fig1, fig.cap='A figure}'}
plot(rnorm(10))
```
```{r fig2, fig.cap='Another figure'}
plot(rnorm(10))
```
这是否意味着在从 Rmarkdown 生成 html 时交叉引用数字的唯一方法是使用 output: bookdown::html_document2
。如果是这样,那很好,但是我是否遗漏了什么?
听过 Yihui Xie 的说法,我想我们可以理所当然地认为,是的,在 rmarkdown 中 html_document 中进行图形交叉引用的唯一方法是
---
output: bookdown::html_document2
---
在header。
使用 RMarkdown 我总是通过 Rmd -> pandoc -> TeX -> pdflatex -> pdf 生成 pdf 文档,并在 fig.cap
中使用 \label{something}
完成图形引用,如下例所示:
---
title: "Foo"
author: "Mark Andrews"
date: "10 January 2019"
output: pdf_document
---
See Figure \ref{figfoo} and see Figure \ref{figbar}.
```{r fig1, fig.cap='A figure\label{figfoo}'}
plot(rnorm(10))
```
```{r fig2, fig.cap='Another figure\label{figbar}'}
plot(rnorm(10))
```
如果我将 output: pdf_document
更改为 output: html_document
,那将不起作用,这是可以理解的,因为它依赖于 LaTeX 的交叉引用系统。
那么在 RMarkdown 中 Figure 引用如何与 html_document
一起使用?
以下不起作用:
---
title: "Foo"
author: "Mark Andrews"
date: "10 January 2019"
output: html_document
---
See Figure \@ref(fig:fig1) and see Figure \@ref(fig:fig2).
```{r fig1, fig.cap='A figure}'}
plot(rnorm(10))
```
```{r fig2, fig.cap='Another figure'}
plot(rnorm(10))
```
但以下确实有效:
---
title: "Foo"
author: "Mark Andrews"
date: "10 January 2019"
output: bookdown::html_document2
---
See Figure \@ref(fig:fig1) and see Figure \@ref(fig:fig2).
```{r fig1, fig.cap='A figure}'}
plot(rnorm(10))
```
```{r fig2, fig.cap='Another figure'}
plot(rnorm(10))
```
这是否意味着在从 Rmarkdown 生成 html 时交叉引用数字的唯一方法是使用 output: bookdown::html_document2
。如果是这样,那很好,但是我是否遗漏了什么?
听过 Yihui Xie 的说法,我想我们可以理所当然地认为,是的,在 rmarkdown 中 html_document 中进行图形交叉引用的唯一方法是
---
output: bookdown::html_document2
---
在header。