I am trying to use Quarto
to render a table created as a flextable
into a pdf file. Some columns of the table are too long and the text does not wrap when I try to render it to a pdf.
When I try to render the table into html the text wraps.
What can I do to render wraped columns in pdf?
---
title: "How to wrap text of columns in a table?"
format: pdf
editor: visual
---
```{r}
#| label: load-packages
#| include: false
library(dplyr)
library(flextable)
#| label: tbl-domains
#| tbl-cap: Table title
#| warning: false
#| echo: false
table_p <- tibble(P = c(1,2,3,4,5),
P_name = c('aaaaaa aaaaa aaaaaa aaaaa aaaaaa aaaaa aaaaaa aaaaa aaaaaa aaaaa', 'aaaaaa aaaaa', 'bb bbbbb', 'bb bbbbb', 'bb bbbbb'),
D_name = c('xxxx xxxx','yyyyyy y yy','zzzz zz','fffff fffffffff','ggggg gggggggggggggggg ggggg gggggggggggggggg ggggg gggggggggggggggg ggggg gggggggggggggggg'))
ft <- flextable(table_p)
ft <- set_header_labels(ft, P_name = "First",
D_name = "Second" )
ft <- set_table_properties(ft, layout = "autofit", width = .8,
opts_pdf = list(tabcolsep = 5))
ft