为什么\@ref()
符号无法与投影仪演示一起操作?
下面的问题可能会提醒您在编写PDF文档时交叉引用的一些问题,例如:this,但是当我进行投影仪演示时,答案中介绍的方法对我没有帮助。
现在我很困惑因为\@ref(fig:label-to-refer-figure)
and \@ref(tab:label-to-refer-table)
当我编织时,引用图形/表格的符号不起作用.Rmd
带有选项的文件output: beamer_presentation
。如下图所示,交叉引用的原始代码出现在输出的 PDF 文件中,但我无法引用图/表编号。尽管即使在列出的环境以及纯文本字段中,引文也能顺利进行,但图/表编号的交叉引用无法正确生效。
我的环境
- R版本3.5.1 (2018-07-02)
- 平台:x86_64-w64-mingw32/x64(64位)
- 运行环境:Windows 10 x64(内部版本 17134)
- knitr_1.20
- rmarkdown_1.10
-
RStudio v1.2.1206(预览版)这个原因
MWEs
我在此处发布的 MWE 是根据以下来源创建的:test-beamer.Rmd
and myref.bib
.
test-beamer.Rmd
---
title: "Test"
subtitle: |
| subtitle,
| with a line break
author: |
| CLR
| Rafael
institute: |
| Now I'm here,
| Now I'm there
date: "`r format(Sys.time(), '%Y/%b/%d')`" #English
output:
beamer_presentation:
keep_tex: yes
latex_engine: lualatex
theme: "AnnArbor"
colortheme: "dolphin"
fonttheme: "structurebold"
toc: true
#toc_depth: 3
#number_sections: TRUE
fig_caption: TRUE
dev: cairo_pdf
#extra_dependencies: subfig
citation_package: natbib
slide_level: 2
bibliography: bibs/myref.bib
biblio-style: apa
always_allow_html: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## The only thing
With Table \@ref(tab:under-pressure-table), @test-master shows that Figure \@ref(fig:under-pressure) depicts...
## Slide with Bullets in which I want to refer a figure
- \@ref(fig:under-pressure)
- @test-master
- \@ref(tab:under-pressure-table)
## Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
## Slide with Plot
```{r under-pressure, fig.cap='Under Pressure', fig.pos='h', out.width="0.75\\textwidth"}
plot(pressure)
```
## Slide with Table
```{r under-pressure-table, caption = "This is a table"}
knitr::kable(pressure)
```
## More extraordinary
With Table \@ref(tab:under-pressure-table), @test-master shows that Figure \@ref(fig:under-pressure) depicts...
编辑:我添加了fig.cap='Under Pressure', fig.pos='h', out.width="0.75\\textwidth"
到图形块,并且caption = "This is a table"
to the knitr::kable()
。如果没有这些代码,标题和表格/图号都不会出现...但是,即使将它们提供给整个系统,问题仍然存在.Rmd
文件,除非你执行@Yihui的回答。
myref.bib
@master{test-master,
author = {Freddie Mercury and Brian May and John Deacon and Roger Taylor},
title = {Bohemian {R}hapsody: {W}e are the champions},
school = {{Queen}},
year = {2018},
address = {London}
}