Quantcast

Passing a LaTeX length to Sweave

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Passing a LaTeX length to Sweave

Thomas Levine
I'd really love to do this

\setkeys{Gin}{width=\columnwidth}
<<label=something,fig=TRUE,echo=FALSE,width=\columnwidth,height=0.3\columnwidth>>=
plot(y~x)
@

The \columnwidth macro does not work, of course, in the second line.
What can I do instead?

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Passing a LaTeX length to Sweave

Sharpie
Thomas Levine wrote
I'd really love to do this

\setkeys{Gin}{width=\columnwidth}
<<label=something,fig=TRUE,echo=FALSE,width=\columnwidth,height=0.3\columnwidth>>=
plot(y~x)
@

The \columnwidth macro does not work, of course, in the second line.
What can I do instead?
This may be difficult as there is no two-way communication between R and LaTeX in the current implementation of Sweave.  In fact, there is hardly any communication at all- Sweave is just a preprocessor that turns .Rnw files into .tex files.

Basically, there is no way to "fetch" the current value of \columnwidth because LaTeX is not even running during the time that Sweave is processing the file.

Two-way communication is certainly possible, Cameron and I implemented an R <-> LaTeX callback to provide accurate font metrics to the R tikzDevice, but as far as I can tell this feature would need to be implemented as an extension to the current Sweave system.

-Charlie
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Passing a LaTeX length to Sweave

Duncan Murdoch-2
In reply to this post by Thomas Levine
On 10/07/2010 10:35 AM, Thomas Levine wrote:

> I'd really love to do this
>
> \setkeys{Gin}{width=\columnwidth}
> <<label=something,fig=TRUE,echo=FALSE,width=\columnwidth,height=0.3\columnwidth>>=
> plot(y~x)
> @
>
> The \columnwidth macro does not work, of course, in the second line.
> What can I do instead?
>  

Pass a number.  As long as it's reasonably close to the truth the graphs
will be resized and things will be fine.

Duncan Murdoch
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Passing a LaTeX length to Sweave

Thomas Levine
Darn. Well here's what I'll do

%Preamble
<<lengths>>=
columnwidth=whatever the \columnwidth is
@

%Figures
\setkeys{Gin}{width=\columnwidth}
<<label=something,fig=TRUE,echo=FALSE,width=columnwidth,height=0.3*columnwidth>>=
plot(y~x)
@

It needs to be exact so that the line weight and point size are
consistent across figures and with the text.

2010/7/10 Duncan Murdoch <[hidden email]>:

> On 10/07/2010 10:35 AM, Thomas Levine wrote:
>>
>> I'd really love to do this
>>
>> \setkeys{Gin}{width=\columnwidth}
>>
>> <<label=something,fig=TRUE,echo=FALSE,width=\columnwidth,height=0.3\columnwidth>>=
>> plot(y~x)
>> @
>>
>> The \columnwidth macro does not work, of course, in the second line.
>> What can I do instead?
>>
>
> Pass a number.  As long as it's reasonably close to the truth the graphs
> will be resized and things will be fine.
>
> Duncan Murdoch
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...