\includegraphics and \includepdf both remove all copy (text) from my (R outputted) pdf graphs, using pdfTeX

gakera today at 06:18. 1 answers, 0 views
pdftex pdf graphics

I'm using pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009) (format=pdflatex 2010.8.30) in TexMaker 2.1 on Mac OSX. I installed the whatever latex packages using the "easier" method at http://guides.macrumors.com/Installing_LaTeX_on_a_Mac - the MacTex batch.

I'm outputting some graphs to PDFs in R and want to include them in my PDF report. Both includegraphics and includepdf input the same, only the lines and colors, but not the text in the legend or the main title. What's going on?

Here is a link to my pdf: http://www.scribd.com/doc/43122065/Vf and some sample tex:




What more bla bla

I tried just this snippet of code, and I get the same results, so nothing else in my preamble should be interfering with it.

1 Answers

Sharpie 11/19/2010.

Note: I co-authored the package I am about to recommend, so this is a shameless plug.

You can try creating your graphics using the tikzDevivce which lets TeX handle all of the typesetting. This will hopefully sidestep any font issues you are having as the text in your graphics will use the same font as the body text of your paper, which is displaying fine.

To install the package in R:


Then make your graph as usual, except use tikz() instead of pdf() to start the plot output:


# Your plotting code here


The output of the tikzDevice is a .tex file containing commands required to construct your plot using TikZ---an excellent graphics package for TeX, LaTeX and ConTeXt (however, our output is currently only compatible with LaTeX). To include your plot in a paper, use \input instead of \includegraphics:

% In your preamble:

% Later on in your paper...
  \caption{Check out the spread on that distribution!}

You can also pass the standAlone=TRUE option to tikz() and the resulting .tex file will be self-contained and can be typeset by LaTeX without including it in another document.

For more information and examples, check out the package vignette.

Hope this helps!


It should be noted that the tikzDevice treats all plot text as LaTeX code. This allows you do do things like:

curve({x^2 / 2},-1,1,main="Plot of $y=\\frac{x^2}{2}$",ylab="$\\frac{x^2}{2}$")

And LaTeX will typeset the equations in your plot. This behavior has some consequences:

  • The backslash at the beginning of each LaTeX command must be escaped by another backslash as R treats backslashes as escape characters.

  • Any character that is special to LaTeX, such as #, $, %, ^, _, etc, must be escaped if you don't want it treated as a LaTeX command:

    plot(...,main="I really want the dollar sign in \\$2.99!")
  • If LaTeX code in your plot text requires special packages, you need to make the tikzDevice aware of this. See the documentation of tikzLatexPackages in section 3.1 of the vignette for details.

HighResolutionMusic.com - Download Hi-Res Songs

1 Alan Walker

Diamond Heart flac

Alan Walker. 2018. Writer: Alan Walker;Sophia Somajo;Mood Melodies;James Njie;Thomas Troelsen;Kristoffer Haugan;Edvard Normann;Anders Froen;Gunnar Greve;Yann Bargain;Victor Verpillat;Fredrik Borch Olsen.
2 Sia

I'm Still Here flac

Sia. 2018. Writer: Sia.
3 Cardi B

Taki Taki flac

Cardi B. 2018. Writer: Bava;Juan Vasquez;Vicente Saavedra;Jordan Thorpe;DJ Snake;Ozuna;Cardi B;Selena Gomez.
4 Little Mix

Woman Like Me flac

Little Mix. 2018. Writer: Nicki Minaj;Steve Mac;Ed Sheeran;Jess Glynne.
5 Halsey

Without Me flac

Halsey. 2018. Writer: Halsey;Delacey;Louis Bell;Amy Allen;Justin Timberlake;Timbaland;Scott Storch.
6 Lady Gaga

I'll Never Love Again flac

Lady Gaga. 2018. Writer: Benjamin Rice;Lady Gaga.
7 Bradley Cooper

Shallow flac

Bradley Cooper. 2018. Writer: Andrew Wyatt;Anthony Rossomando;Mark Ronson;Lady Gaga.
8 Bradley Cooper

Always Remember Us This Way flac

Bradley Cooper. 2018. Writer: Lady Gaga;Dave Cobb.
9 Kelsea Ballerini

This Feeling flac

Kelsea Ballerini. 2018. Writer: Andrew Taggart;Alex Pall;Emily Warren.
10 Mako

Rise flac

Mako. 2018. Writer: Riot Music Team;Mako;Justin Tranter.
11 Dewain Whitmore

Burn Out flac

Dewain Whitmore. 2018. Writer: Dewain Whitmore;Ilsey Juber;Emilio Behr;Martijn Garritsen.
12 Avril Lavigne

Head Above Water flac

Avril Lavigne. 2018. Writer: Stephan Moccio;Travis Clark;Avril Lavigne.
13 Khalid

Better flac

Khalid. 2018. Writer: Charlie Handsome;Jamil Chammas;Denis Kosiak;Tor Erik Hermansen;Mikkel Stoleer Eriksen;Khalid.
14 Lady Gaga

Look What I Found flac

Lady Gaga. 2018. Writer: DJ White Shadow;Nick Monson;Mark Nilan Jr;Lady Gaga.
15 Deep Chills

Run Free flac

Deep Chills. 2018.
16 Dynoro

In My Mind flac

Dynoro. 2018. Writer: Georgi Kay;Feenixpawl;Ivan Gough.
17 Charli XCX

1999 flac

Charli XCX. 2018. Writer: Charli XCX;Troye Sivan;Leland;Oscar Holter;Noonie Bao.
18 NCT 127

Regular (English Version) flac

NCT 127. 2018.
19 Lukas Graham

Love Someone flac

Lukas Graham. 2018. Writer: Don Stefano;Morten "Rissi" Ristorp;Morten "Pilo" Pilegaard;Jaramye Daniels;James Alan;David LaBrel;Lukas Forchhammer Graham.
20 Rita Ora

Let You Love Me flac

Rita Ora. 2018. Writer: Rita Ora.


Popular Tags