[英]Rmarkdown, bookdown, texreg and cross-referencing
在 bookdown 中途交叉引用texreg
制作的表格。 该表已正确编号,但交叉引用最终为“??” 在文中。 下面是一个 MRE。 是否有解决方案,或者是否有另一个包可以解决这个问题( stargazer
在 bookdown 中也有同样的问题)。 使用fig.cap
没有效果。
谢谢你的帮助。
---
title: "bookdownTest"
author: "Richard Sherman"
date: "1/9/2020"
output:
bookdown::pdf_document2:
fig_caption: yes
toc: false
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r load libraries, include=FALSE}
library(texreg)
library(bookdown)
```
```{r lm, results='asis', star.symbol = "\\*", center = TRUE}
m1 <- lm(mpg ~ disp + cyl + hp, mtcars)
m2 <- lm(mpg ~ disp + hp, mtcars)
texreg(list(m1, m2), center = TRUE,
caption="Linear model of mpg")
```
Results are in Table \@ref(tab:lm).
texreg()
有一个标签选项,可以让你设置标签,所以你可以这样做:
texreg(list(m1, m2), center = TRUE,
caption="Linear model of mpg",
label="tab:lm")
您可能一直依赖bookdown 文档中描述的自动表格标签,但这仅在使用knitr::kable()
函数生成表格时才有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.