I am looking for at way to plot graphs in R, using LaTeX fonts.
In the documentation for pdfFonts
in R, it states that:
There are also mappings for "ComputerModern", "ComputerModernItalic" and, as from R 3.1.0, "ArialMT" (Monotype Arial).
When using pdf(file = outputFile, width=11.692, height=8.267, family = "ComputerModern")
I get the following error message:
Error in pdf(file = outputFile, width = 11.692, height = 8.267, family = "ComputerModern", :
unknown family 'ComputerModern'
Execution halted
I am using R version 3.2.2 (2015-08-14)
. How can I use LaTeX fonts in R? Preferable without installing extra libraries.
Best Answer
This is how I did it in Windows:
extrafont
package.font_import()
can't handle OTF.font_import()
.loadfonts(device = "win")
. Use thedevice = "Win"
parameter to make the preview in R Studio work.par(family = "LM Roman 10")
.This is the full code you need to use:
R Studio preview:

Exported pdf:
