[R] Sweave: pass scale parameter to includegraphics?

Christophe Declercq cdeclercq at nordnet.fr
Tue Jul 29 10:05:06 CEST 2003


Peter,

To set the width of included graphics in your LaTeX document, see the Sweave
manual: http://www.ci.tuwien.ac.at/~leisch/Sweave/Sweave-manual-20030624.pdf

'It also sets the default LATEX figure width (which is
independent of the size of the generated EPS and PDF files).
The current default is \setkeys{Gin}{width=0.8\textwidth} if
you want to use another width for the figures that are
automatically generated and included by Sweave, simply add a
line similar to the one above after \begin{document}.'

Hope it helps.

Christophe
--
Christophe DECLERCQ, MD
Observatoire Régional de la Santé Nord-Pas-de-Calais
13, rue Faidherbe 59046 LILLE Cedex FRANCE
Phone +33 3 20 15 49 24
Fax   +33 3 20 55 92 30
E-mail c.declercq at orsnpdc.org


> De : r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]De la part de Peter Dunn
> Envoyé : mardi 29 juillet 2003 07:24
> À : R mailing list
> Objet : [R] Sweave: pass scale parameter to includegraphics?
>
>
> Hi all
>
> I'm using Sweave and find it a treat.  But one
> question:
>
> I use Sweave to create my pictures which are
> automatically included into LaTeX.  For example,
> in the file  test.Snw,  I may have:
>
> % LaTeX stuff
> \begin{figure}
> <<fig=true,width=5,height=5>>=
> x1 <- seq(1,5, length=10)
> x2 <- sin(x1)
> plot(x1,x2)
> @
> \caption{Plot}
> \end{figure}
> % More LaTeX
>
> This produces the LaTeX file test.tex with the
> (example) chuck:
>
> % LaTeX stuff
> \begin{figure}
> \includegraphics{test-001}
> \caption{Plot}
> \end{figure}
> % More LaTeX stuff
>
> But what if I want the chunk to be, for example,
>    \includegraphics[scale=0.6]{test-001}
> rather than the standard, no frills \includegraphics
> command?  (Why?  Because I create a picture that I
> want small!  Changing  width  and  height within the
> <<>>= only changes the appearance of the picture--it
> alters the x11 window the plot is produced in, not
> the final size in my document.)
>
> How can I inform Sweave to create this in the
> LaTeX code (not universally, but in the occasional
> picture)?  More generally, how can I inform Sweave
> to pass these types of parameters to the
> \includegraphics command?
>
> I have searched archives and all the (obvious to me)
> places, but haven't found the solution.
>
> Thanks again,
>
> P.
>
> --
> Dr Peter Dunn          (USQ CRICOS No. 00244B)
>   Web:    http://www.sci.usq.edu.au/staff/dunn
>   Email:  dunn @ usq.edu.au
> Opinions expressed are mine, not those of USQ.  Obviously...
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>




More information about the R-help mailing list