简体   繁体   English

如何在Kable中缩小列宽和表大小(type = rmarkdown)

[英]How to Shrink Column Width and Table Size In Kable(type = rmarkdown)

I am making slides in rmarkdown, and when I use 我在rmarkdown制作幻灯片,当我使用时

 kable(tablename)

the columns adjust so the table fits the whole slide. 柱子调整,使桌子适合整个幻灯片。

I want the columns to be a smaller fixed size somehow. 我希望列以某种方式更小的固定大小。 Either by wrapping columns around the width of the text/numbers, or declaring a fixed width. 通过围绕文本/数字的宽度包装列,或声明固定宽度。

Also, I wouldn't mind shrinking the whole table to be a much smaller size. 另外,我不介意缩小整个表格的尺寸。

I'd like to avoid using other packages and just want to know how to do this with kable. 我想避免使用其他软件包,只想知道如何使用kable。

I do this when kniting to .pdf by using latex commands and minipage package. 我通过使用latex命令和minipage包来编织.pdf时这样做。 I don't think you will have 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 would expect. \\ centering和\\ flushleft命令是您的偏好,并按照您的期望行事。 The two minipage commands will put the tables side by side. 两个小型命令将并排放置表格。 you can place more than two byt will have to play around with the {0.4\\textwidth} part, which means allow table to occupy 0.4 of the text width. 你可以放置两个以上的byt来使用{0.4 \\ textwidth}部分,这意味着允许表占用文本宽度的0.4。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM