Skip to content

Duplicated Figure/Table labels in word_document2 #1223

@dewittpe

Description

@dewittpe

I have taken the example .Rmd file from the cross-ref
documentation and added bookdown::word_document2: default in the yaml header.

--- title: Cross-referencing figures, tables, and equations author: Generated by bookdown output: bookdown::word_document2: default bookdown::pdf_document2: default bookdown::html_document2: default --- See Figure \@ref(fig:cars-plot). ```{r cars-plot, fig.cap="The cars data.", echo=FALSE} par(mar = c(4, 4, .2, .1)) plot(cars) # a scatterplot ``` Also see Equation \@ref(eq:mean). \begin{equation} \bar{X} = \frac{\sum_{i=1}^n X_i}{n} (\#eq:mean) \end{equation} And see Table \@ref(tab:mtcars). ```{r mtcars, echo=FALSE} knitr::kable(mtcars[1:5, 1:5], caption = "The mtcars data.") ``` 

The example renders as expected when generating a pdf, but, when using the dropdown options in RStudio to knit to word_document2 the resulting .docx file has the labels for the figure and table duplicated.

Expected "Figure 1: The cars data", observed: "Figure 1: Figure 1: The cars data."

image

A similar issue for the Table.

> rmarkdown::pandoc_version() [1] ‘2.14.1> xfun::session_info("bookdown") R version 4.1.0 (2021-05-18) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Big Sur 11.3.1, RStudio 1.4.1717 Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8 Package version: base64enc_0.1.3 bookdown_0.22.17 digest_0.6.27 evaluate_0.14 glue_1.4.2 graphics_4.1.0 grDevices_4.1.0 highr_0.9 htmltools_0.5.1.1 jquerylib_0.1.4 jsonlite_1.7.2 knitr_1.33 magrittr_2.0.1 markdown_1.1 methods_4.1.0 mime_0.11 rlang_0.4.11 rmarkdown_2.10 stats_4.1.0 stringi_1.7.3 stringr_1.4.0 tinytex_0.33 tools_4.1.0 utils_4.1.0 xfun_0.25 yaml_2.2.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviornextto consider for next releasepandocconcerns upstream pandoc

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions