![](/img/trans.png)
[英]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.