How to reduce column width and table size in Kable (type = rmarkdown)

I make slides in rmarkdown, and when I use

kable(tablename) 

columns are adjusted so that the table matches the entire slide.

I want the columns to be somehow smaller than the fixed size. Either wrapping the columns across the width of the text / numbers, or declaring a fixed width.

In addition, I would not mind cutting the whole table to be much smaller.

I would like to avoid using other packages and just want to know how to do this with kable.

+6
source share
1 answer

I do this when knitting on .pdf using latex commands and minipacks. I do not think you will need to install this.

 \centering \begin{minipage}{0.4\textwidth} ```{r} Use your kable command here to create your first table knitr::kable(data[c(rownum),],format = "latex") ``` \end{minipage} \begin{minipage}{0.4\textwidth} ```{r} Use your kable command here to create your second table knitr::kable(data[c(rownum),],format = "latex") ``` \end{minipage} \flushleft 

The \ centering and \ flushleft commands are your preference and do what you expect. Two mini-disk commands place tables next to each other. you can place more than two bytes to play with the {0.4 \ textwidth} part, which means that the table can take up 0.4 text widths.

Hope this helps!

0
source

Source: https://habr.com/ru/post/989626/


All Articles