bookdown: caption style is not rendered

I've tried to customize captions using expressions as described in this post.

While the post stated that Markdown syntax is supported, I could not make a strong type. Instead of strong type, in the book, I got caption enclosed with asterisks, like **Table 1.1.**. I reproduced this behavior by copying Yihui's minimal bookdown and adding _bookdown.yml to it.


title: "reprex"
site: bookdown::bookdown_site
documentclass: book
  bookdown::gitbook: default

# Hello World

  caption = 'A table generated by the longtable package.'


    tab: !expr function(x) sprintf("**TABLE %s.** ", x)


Any suggestions why it does not work?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

Hi !

Sorry for the delay on this. I believe this is a uncomplete answer on

It worked there because it was used with a word_document2() output format, and with it, the label prefix replacement from configuration happens at the Markdown step. It was a bit of a "hack" to use this for Word output.

It does not work with gitbook() or other format where the replacement happens not at the markdown step.
That is obviously internal stuff, and this could be considered an issue or at least a feature request to bring support to HTML format for passing markdown syntax in the configuration. Do you want to open one in Bookdown repo ? GitHub - rstudio/bookdown: Authoring Books and Technical Documents with R Markdown ?

Usually, for styling HTML one need to use CSS. To do that with the "Table 1.1" part of the caption with a HTML format, you need to use CSS. Something like this would work

caption span {
  font-weight: 700;

Changing the CSS selector can help customize further. See also about the CSS rule

Hope it helps.