R Markdown PowerPoint幻灯片自定义

问题描述 投票:1回答:1
---
title: "Untitled"
author: "April 2018"
date: "4/9/2019"
output: powerpoint_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## Slide with Plot

```{r pressure, fig.width=30, fig.asp=0.618, out.width="200%"}
plot(pressure)
```

default slide

我正在读R Studio's guide to creating PowerPoint presentations in R Markdown。我希望能够自定义我的幻灯片,包括两件事:

  1. 将图像大小拉伸到幻灯片的整个宽度
  2. 将标题向上移动一点并保持对齐

在做了一些互联网搜索后,我无法确定如何正确地做到这一点。也许你知道怎么做。这就是我要找的东西(下图)。调整输出宽度似乎没什么帮助。

desired slide

r r-markdown powerpoint officer
1个回答
5
投票

您可以通过创建具有您创建的自定义主幻灯片布局的“参考”powerpoint文件来调整生成的powerpoint文件的布局。您链接的RStudio文档的The Templates section解释了如何执行此操作。

基本思想是打开一个新的powerpoint文件并自定义主幻灯片样式,或使用现有的powerpoint文档或模板,这些文档或模板已经具有您想要的样式或可以调整以获得您想要的样式。将该自定义文件保存在RStudio项目文件夹中(或者您可以在YAML标头中引用的其他路径),然后将其引用到YAML标头。如果此参考文档名为my_template.pptx,则YAML标头将如下所示:

---
title: "Untitled"
author: "April 2018"
date: "4/9/2019"
output: 
  powerpoint_presentation:
    reference_doc: my_template.pptx
---

对于您的情况,我将您提供的文档编织到名为test.pptx的文件中,并将其用作我的起始文档来创建所需的模板。打开该文件后,我打开了“幻灯片母版”:

enter image description here

这提出了以下观点:

enter image description here

单击Insert Layout(靠近功能区的左端)以创建新的幻灯片布局,这将成为我们的边到边图片布局。然后单击Insert Placeholder下拉列表并选择Picture。然后单击并拖动以在我们刚刚创建的幻灯片布局中添加边对边图片占位符。您也可以将幻灯片标题框移到更高的位置,然后使用Home菜单将其设置为左对齐。新的幻灯片布局现在看起来像这样:

enter image description here

单击Slide Master(功能区的左端),然后单击Close Master(功能区的右端)。然后将文件另存为my_template.pptx

现在编译以下文档:

---
title: "Untitled"
author: "April 2018"
date: "4/9/2019"
output: 
  powerpoint_presentation:
    reference_doc: template.pptx
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## Slide with Plot

```{r pressure, fig.asp=0.618}
par(mar=c(4,4,0.1,0.1))
plot(pressure)
```

这就是powerpoint幻灯片的样子:

enter image description here

那不是我们想要的。让我们尝试不同的fig.asp=0.5宽高比:

enter image description here

虽然分辨率很差,但这更好。所以让我们设置dpi块参数,以便块头现在如下:

```{r pressure, fig.asp=0.5, dpi=300}

它为我们提供了以下带有更清晰线条和文字的幻灯片:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.