Cross-referencing a table made by texreg
in bookdown halfway works. The table is numbered properly but the cross-reference ends up as '??' in the text. A MRE is below. Is there a solution to this, or is there another package that can solve this problem (stargazer
has the same problem in bookdown). Using fig.cap
has no effect.
Thanks for any help.
---
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).