Re: [R] Adding LaTeX cross-references into Sweave plots

2008-02-27 Thread Mark Wardle
Hi.

I don't use figure titles (*) when generating figures for inclusion in
a latex document. Instead, I rely on the latex caption. Otherwise, one
has two titles for a figure.

If you want multiple plots with separate captions, then try subfigures.

Best wishes,

Mark

(*): try main=""

On 27/02/2008, Peter Dunn <[EMAIL PROTECTED]> wrote:
> Hi all
>
>  I'm using Sweave and LaTeX, and love how they interact.
>
>  But here's a different interaction I'm not sure how to achieve; I
>  hope someone can help.  I use a simple example, of course, to
>  demonstrate.
>
>  Suppose in my LaTeX document I have this:
>
> Here is a linear equation:
> \begin{equation}
> y = -1 + 3 x
> \label{EQ:example}
> \end{equation}
>
>  This appears in the final product with an Equation number, say (1).
>
>  Now suppose I wish to produce a graphic in R:
>
> <>=
> plot( c(-1,1), c(-1,1), type="n",
> main="Graph of Eq (1)")
> abline(-1, 3)
> @
>
>  All easy.
>
>  But... how to I ensure the correct LaTeX label appears in the plot?
>  You see, if I run LaTeX again, and my equation is no longer
>  labelled (1) and changes to (say) label (3), I have to manually fix
>  the Sweave code to read
>
> <>=
> plot( c(-1,1), c(-1,1), type="n",
> main="Graph of Eq (3)")
> abline(-1, 3)
> @
>
>  Any ideas of how that can be automated?  I guess something like this
>  (though this obviously will fail):
>
>
> <>=
> plot( c(-1,1), c(-1,1), type="n",
> main="Graph of Eq (\label{EQ:equation})")
> abline(-1, 3)
> @
>
>  Thanks as always.
>
>  P.
>
>  --
>  Dr Peter Dunn  |  dunn  usq.edu.au
>  Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
>  Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc
>
>  This email (including any attached files) is confidentia...{{dropped:15}}
>
>  __
>  R-help@r-project.org 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.
>
>
>  __
>  This email has been scanned by the MessageLabs Email Security System.
>  For more information please visit http://www.messagelabs.com/email
>  __
>


-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK

__
R-help@r-project.org 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.


Re: [R] Adding LaTeX cross-references into Sweave plots

2008-02-26 Thread Duncan Murdoch
Peter Dunn wrote:
> Hi all
>
> I'm using Sweave and LaTeX, and love how they interact.
>
> But here's a different interaction I'm not sure how to achieve; I 
> hope someone can help.  I use a simple example, of course, to 
> demonstrate.
>
> Suppose in my LaTeX document I have this:
>
>   Here is a linear equation:
>   \begin{equation}
>   y = -1 + 3 x
>   \label{EQ:example}
>   \end{equation}
>
> This appears in the final product with an Equation number, say (1).
>
> Now suppose I wish to produce a graphic in R:
>
>   <>=
>   plot( c(-1,1), c(-1,1), type="n", 
>   main="Graph of Eq (1)")
>   abline(-1, 3)
>   @
>
> All easy.
>
> But... how to I ensure the correct LaTeX label appears in the plot?  
> You see, if I run LaTeX again, and my equation is no longer 
> labelled (1) and changes to (say) label (3), I have to manually fix 
> the Sweave code to read
>
>   <>=
>   plot( c(-1,1), c(-1,1), type="n", 
>   main="Graph of Eq (3)")
>   abline(-1, 3)
>   @
>
> Any ideas of how that can be automated?  I guess something like this 
> (though this obviously will fail):
>
>
>   <>=
>   plot( c(-1,1), c(-1,1), type="n", 
>   main="Graph of Eq (\label{EQ:equation})")
>   abline(-1, 3)
>   @
>
> Thanks as always.
>   
I don't think there's a reasonable way to do this.  If you want to be 
unreasonable, you could execute R code to read the .aux file produced 
from a previous LaTeX run (which is how LaTeX handles references).  I'd 
say a better approach is just not to use a main title, use the figure 
caption to include the equation number.

Duncan Murdoch

__
R-help@r-project.org 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.


[R] Adding LaTeX cross-references into Sweave plots

2008-02-26 Thread Peter Dunn
Hi all

I'm using Sweave and LaTeX, and love how they interact.

But here's a different interaction I'm not sure how to achieve; I 
hope someone can help.  I use a simple example, of course, to 
demonstrate.

Suppose in my LaTeX document I have this:

Here is a linear equation:
\begin{equation}
y = -1 + 3 x
\label{EQ:example}
\end{equation}

This appears in the final product with an Equation number, say (1).

Now suppose I wish to produce a graphic in R:

<>=
plot( c(-1,1), c(-1,1), type="n", 
main="Graph of Eq (1)")
abline(-1, 3)
@

All easy.

But... how to I ensure the correct LaTeX label appears in the plot?  
You see, if I run LaTeX again, and my equation is no longer 
labelled (1) and changes to (say) label (3), I have to manually fix 
the Sweave code to read

<>=
plot( c(-1,1), c(-1,1), type="n", 
main="Graph of Eq (3)")
abline(-1, 3)
@

Any ideas of how that can be automated?  I guess something like this 
(though this obviously will fail):


<>=
plot( c(-1,1), c(-1,1), type="n", 
main="Graph of Eq (\label{EQ:equation})")
abline(-1, 3)
@

Thanks as always.

P.

-- 
Dr Peter Dunn  |  dunn  usq.edu.au
Faculty of Sciences, USQ; http://www.sci.usq.edu.au/staff/dunn
Aust. Centre for Sustainable Catchments: www.usq.edu.au/acsc

This email (including any attached files) is confidentia...{{dropped:15}}

__
R-help@r-project.org 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.