wrap text in knitr::kable table cell using “\n”
问题 How can I wrap a cell in a knitr::kable table cell using \n ? I want to generate a .rmd file containing some tables where one column needs text wrapping. The places where the wrapping should occur are marked with \n . I tried (this is a standalone .rmd document): --- output: pdf_document --- ## A Table with text wrap ```{r cars} knitr::kable(data.frame(col1 = c("a", "b"), col2 = c("one\ntwo", "three\nfour"))) ``` ..but this doesn't work. Instead of staying in col2 , the wrapped part lives on