简体   繁体   English

RMarkdown:如何调整要显示为 ioslides 演示文稿的表格大小?

[英]RMarkdown: How to resize a table to be displayed into a ioslides presentation?

I'm creating a presentation with RMarkdown to be displayed in ioslides.我正在使用 RMarkdown 创建要在 ioslides 中显示的演示文稿。 That being said, I'm having some trouble when it comes to display tables into slides, as they appear in there way smaller than I'd desire.话虽如此,在将表格显示为幻灯片时我遇到了一些麻烦,因为它们看起来比我想要的要小。

My code looks like follows:我的代码如下所示:

library(kableExtra)
x <- data.frame(a = c("x", "y", "z"), b = c(1, 2, 3))
x %>% 
  kable() %>%
  kable_styling("striped", full_width = FALSE) %>%
  column_spec(2, bold = TRUE) %>%
  row_spec(1, color = "blue", background = "lightblue", bold = TRUE) %>%
  row_spec(2, color = "orange", background = "navajowhite", bold = TRUE) %>%
  row_spec(3, color = "red", background = "lightsalmon", bold = TRUE)

Here's a screenshot with the output I get when I knit it to ioslides:这是我将它编织到 ioslides 时得到的 output 的屏幕截图:

在此处输入图像描述

I wish to expand this table so it fits better the room available into the slide and become more eye-friendly than now it is.我希望扩大这张桌子,使它更适合滑梯的可用空间,并且比现在更适合眼睛。 I'd like also to center the subtitle as well.我也想将字幕居中。

What is eye-friendly is certainly in the eye of the beholder;-).对眼睛友好的东西肯定在旁观者的眼中;-)。 It may help to format the font size and print the header bold.它可能有助于格式化字体大小并打印 header 粗体。

To make the table wider, use the width argument in col_spec() .要使表格更宽,请使用col_spec()中的width参数。

I assume that you have created subtitle using markdown syntax ( ## subtitle ).我假设您使用 markdown 语法( ## subtitle )创建了字幕。 This is included in the HTML output as <h3>Subtitle</h3> .这包含在 HTML output 作为<h3>Subtitle</h3>中。 You can also use HTML and center it in the rmd file: <center><h3>subtitle</h3></center> .您也可以使用 HTML 并将其居中在 rmd 文件中: <center><h3>subtitle</h3></center> (Note that kable() also has the argument caption ). (注意kable()也有参数caption )。

x %>% 
 kable() %>%
 kable_styling("striped", full_width = F) %>%
 column_spec(2, width = "20em") %>%
 row_spec(0, bold = TRUE, font_size = 24) %>%
 row_spec(1, color = "blue", background = "lightblue", bold = TRUE) %>%
 row_spec(2, color = "orange", background = "navajowhite", bold = TRUE) %>%
 row_spec(3, color = "red", background = "lightsalmon", bold = TRUE)

在此处输入图像描述

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

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