Reputation: 71
Creating a latex table using kbl
and linebreak
results in a weird alignement of the text column.
library(dplyr)
library(kableExtra)
data.frame(
text = c(
"Some longer line",
"Line 1\nLine 2",
"Line 1\nLine 2",
"Line 1\nLine 2",
"Line 1\nLine 2",
"Line 1\nLine 2"
)
) %>%
mutate_all(linebreak) %>%
kbl(booktabs = T, escape = F, format = "latex")
How do I get the column left-aligned as expected?
Upvotes: 1
Views: 328
Reputation: 71
Setting the align
parameter in linebreak
solves the problem.
data.frame(
text = c(
"Some longer line",
"Line 1\nLine 2",
"Line 1\nLine 2",
"Line 1\nLine 2",
"Line 1\nLine 2",
"Line 1\nLine 2"
)
) %>%
mutate_all(linebreak, align = 'l') %>%
kbl(booktabs = T, escape = F, format = "latex")
Upvotes: 3