5

我想在一张幻灯片上放一张大桌子。我正在使用卡布尔。我试过{.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%;
}
4

1 回答 1

5

您可以通过修改 csstabletd属性来做到这一点。

结果:

在此处输入图像描述

示例 CSS 和代码:

演示文稿.css

table.rmdtable td, table th {
    font-size: 40%;
    padding: 1em 0.5em;
    line-height: 18px;
}

rmarkdown 文件

---
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

我希望这能为您指明正确的方向。

于 2019-03-18T01:47:59.393 回答