Add author affiliation in R markdown beamer presentation
Asked Answered
Z

4

34

How to add author affiliation in a new line in an rmarkdown beamer presentation?

---
title: "This is the title"
author: "Author"
date: "Thursday, April 09, 2015"
output: beamer_presentation
---
## Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3

The desire title slide should be

This is the title

Author

Affiliation

Thursday, April 09, 2015

Zeus answered 9/4, 2015 at 7:19 Comment(0)
C
36

If you use pipes | you can break the author line into multiple lines:

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

Output:

beamer

Edit (can we play with the title and author/affiliation fonts?):

If you want to change the different font sizes, I recommend playing with the includes: in_header option of your presentation's header (check this RStudio link for specifics).

This points to a simple .tex file on your computer where you can add LaTeX commands specifically for your presentation's preamble. You could therefore have a file called preamble.tex in your Desktop, and use the \setbeamerfont{XX}{size={\fontsize{YY}{ZZ}}} command, where XX is the specific thing you want to change (title, author); YY is the font size to apply; and ZZ is the skip line (in pt) (also see this link for more details).

So for your example, we have:

preamble.tex file at your Desktop (or wherever you want) containing just two lines:

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

Your foo.Rmd file:

---
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.

And the output will be:

beamer font changed

Coucal answered 9/4, 2015 at 7:39 Comment(2)
Can we make the tiltle font large and author and affiliation smaller??Splutter
this doesnt work anymore (likely higher version behave differently)Aldrich
C
21

and you should be able to have multiple authors and institutions

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
Cysticercus answered 2/6, 2016 at 10:6 Comment(0)
F
12

The proper way to deal with affiliation in beamer is through \institute{} (see this answer on tex.SE).

Current solution (pandoc version >= 1.17)

Starting with pandoc 1.17, the institute field is present in the default beamer template, so all you need to do if you have the proper version is:

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

Old answer

Might be needed if you use an older pandoc version (< 1.17) or while rmarkdown's default beamer template has not been updated. To make this work with pandoc, you could edit your beamer template. If you have not edited it yet, you can create it with:

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

Then, open the file and add this after the author information:

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

Finally, add the institute option to your yaml:

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

If you are using rmarkdown, you may have to specify the template:

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

There are two advantages to using this over a multiline author.

  1. some beamer theme use the author field and/or the institute field, for instance to repeat it at the bottom of each slide. A multiline author would mess this up.
  2. this allow for a finer control of the title slide elements: you can have a different font family and size for author and affiliation information for instance:
\setbeamerfont{institute}{size={\fontsize{5}{20}}}
Forthcoming answered 9/3, 2016 at 9:51 Comment(1)
Isn't pandoc 1.17? I tried to edit your answer but it does not allows me to make such a small change.Misbehavior
G
2

The following also works,

---
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

Glossa answered 8/4, 2023 at 15:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.