关于在R Markdown(PDF输出)中引用数字的问题?

问题描述 投票:0回答:1

我正在尝试将R markdown编织为pdf文档。我想自动引用我的数字,这样当我在文本中提到图1时,它可以自动指向图中的图1。

我下载了bookdown软件包,并尝试使用以下代码,因为我使用了入门指南的介绍。然而,在我编织之后,它显示了我输入的内容,而不是我希望它显示的标签。

这是我的YAML标题:

---
title: Policy Analysis
author: Me
fontsize: 12pt
output:
  pdf_document: default
  bookdown::pdf_document2: default
mainfont: Times New Roman
geometry: margin=2.54cm
subtitle: Web address
abstract: "This is an analysis"
  ---

以下是我的代码:

library('bookdown')

\@ref(fig:explore) is produced to look at each of the 9 counties and their respective air emission.

```{r explore, fig.cap="Data Exploration", fig.height = 5.5, fig.width = 9}

par(mar = c(4, 4, .1, .1))

plot(cars, pch = 19)


```

我希望它能引导我到代码chuck explore生成的图形,但文本最终仍然出现在我输入的内容中:

制作@ref(图:探索)来观察9个县中的每个县及其各自的空气排放。

基本上,@ ref(图:探索)没有做任何事情来引用这个数字。

图表如下图所示。

我的设置有什么问题吗?如果有人对此有任何想法,请告诉我。

谢谢!

r r-markdown bookdown
1个回答
1
投票

你还没有提供你的YAML标题,但我认为存在问题。它应该有以下行:

--- 
output: 
  bookdown::pdf_document2
---

如果不从包中加载模板,则无法使用bookdown的功能。

© www.soinside.com 2019 - 2024. All rights reserved.