R Bookdown:另一个文件中的交叉参考图形
我已经下了决心,正在准备一份手稿,完全用bookdown在RStudio上发表。在正文中,我想在一个单独的支持信息.Rmd文件中交叉引用一些数字 假设这是我的主文本文件,名为R Bookdown:另一个文件中的交叉参考图形,r,r-markdown,bookdown,cross-reference,literate-programming,R,R Markdown,Bookdown,Cross Reference,Literate Programming,我已经下了决心,正在准备一份手稿,完全用bookdown在RStudio上发表。在正文中,我想在一个单独的支持信息.Rmd文件中交叉引用一些数字 假设这是我的主文本文件,名为main.Rmd: --- title: "Main text" output: bookdown::pdf_book: toc: no --- Here is the main text file. I would like to refer to \@ref(fig:supporting-figure).
main.Rmd
:
---
title: "Main text"
output:
bookdown::pdf_book:
toc: no
---
Here is the main text file. I would like to refer to \@ref(fig:supporting-figure).
以下是保存在同一文件夹中的名为supporting.Rmd
的支持文本和参考图:
---
title: "Supporting info"
output:
bookdown::pdf_book:
toc: no
---
Here is the supporting text.
```{r supporting-figure}
plot(cars)
```
如何在正文中交叉引用支持图
我已经查看了易慧的交叉引用部分,但我看不出如何将其扩展到文件之间的交叉引用
我还发现了这个问题:
但是被接受的答案对我来说并不适用(可能是因为我使用的是bookdown而不是base Rmarkdown?我不完全确定您是如何将这两个文件编译成一个bookdown文档的,因为目前它们只是两个独立的R Markdown文档。但有两个问题:
fig.cap
的图形,如下所示:
如果我们通过chunk选项为代码块分配一个图形标题
fig.cap,R图将放入figure环境中,该环境将
自动标记和编号,也可以交叉引用
bookdown
正确配置项目:
- 主文件应称为
index.Rmd
- 支持文件不应包含任何YAML
- 您应该在主文档的YAML中包括
site:bookdown::bookdown\u site
解决方案 指数.Rmd
---
title: "Main text"
site: bookdown::bookdown_site
output:
bookdown::pdf_book:
toc: no
---
Here is the main text file. I would like to refer to \@ref(fig:supporting-figure).
Here is the supporting text.
```{r supporting-figure, fig.cap= "Some Figure"}
plot(cars)
```
支持.Rmd
---
title: "Main text"
site: bookdown::bookdown_site
output:
bookdown::pdf_book:
toc: no
---
Here is the main text file. I would like to refer to \@ref(fig:supporting-figure).
Here is the supporting text.
```{r supporting-figure, fig.cap= "Some Figure"}
plot(cars)
```
我不完全确定您是如何将这两个文件编译成一个单独的bookdown文档的,因为目前它们只是两个单独的R Markdown文档。但有两个问题:
fig.cap
的图形,如下所示:
如果我们通过chunk选项为代码块分配一个图形标题
fig.cap,R图将放入figure环境中,该环境将
自动标记和编号,也可以交叉引用
bookdown
正确配置项目:
- 主文件应称为
index.Rmd
- 支持文件不应包含任何YAML
- 您应该在主文档的YAML中包括
site:bookdown::bookdown\u site
解决方案 指数.Rmd
---
title: "Main text"
site: bookdown::bookdown_site
output:
bookdown::pdf_book:
toc: no
---
Here is the main text file. I would like to refer to \@ref(fig:supporting-figure).
Here is the supporting text.
```{r supporting-figure, fig.cap= "Some Figure"}
plot(cars)
```
支持.Rmd
---
title: "Main text"
site: bookdown::bookdown_site
output:
bookdown::pdf_book:
toc: no
---
Here is the main text file. I would like to refer to \@ref(fig:supporting-figure).
Here is the supporting text.
```{r supporting-figure, fig.cap= "Some Figure"}
plot(cars)
```
如果您打算编译两个不同的PDF,我遇到了相同的问题,并提出了此解决方案。它依赖于LaTeX的xr包进行交叉引用:如果您打算编译两个不同的PDF,我遇到了相同的问题并提出了此解决方案。它依赖于LaTeX的xr软件包进行交叉引用:
站点:bookdown::bookdown\u站点
已就位!终于明白为什么不把它删掉了。site:bookdown::bookdown\u site
!终于明白为什么不删掉它了。