[R] Sweave, Xfig, pdflatex and \setkeys

Kevin E. Thorpe kevin.thorpe at utoronto.ca
Tue Dec 12 19:22:47 CET 2006


David Lindelöf wrote:
> Dear useRs,
> 
> How does one include graphics created with Xfig with LaTeX fonts into
> Sweave?
> 
> If I create a graphic with Xfig with some Computer Modern fonts, I
> choose to export it as combined PDF and LaTeX. So I get two files, one
> foo.pdf with the drawings without the text and foo.pdftex with some
> LaTeX code that ensures the text lands in the right place together with
> the drawing. I'm supposed to \input{} this file in my LaTeX document.
> 
> Trouble is that Sweave defines (with \setkeys) the default width of
> \includegraphics to be 0.8 times the \textwidth. The result is that the
> graphic is scaled, but not the text.
> 
> I was looking for a way to temporarily undefine the default width of
> included graphics, but without success. Does anyone know how to undo a
> definition that has been set with \setkeys?
> 
> Or does anyone has another workaround for including xfig graphics with
> LaTeX text in Sweave?
> 
> Looking forward to your help,

If you knew what setting you needed, you could try

\setkeys{Gin}{width=whatever}

before your include, and set it back to the default afterward with

\setkeys{Gin}{width=0.8\textwidth}

I have run into this myself, but since I was also using beamer, it
wasn't at all obvious what I should try for the setting, so I don't
know if this will work.  I have used this to rescale the imported
graphics from R.  Fortunately, the graphic I created in xfig could
be completely specified in LaTeX, and so I exported it in that format
and imported it with \scalebox{0.5}{\input{xfigfile.latex}}

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Department of Public Health Sciences
Faculty of Medicine, University of Toronto
email: kevin.thorpe at utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057



More information about the R-help mailing list