papaja 和文本参考编织到 word

papaja and text references knitting to word

我正在尝试为 table 和数字创建文本引用。但是,我确实按照文档中的示例让它工作。使用这两种方法既没有文本参考也没有 table 标题。这是一些示例脚本。

    # 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)")
    ```

热烈欢迎提示。

詹斯

以下代码应该有效:

    # 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)")
    ```

那么为什么您的代码不起作用?

  • 如果您想通过文本引用向 table 添加标题,请在对 apa_table() 的调用中添加类似 caption = "(ref:caption-name)" 的内容(块选项 tab.cap不工作)
  • 当您使用交叉引用(即 "see Table 1 and 2")时,请使用 \@ref(tab:chunk-name)——在您的示例中您的块名称是 ANOVAIANOVAII,因此它必须是 \@ref(tab:ANOVAI)\@ref(tab:ANOVAII)

希望对您有所帮助!

如需进一步阅读,papaja 手册的相关部分位于此处: