r - 交叉引用和标题在 Rmd 文件中不起作用
问题描述
任何人都可以帮助我了解如何编写我的标题,以便图形标题和交叉引用有效吗?
我正在练习制作标题并交叉引用我的 Rmd 文件中的一个简单图。我知道要这样做,我应该在标题中添加:“输出:bookend::pdf_document2”和“fig_caption = yes”。然后,在一个名为 myfigure 的块中,我应该添加“fig.cap =”\label{fig:myfigure} My caption”。要交叉引用这个图,我应该在文本中写入“@ref(fig:myfigure)”。我的代码如下。它不会编织,因为标题的格式错误。
---
title: "knit"
author: "Chase Hommeyer"
date: "4/1/2019"
output: bookdown::pdf_document2
toc: true
fig_caption: yes
---
```{r myfigure, fig.cap = "\\label{fig:myfigure} My caption"}
plot(pressure)
```
My plot is called \@ref(fig:myfigure).
然后,我尝试删除 toc 和 fig_caption 之前的空格,它编织,但没有出现标题,并且文本字面上打印“@ref(fig:myfigure)”而不是交叉引用。我试过的标题在这里:
---
title: "knit"
author: "Chase Hommeyer"
date: "4/1/2019"
output: bookdown::pdf_document2
toc: true
fig_caption: yes
---
我还尝试将“pdf_document:”添加到标题中,但同样的问题是没有标题,并且交叉引用实际上是“@ref(fig:myfigure)”。我试过的这个标题在这里:
---
title: "knit"
author: "Chase Hommeyer"
date: "4/1/2019"
output: bookdown::pdf_document2
pdf_document:
toc: true
fig_caption: yes
---
任何人都可以帮助我了解如何编写我的标题以使其正常工作吗?
解决方案
使用\ref{fig:myfigure}
而不是\\@ref(fig:myfigure)
请参阅RStudio 社区帖子
推荐阅读
- kernel - 什么是 Solarflare Onload 堆栈以及它与它们的虚拟接口有何关系
- android - 不确定如何将 Cursor 转换为此方法的返回类型
- linux - rabbitmq 集群不匹配主机名问题
- python - 如何在 VS Code 中使用 unittest.TestSuite?
- php - 当插入的值与表中的列数不匹配时,使用 PHP 将数据插入到 MySQL 表中
- javascript - 在 node.js 中,在工作表继承下将 .connection.destroy() 提供给 res 对象
- sql - 一张表上的 DB2 CTE 递归,6 级
- javascript - 在 Laravel 5.7 中以 'State' -> 'City' -> 'Municipality' 方式进行依赖输入
- python - 使用 Python 中的线程无法识别数据类型
- unix - 将参数传递给 CURL GET 调用