I have a table that is too wide and is therefore spilling into the right margin.
I found this on tex exchange which gives the latex solution using \makebox
.
As I am not an expert in latex and my table is a longtable I was unable to implement that even in latex.
My preference is for a solution in rmarkdown itself. I am using kable if that makes any difference.
Posting through mobile so couldn't add an example.
The most basic solution for kableExtra
is:
```{r table, echo=FALSE, warning=FALSE, message=FALSE}
library(gt) #dataset gtcars is here
library(kableExtra)
dt <- head(gtcars)
dt %>%
kbl() %>%
kable_styling(latex_options = c("scale_down", "hold_position"))
```
You can also use \resizebox{\textwidth}{!}{ ***table is here*** }
but fontsize is also affected.
If you want additionaly control the fontsize, look there
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.