[英]How remove colon in figure caption when using pandoc and bookdown in Rmarkdown?
[英]How do I create a huxtable table caption using bookdown in rmarkdown?
我的rmarkdown中有很多huxtable表。 我想用bookdown給他們加上標題。 到目前為止,我無法使用“其他用於生成表的R包”的預訂說明來執行此操作(請參見上面的URL)。
這是一個遵循此答案說明的示例:
---
title: "huxtable-mwe"
site: bookdown::bookdown_site
output:
bookdown::html_book
documentclass: book
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(huxtable)
library(magrittr)
```
See table \@ref(tab:bar).
Table (\#tab:foo): Foo
```{r foo, echo=FALSE}
ht <- hux(
foo = c('foo','bar')
) %>%
set_all_borders(1)
ht
```
See table \@ref(tab:foo).
Table (\#tab:bar): Bar
```{r bar, echo=FALSE}
ht <- hux(
foo = c('bar', 'baz')
) %>%
set_all_borders(1)
ht
```
參考有效,但獲得以下表格標題:
表格(#tab:foo):Foo
表格(#tab:bar):欄
當我期望:
表1:Foo
表2:欄
感謝MWE。
解決。 使用set_caption(...)
將標題放入<caption>...</caption>
元素中,並且不要轉義標簽:
---
title: "huxtable-mwe"
site: bookdown::bookdown_site
output:
bookdown::html_book
documentclass: book
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(huxtable)
library(magrittr)
```
See table \@ref(tab:bar).
```{r foo, echo=FALSE}
ht <- hux(
foo = c('foo','bar')
) %>%
set_all_borders(1) %>%
set_caption('(#tab:foo) Foo')
ht
```
See table \@ref(tab:foo).
```{r bar, echo=FALSE}
ht <- hux(
foo = c('bar', 'baz')
) %>%
set_all_borders(1) %>%
set_caption('(#tab:bar) Bar')
ht
```
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.