PetitJean
PetitJean

Reputation: 1778

Recompile ggplot2 fonts while importing to LaTeX

Is there a way to get the fonts of a R plot reformated while compiling the global .tex file?

For example something similar to the exporting option of the Inkscape software, allowing to export a .pdf_tex file containing the text along with a .pdf containing the graphics.

Thanks in advance

Upvotes: 1

Views: 217

Answers (1)

Konrad Rudolph
Konrad Rudolph

Reputation: 546083

Your best bet is to produce a plot output that is itself wholly LaTeX, rather than separating font and graphics. This is possible by using the tikz graphics device:

local({
    on.exit(dev.off())
    tikz('foo.tex')
    ggplot(iris) + aes(Petal.Width, Petal.Length) + geom_point()
})

This will output a TeX file containing graphics primitives that can be used via the TikZ package for LaTeX. The drawback is that compiling complex TikZ graphics to PDF can be quite slow; however, it is possible to cache the graphics so that they do not need to be re-compiled on every LaTeX run of the main document.

Upvotes: 1

Related Questions