在R markdown beamer演示中添加作者所属单位

34
如何在一个 RMarkdown Beamer 报告中,将作者机构添加到新行?
---
title: "This is the title"
author: "Author"
date: "Thursday, April 09, 2015"
output: beamer_presentation
---
## Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3

期望的标题幻灯片应为

这是标题

作者

从属关系

2015年4月9日星期四

4个回答

36

如果您使用管道符号|,则可以将作者行分成多行:

---
title: "The title"
author: | 
  | The author
  | The affiliation
date: "9 April 2015"
output: beamer_presentation
---

输出:

beamer

编辑我们可以调整标题、作者/机构的字体吗?):

如果您想更改不同的字体大小,我建议您玩一下演示文稿头文件的includes: in_header选项(请参阅此RStudio链接以获取详细信息)。

这指向您计算机上的一个简单的.tex文件,在其中可以添加针对演示文稿导言的LaTeX命令。因此,您可以在桌面上拥有一个名为preamble.tex的文件,并使用\setbeamerfont{XX}{size={\fontsize{YY}{ZZ}}}命令,其中XX是要更改的特定项(标题,作者);YY是要应用的字体大小;ZZ是跳过行数(以pt为单位)(也可参见此链接以获取更多详细信息)。

因此,对于您的示例,我们有:

在桌面上(或任何您想要的位置)创建一个名为preamble.tex的文件,其中只包含两行:

\setbeamerfont{title}{size={\fontsize{30}{25}}}
\setbeamerfont{author}{size={\fontsize{5}{20}}}

您的foo.Rmd文件:

---
title: "The title"
author: | 
  | The author
  | The affiliation
output:
 beamer_presentation:
   includes:
     in_header: ~/Desktop/preamble.tex
---


## R Markdown

This is an R Markdown presentation. 
Markdown is a simple formatting syntax for 
authoring HTML, PDF, and MS Word documents.

输出结果将是:

更改的Beamer字体


1
我们可以把标题字体变大,作者和机构变小吗? - Koundy
这个不再起作用了(可能更高版本的行为不同)。 - xhudik

21

而且您应该能够拥有多个作者和机构。

title: This is the title
author: 
   - Author Juan$^1$
   - Author Tu$^2$
institute: 
   - $^1$Juans Casa
   - $^2$Tus Place
date: "Thursday, April 09, 2015"
output:
  beamer_presentation

12

beamer中处理机构信息的正确方式是通过\institute{}(参见tex.SE上这个答案)。

pandoc 1.17开始,默认的beamer模板中就包含了institute字段,所以如果您有适当的版本,则只需执行以下操作:

---
title: "This is the title"
author: "Author"
institute: "Affiliation"
date: "Thursday, April 09, 2015"
---

旧答案

如果您使用较旧的pandoc版本(< 1.17),或者rmarkdown的默认beamer模板尚未更新,则可能需要它。 为使其与pandoc配合使用,您可以编辑您的beamer模板。 如果您尚未编辑过它,可以使用以下命令创建:

pandoc -D beamer > ~/.pandoc/templates/default.beamer

接下来,打开文件并在作者信息后添加以下内容:

$if(institute)$
\institute[]{$institute$}
$endif$

最后,将学院选项添加到您的yaml文件中:

---
title: "This is the title"
author: "Author"
institute: "Affiliation"
date: "Thursday, April 09, 2015"
---

如果你正在使用rmarkdown,你可能需要指定模板:

如果您使用rmarkdown,可能需要指定模板:

---
title: "This is the title"
author: "Author"
institute: "Affiliation"
date: "Thursday, April 09, 2015"
output:
  beamer_presentation:
    template: ~/.pandoc/templates/default.beamer
---

使用这种方法相对于多行作者有两个优点。

  1. 一些Beamer主题使用作者字段和/或机构字段,例如重复在每个幻灯片底部显示。多行作者会破坏此效果。
  2. 这允许更好地控制标题幻灯片元素:例如,您可以为作者和从属信息设置不同的字体系列和大小:
\setbeamerfont{institute}{size={\fontsize{5}{20}}}

难道 pandoc 不是 1.17 版本吗?我试图编辑你的回答,但它不允许我进行如此微小的更改。 - gvegayon

2

以下方法也可行,

---
title: "Multiple authors"
author: 
  - John Doe\inst{1}
  - John Roe\inst{2}
institute: 
  - \inst{1} affiliation for John Doe
  - \inst{2} affiliation for John Roe
output: beamer_presentation
---

## Slide 1


authors with affiliations


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接