3

I inclue and cross-referencing a table in a Rmd file, and I want to add chapter number with the table title and referencing number, like "TABLE 1.1 test", but not "TABLE 1 test". I render the file using bookdown::word_document2. Here is a minimal example:

---
title: test
output:
  bookdown::word_document2:
    fig_caption: yes
    toc: yes
---

```{r}
library(knitr)
```
# Heading 1
I'm cross-referencing a table table:\@ref(tab:test).

```{r test}
test <- data.frame(a = 1:6, b = 2:7)
kable(test, caption = "test")
```

output

Rmarkdown/Bookdown is really an amazing tool @Yihui, thanks!

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
chongliang
  • 31
  • 1
  • And... What are you asking? – BusyProgrammer Feb 15 '17 at 13:34
  • You could try pandoc-crossref https://github.com/lierdakil/pandoc-crossref with the chapter option – scoa Feb 15 '17 at 14:05
  • 1
    I want to add chapter number with the table title like "TABLE 1.1 test", but not "TABLE 1 test" @ABusyProgrammer – chongliang Feb 16 '17 at 02:19
  • Thank you @scoa. Pandoc-crossref can add chapter number in table title, but hyperlink is disable in docx. I have contact the author. – chongliang Feb 16 '17 at 10:49
  • 1
    It is a known issue in bookdown: https://github.com/rstudio/bookdown/blob/a5ad84c8/R/word.R#L12-L13 It may change in the future, but currently we only support Pandoc 1.17.2, and I don't think it supports numbered sections in Word. – Yihui Xie Feb 16 '17 at 21:45
  • Thanks @Yihui. As scoa mentioned, I tried Pandoc-crossref yestoday. I can add chapter number in table title, like table 1.1 in both .docx file and .odt file. But as spans and divs are not converted to docx bookmarks by Pandoc, hyperlink to table title is disabled. [https://github.com/lierdakil/pandoc-crossref/issues/105](https://github.com/lierdakil/pandoc-crossref/issues/105) – chongliang Feb 17 '17 at 14:21
  • I have [similar question](https://stackoverflow.com/questions/48254248/why-figure-numbers-with-two-digits-separated-by-dot-are-shown-only-in-html-docum?s=2|0.0000) with figures. Do you have any news, @YihuiXie? Do we have any simple workaround? – N0rbert Jan 17 '18 at 12:12
  • @YihuiXie , I found interesting [github repo](https://github.com/KeachMurakami/fudukue/blob/master/demo/cross-reference/demo_crossref.Rmd) with possible workaround. Could you please implement such in bookdown directly? – N0rbert Jan 17 '18 at 14:06

0 Answers0