2016-07-24 62 views
1

我正在使用R Markdown,並試圖生成一個表格並將它居中放置在word文檔中。下面是我的代碼已經從github作爲測試MS Word中的RMarkdown,中心和參考表格

Table \@ref(tab:table-single) is a simple example. 

```{r table-single, tidy=FALSE} 
knitr::kable(
    head(mtcars, 10), booktabs = TRUE, 
    caption = 'A table of the first 10 rows of the mtcars data.' 
) 
``` 

當我運行這段代碼表名從來沒有解決,所以我得到\ @ref(製表:表單),而不是作爲​​可從看到的最終document

  • 有人能看到在我的代碼我已經取得了關係的錯誤引用我的表

我編織到Word

感謝

+0

請張貼在一個時間一個問題。引用該方式的 –

+0

只適用於膠乳輸出。您可以嘗試https://github.com/lierdakil/pandoc-crossref獲取其他輸出。 – scoa

回答

1

如果使用bookdown包來渲染降價,你會得到正確的交叉引用:

--- 
output: bookdown::word_document2 
--- 

Table \@ref(tab:table-single) is a simple example. 

```{r table-single, tidy=FALSE} 
knitr::kable(
    head(mtcars, 10), booktabs = TRUE, 
    caption = 'A table of the first 10 rows of the mtcars data.' 
) 
``` 

enter image description here