在R Markdown PowerPoint导出中选择幻灯片布局

发布于 2025-02-04 08:34:14 字数 1440 浏览 2 评论 0原文

我使用R Markdown创建一个PowerPoint。

---
title: "Presentation Title"
author: "That is me"
date: "`r format(Sys.time(), '%d.%m.%Y')`"
output:
  powerpoint_presentation:
    reference_doc: template.pptx
    slide_level: 2
---

如您所见,我使用自定义模板文件template.pptx

现在,我的目标是从该模板中选择要使用的布局。我知道officedown允许块选项布局(请参阅 https://www.apreshill.com/blog/2021-07-fcedown/ ),但我认为没有其他包装也可以使用。为什么?

当我通过kable在页面上放置一个表时,使用模板中的“带有字幕的内容”的布局。

```{r results="asis"}
cat("\n\n## Page Title\n\n")
cat("\n\nSome content\n\n")
data.frame(matrix(c(1))) %>% kable
```

当我使用Flextable时,使用布局“标题和内容”。

```{r results="asis", ft.left=0.9}
cat("\n\n## Page Title\n\n")
cat("\n\nSome content\n\n")
flextable(data.frame(matrix(c(1)))) %>% flextable_to_rmd
```

因此,似乎kable()可以以某种方式告诉输出使用其他布局。有什么想法,为什么是这种情况?

pandoc手册

内容添加标题

此布局用于任何非两列幻灯片,其中包含文本,后跟非文本(例如图像或表格)。

因此,这可能意味着flextable未被识别为“非文本”内容。我可以添加演示文稿中不会显示的非文本内容吗?我并不希望clearpixel.gif的时间,而是...

I create a PowerPoint with R markdown.

---
title: "Presentation Title"
author: "That is me"
date: "`r format(Sys.time(), '%d.%m.%Y')`"
output:
  powerpoint_presentation:
    reference_doc: template.pptx
    slide_level: 2
---

As you see, I use a custom template file template.pptx.

Now my goal ist to select which layout to be used from that template. I know that officedown allows for a chunk option layout (see https://www.apreshill.com/blog/2021-07-officedown/), but I think it is possible without the additional package as well. Why?

When I put a table on the page via kable, the layout "Content with Caption" from the template is used.

```{r results="asis"}
cat("\n\n## Page Title\n\n")
cat("\n\nSome content\n\n")
data.frame(matrix(c(1))) %>% kable
```

When I use flextable instead, the layout "Title and Content" is used.

```{r results="asis", ft.left=0.9}
cat("\n\n## Page Title\n\n")
cat("\n\nSome content\n\n")
flextable(data.frame(matrix(c(1)))) %>% flextable_to_rmd
```

So it seems that kable() can somehow tell the output to use the other layout. Any ideas why that is the case?

The Pandoc manual says

Content with Caption

This layout is used for any non-two-column slides which contain text followed by non-text (e.g. an image or a table).

So that probably means that the flextable is not recognizes as "non-text" content. Can I add non-text content that won't show up in the presentation? It's not that I wish back times of the clearpixel.gif, but ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月如刀 2025-02-11 08:34:14

我对此并不特别骄傲,但是旧的clearpixel可以完成这项工作...

```{r results="asis", ft.left=0.9}
cat("\n\n## Page Title\n\n")
cat("\n\nSome content\n\n")
flextable(data.frame(matrix(c(1)))) %>% flextable_to_rmd
cat("![](clearpixel.png)\n")
```

谁找到了一个更清洁的解决方案(隐形元素仍然可以在PPT文件中选择),请在此处友好地将其发布在此处:)

I am not especially proud of this, but the good old clearpixel does the job...

```{r results="asis", ft.left=0.9}
cat("\n\n## Page Title\n\n")
cat("\n\nSome content\n\n")
flextable(data.frame(matrix(c(1)))) %>% flextable_to_rmd
cat("![](clearpixel.png)\n")
```

Whoever finds a cleaner solution (the invisible elemente will still be selectable in the PPT file), please kindly post it here :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文