Reputation: 1303
I want to have the title(caption) of the table centered, but the values of columns left assigned. I also want my caption to be broken into two lines and each line to be centered.
align
option changes both of them in a same way.
head(mtcars) %>%
kbl(caption = "{first row\\\\
second row}",
align = "l") %>%
kable_styling()
Upvotes: 3
Views: 2847
Reputation: 2944
Maybe this helps:
head(mtcars) %>%
kbl(align = "l") %>%
add_header_above(data.frame("{first row \\\\ second row}", 12),
monospace = TRUE) %>%
kable_styling()
The result:
I assume that you are trying to produce a table in html format. To center the caption and put a line break on the caption texts, you can use html elements: <center>
for centering and <br>
for line breaking.
head(mtcars) %>%
kbl(caption = "<center>{first row <br>
second row}</center>",
align = "l") %>%
kable_styling()
The result:
Upvotes: 3