[R markdown输出的投影仪中的页码

问题描述 投票:0回答:1

我正在尝试在投影仪演示文稿中添加页码。我在Rmarkdown中使用以下代码(请参见下文)。问题是页码被切断。我尝试使用几何来调整尺寸,但是我不断收到一条错误消息,指出它们不兼容。有人有什么想法吗?我花了几个小时寻找解决方案。

---
title: my title
author: "me"
date: "May 05, 2016"
output: beamer_presentation
header-includes:
- \usepackage{fancyhdr}
- \pagestyle{fancy}
- \fancyhead{}
- \fancyfoot{}
- \fancyfoot[R]{\thepage}
- \setbeamertemplate{footline}{\thepage}
---

Global Options
=======================================================

```{r global_options, include=FALSE}
# Setting up your workspace for standard figure output and exclusion of chunk codes, warnings, and messages unless otherwise specified:
knitr::opts_chunk$set(fig.width=6, fig.height=4, 
                      fig.path='Figs/', 
                      fig.show='asis', include=FALSE, warning=FALSE, message=FALSE)
```

```{r}
 library(knitr)
```

```{r cars, include=TRUE, echo=FALSE}
summary(cars)
```


# Including Plots


```{r pressure, echo=FALSE, include=TRUE}
plot(pressure)
```
latex r-markdown
1个回答
0
投票

正如@Werner已经说过的,您不应该将fancyhdr与beamer一起使用,因为beamer有其自己的头和脚线机制。

将页码添加到投影仪演示文稿的最简单方法是使用预定义模板之一,例如\setbeamertemplate{footline}[frame number]。不幸的是,在rmarkdown标头包含中似乎没有可选参数,但是可以欺骗rmarkdown并将它们隐藏在文件中:

---
title: my title
author: "me"
date: "May 05, 2016"
output: 
  beamer_presentation:
    keep_tex: true
    includes:
      in_header: preamble.tex
---

Global Options
=======================================================

```{r global_options, include=FALSE}
# Setting up your workspace for standard figure output and exclusion of chunk codes, warnings, and messages unless otherwise specified:
knitr::opts_chunk$set(fig.width=6, fig.height=4, 
                      fig.path='Figs/', 
                      fig.show='asis', include=FALSE, warning=FALSE, message=FALSE)
```

```{r}
 library(knitr)
```

```{r cars, include=TRUE, echo=FALSE}
summary(cars)
```


# Including Plots


```{r pressure, echo=FALSE, include=TRUE}
plot(pressure)
```

和preamble.tex

\setbeamertemplate{footline}[frame number]
© www.soinside.com 2019 - 2024. All rights reserved.