I'm creating a PDF bookdown file. However, I'm unable to edit the Table and Figure headers, such that the text "Figure X" and "Table X" are in bold. For example,
Table 1 my first table
Figure 2 my second figure
Here is the code that I ran, modified with the starwars dataset:
---
title: "Untitled"
output:
bookdown::pdf_document2: default
date: "2023-03-22"
header-includes:
- \usepackage[singlelinecheck=false]{caption}
toc: FALSE
---
```{r tab2, echo=FALSE, message=FALSE}
library(dplyr)
library(kableExtra)
sw <- starwars[, c("name", "height", "mass", "films")]
kable(sw, "latex", booktabs = TRUE, longtable = TRUE, linesep = "", caption = "Some chars", align = "l") %>%
kable_styling(latex_options = c("hold_position", "repeat_header"), position="left") %>%
column_spec(4, width = "8cm") %>%
row_spec(0,bold=TRUE)
```
Are you able to advise?
Thanks, Mark
You could use the labelfont=bf
option in the {caption}
package:
---
output:
bookdown::pdf_document2: default
header-includes:
- \usepackage[singlelinecheck=false, labelfont=bf]{caption}
---
```{r tab2, echo=FALSE, message=FALSE}
library(dplyr)
library(kableExtra)
sw <- starwars[, c("name", "height", "mass", "films")]
kable(sw, "latex", booktabs = TRUE, longtable = TRUE, linesep = "", caption = "Some chars", align = "l") %>%
kable_styling(latex_options = c("hold_position", "repeat_header"), position="left") %>%
column_spec(4, width = "8cm") %>%
row_spec(0,bold=TRUE)
```
Output: