How to change the figure/table caption style in bookdown

I think you get this behavior because we changed the output to have a : as separator by default. It was suppose to be there and it was not. It is possible that we revert back this change because you are not the first one to be impacted by this.

However, you can now do that with R directly, no need of Lua.

You can add this in a _bookdown.yml file:

language:
  label:
    fig: !expr function(x) sprintf("**Figure %s.** ", x)

This is documented in 4.5 Internationalization | bookdown: Authoring Books and Technical Documents with R Markdown and supported since bookdown 0.22

As you see you can pass Markdown syntax to obtain the Strong type.

Would that work for you ?

Otherwise, you we need to replace the sep : if it exists using Lua function. I guess indexing by number is not robust to any change in the default caption. (string.gsub should work in Lua for example)

1 Like