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

dat*_*a L 6 r slideshow r-markdown

我在rmarkdown制作幻灯片,当我使用时

 kable(tablename)
Run Code Online (Sandbox Code Playgroud)

柱子调整,使桌子适合整个幻灯片.

我希望列以某种方式更小的固定大小.通过围绕文本/数字的宽度包装列,或声明固定宽度.

另外,我不介意缩小整个表格的尺寸.

我想避免使用其他软件包,只想知道如何使用kable.

小智 1

我在使用 Latex 命令和 minipage 包编织到 .pdf 时执行此操作。我认为您不必安装这个。

\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
Run Code Online (Sandbox Code Playgroud)

\centering 和 \flushleft 命令是您的偏好,并且执行您期望的操作。两个 minipage 命令会将表格并排放置。您可以放置​​超过两个字节,则必须使用 {0.4\textwidth} 部分,这意味着允许表格占用文本宽度的 0.4。

希望这可以帮助!