来自R markdown的投影机输出中的页码

时间:2016-05-12 00:02:51

标签: latex r-markdown

我正在尝试将页码添加到我的beamer演示文稿中。我在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)
```

1 个答案:

答案 0 :(得分: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]