# Font Families for the R PDF Device

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

**Statistics, R, Graphics and Fun » R Language**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Motivated by the excellent R package `pgfSweave`

, I begin to notice the font families in my graphs when writing Sweave documents. The default font family for PDF graphs is `Helvetica`

, which is, in most cases (I think), inconsistent with the LaTeX font styles. Some common font families are listed in `?postscript`

, and we can take a look at them by:

for (f in c("AvantGarde", "Bookman", "Courier", "Helvetica", "Helvetica-Narrow", "NewCenturySchoolbook", "Palatino", "Times")) { pdf.options(family = f) pdf(paste(f, ".pdf", sep = "")) set.seed(123) plot(rnorm(25), pch = 1:25, xlab = "xlab family", ylab = "ylab font", main = paste("Font Families in R (PDF):", f)) text(13, 0, "Text in the Middle") mtext(sprintf("pdf.options(family = \"%s\")", f), side = 4) dev.off() }

Here is a merged PDF containing the above single PDF files:

It seems that `"Bookman"`

, `"NewCenturySchoolbook"`

, `"Palatino"`

and `"Times"`

can be better choices when using Sweave because they are serif fonts, which are usually more consistent with LaTeX PDF.

## Related Posts

To

**leave a comment**for the author, please follow the link and comment on their blog:**Statistics, R, Graphics and Fun » R Language**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.