Skip to content

Sweave, Xfig, pdflatex and \setkeys

4 messages · David Lindelöf, Kevin E. Thorpe, Friedrich Leisch

#
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,
--
--------------------------------------------------
David Lindel?f
Station 18
LESO-PB/EPFL
1015 Lausanne
tel +41-21-693.5556
mob +41-79-415.6641
fax +41-21-693.2722
e-mail david.lindelof at epfl.ch
url http://lesowww.epfl.ch/doctorants/lindelof/
weblog http://visnet.ch/~lindelof/smartbuildings/
--------------------------------------------------

In the force if Yoda's so strong, construct a sentence with words in
the proper order then why can't he?
#
David Lindel?f wrote:
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}}
#
On Tue, 2006-12-12 at 13:22 -0500, Kevin E. Thorpe wrote:
Yes, but the trouble is that for arbitrary figures created with Xfig I
cannot know what the correct width is going to be. And I could not find
any help on how to undefine variables set with \setkeys.
But then you are severly limited, aren't you? For instance, you cannot
draw lines with slopes other that multiples of 45 degrees?

Cheers,
--
--------------------------------------------------
David Lindel?f
Station 18
LESO-PB/EPFL
1015 Lausanne
tel +41-21-693.5556
mob +41-79-415.6641
fax +41-21-693.2722
e-mail david.lindelof at epfl.ch
url http://lesowww.epfl.ch/doctorants/lindelof/
weblog http://visnet.ch/~lindelof/smartbuildings/
--------------------------------------------------

COBOL:
	An exercise in Artificial Inelegance.
#

        
> On Tue, 2006-12-12 at 13:22 -0500, Kevin E. Thorpe wrote:
>> > 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?

  >> 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}

  > Yes, but the trouble is that for arbitrary figures created with Xfig I
  > cannot know what the correct width is going to be. And I could not find
  > any help on how to undefine variables set with \setkeys.

Yes, I should document Sweave.sty much better ...

  \usepackage[nogin]{Sweave}

in your .Rnw file will do the trick, i.e., not set any Gin keys.

HTH,
Fritz