I am trying to create text references for tables and figures. However, I do get it to work following the examples in the documentation. There is neither a text reference nor a table caption using either approach. Here is some example script.
# Results
See Table \@ref(tab:ResultsANOVAI) or Table \@ref(tab:ResultsANOVAII) for ANOVA results. They show that ...
(ref:ResultsANOVAI) Results ANOVA I
```{r ANOVAI, warning=FALSE, tab.cap='(ref:ResultsANOVAI)'}
library(afex)
daten <- data.frame(vp = rep(1:30, each = 6),
cond1 = rep(1:3, each = 2),
cond2 = rep(1:2),
rt = rnorm(180, 600, 100))
aov.res <- aov_ez("vp", "rt", daten, within = c("cond1", "cond2"))
apa_anova <- apa_print.afex_aov(aov.res)
apa_table(apa_anova$table)
```
A little bit of text after the table.
(ref:ResultsANOVAI) Results ANOVA II
```{r ANOVAII, warning=FALSE}
apa_anova <- apa_print.afex_aov(aov.res)
apa_table(apa_anova$table,
caption = "(ref:ResultsANOVAII)")
```
Hints are heartly welcome.
Jens
the following code should work:
# Results
See Table \@ref(tab:ANOVAI) or Table \@ref(tab:ANOVAII) for ANOVA results. They show that ...
(ref:ResultsANOVAI) Results ANOVA I
```{r ANOVAI, warning=FALSE}
library(afex)
daten <- data.frame(vp = rep(1:30, each = 6),
cond1 = rep(1:3, each = 2),
cond2 = rep(1:2),
rt = rnorm(180, 600, 100))
aov.res <- aov_ez("vp", "rt", daten, within = c("cond1", "cond2"))
apa_anova <- apa_print.afex_aov(aov.res)
apa_table(apa_anova$table, caption = "(ref:ResultsANOVAI)")
```
A little bit of text after the table.
(ref:ResultsANOVAII) Results ANOVA II
```{r ANOVAII, warning=FALSE}
apa_anova <- apa_print.afex_aov(aov.res)
apa_table(apa_anova$table,
caption = "(ref:ResultsANOVAII)")
```
So why did your code not work?
caption = "(ref:caption-name)"
to your call to apa_table()
(the chunk option tab.cap
does not work)\@ref(tab:chunk-name)
-- your chunk names are ANOVAI
and ANOVAII
in your example, so it has to be \@ref(tab:ANOVAI)
and \@ref(tab:ANOVAII)
Hope this helps!
For further reading, the relevant parts of the papaja
manual are here: