I'm in the process of documenting some of my functions for an R package I'm making.
I'm using roxygen markup, though that is largely irrelevant to my question.
I have put equations into my documentation using \deqn{...}
. My question is:
Is there a way to cross-reference this equation later on?
For example, in my Rd file:
\deqn{\label{test}
y = mx + b
}
Can I later do something like:
Referring to equation \ref{test}, ...
I've tried \eqref{test}
, \ref{test}
(which both get "unknown macro" and don't get linked ), and also \link{test}
(which complains it can't find function test
because it's really just for linking to other functions).
Otherwise I fear I may have to do something hacky and add in the -- (1)
and Refer to equation (1)
manually within the \deqn
etc in the Rd file...
Update
General answer appears to be "no". (awww...)
However, I can write a vignette and use "normal" latex/packages there. In any case, I've just noticed that the matrix equations I spent ages putting into my roxygen/Rd file look awful in the ?myFunction
version of the help (they show up as just-about literal latex source). Which is a shame, because they look beautiful in the pdf version of the help.
@Iterator has pointed out the existence of conditional text, so I'll do ASCII maths in the .Rd files, but Latex maths in the pdf manual/vignette.
.Rd
format is just the most basic LaTeX, and does not support the AMS extensions, I'm not sure if this is feasible. It may be that you have to use a vignette for it. – Krissiedeqn
and then just say "Refer to equation 1" in the text..but it feels so wrong!) – Lalise?myFunction
to show the maths as well -- I'll either say "For further information on the maths, see the vignette", or I'll put in the maths there too with the clunky "In the above equation..". – Lalise?myFunction
(I use the terminal). So I'll go with ASCII maths for the .Rd and proper maths in the vignette. It's a shame, though - I use roxygen so by using latex maths in the .Rd (well, in the .r file actually) I automatically get a beautiful PDF manual auto-compiled. Shame I can't say "if .Rd version, use this code; if pdf version, use this code". – Lalise