我正试图在一张幻灯片上放一张大桌子。我正在使用kable。
我试过{.smaller}
,但这还不够,所以我以为我会使用.css,但它也不起作用。
我创建了一个示例演示文稿来说明问题。我尝试编织它,它显示的方式与我的其他演示文稿相同(这很长,这就是我在这里排除它的原因)
我的代码:
---
title: "test"
author: "Test Author"
date: "5 Februar 2018"
output:
ioslides_presentation:
test: presentation.css
---
{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(knitr)
## Test slide
{r}
table <- data.frame(
index=1:10,
long_text=c("long text here: asdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf")
)
kable(table)
## Test slide css {.test}
{r}
table <- data.frame(
index=1:10,
long_text=c("long text here: asdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf")
)
kable(table)
我的.css:
.test{
font-size: 50%;
}
答案 0 :(得分:2)
您可以通过修改css table
和td
属性来做到这一点。
示例CSS和代码:
table.rmdtable td, table th {
font-size: 40%;
padding: 1em 0.5em;
line-height: 18px;
}
---
title: "test"
author: "Test Author"
date: "5 Februar 2018"
output:
ioslides_presentation:
css: presentation.css
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(knitr)
```
## Test slide
```{r}
table <- data.frame(
index=1:10,
long_text=c("long text here: asdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf")
)
kable(table)
```
## Test slide css {.test}
```{r}
table <- data.frame(
index=1:10,
long_text=c("long text here: asdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasfasdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf",
"long text here: asdfghhjoqweqwrqwrqwrasf")
)
kable(table)
```
我的建议是您在浏览器中打开演示文稿,例如chrome。启动开发工具并使用css
属性。然后,您可以将其构建到演示文稿.css文件中。
而不是修改总体幻灯片格式。我建议您阅读将css
格式应用于特定幻灯片的内容。例如,只有两个测试幻灯片。
https://bookdown.org/yihui/rmarkdown/custom-css-1.html#slide-ids-and-classes
我希望这可以为您指明正确的方向。