简体   繁体   中英

rMarkdown: change fontsize for Beamer

I am moving my workflow to R/RMarkdown that outputs Beamer slides. I give about 60 presentations per year, and I'm loving the automated flow. However, I need to increase the base font size in my Beamer output. Using the code below, the size of the bullet-pointed text is indifferent to the value in fontsize. I can input 12pt or 24pt, and the option changes in the .tex file, but there is no change in the resulting Beamer pdf. I'm compiling from within RStudio in win10.

title: "Title"
author: "Matthew C. Roberts"
date: "October 2016"
fontsize: 12pt
output: 
    beamer_presentation:
---

## Blah

* Hi, my name is Matt
* This is a bullet point
    + so is this
    + this is fontsize

As @samcarter_is_at_topanswers.xyz writes in his comment, it is correct to use the option fontsize ; but you just cannot use arbitrary numbers. At the moment, only the numbers 8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt and 20pt work (see the documentation beameruserguide.pdf that comes with beamer, Section 18.2 "Font Changes Made Without Using Font Themes"). So you should check whether 20pt are enough.

Another strategy is to fiddle with the paper geometry. The default is that slides are of format 128mm by 96mm. If you specify smaller values, then, obviously, the font size will appear larger in full screen mode. However, beameruserguide.pdf advises against this strategy (in Section 8.3 "Margins and Sizes").

This is a bit of a workaround but this is how I got it to work and also got it to work for a colleague.

  1. Add the following to the meta:

     output: beamer_presentation: keep_tex: TRUE
  2. Run the rmarkdown as usual

  3. Open the result .tex file in TexWorks
  4. Change the fontsize to a random number in the .tex file. The fontsize can be found on the very first line in the document.
  5. Compile it in TexWorks (Press the green play button)
  6. I had to install a specific package when I did this, my colleague didn't. I can't remember the name but it had to do with fonts anyway. If it comes up install it.
  7. repeat steps 4 and 5.
  8. Go back to the Rmarkdown and change the fontsize there.
  9. Run the markdown.

It should now work fine with changing the fontsize. You can also remove the keep_text: TRUE from the meta if you don't want it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM