Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
631 views
in Technique[技术] by (71.8m points)

knitr - Add author affiliation in R markdown beamer presentation

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...