[英]cross-reference to figure in R Markdown with html output is not working
我想在我用 R Markdown 創建的 HTML 文檔中展示一張圖片的很好的交叉引用。但是,即使我遵循交叉引用的 bookdown 部分,我也無法獲得在最終 HTML 中顯示的參考output。我在 R Studio 工作,如果有幫助的話。 .rmd 文件:
---
title: "ppp"
author: "ppp"
date: "July 4, 2017"
output:
html_document:
fig_caption: yes
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(echo = FALSE)
```
```{r foo, fig.cap="$f_{p}$ as a function of $g$ for various values of $r=\\frac{\\rho_{w}}{\\rho_{a}}$"}
# All defaults
include_graphics("download.jpg")
```
A cross-reference to figure \@ref(fig:foo).
我得到的 output 是
因此標題呈現正確,但未創建交叉引用。 我該如何解決?
我不確定。 但是你在使用bookdown
嗎? 如果您關注https://bookdown.org/yihui/bookdown/get-started.html ,並使用https://github.com/yihui/bookdown-minimal中的 bookdown 項目。 然后你應該得到你想要的結果。
例如,我使用https://github.com/yihui/bookdown-minimal並將index.Rmd
修改為這樣的內容,並且交叉引用正確顯示。
---
title: "A Book"
author: "Frida Gomam"
site: bookdown::bookdown_site
documentclass: book
output:
bookdown::gitbook: default
bookdown::pdf_book: default
---
```{r foo, fig.cap="$f_{p}$ as a function of $g$ for various values of $r=\\frac{\\rho_{w}}{\\rho_{a}}$", echo=FALSE}
# All defaults
knitr::include_graphics("download.png")
```
A cross-reference to figure \@ref(fig:foo).
更新:將 output 字段修改為bookdown::html_document2
似乎生成類似於rmarkdown::html_document
的 html 文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.