Reputation: 1677
When I write function documentation in R and I reference an external package I use \code{\link[package]{function}}
and that works great for the ?
function in interactive R.
But then my pdf files have linked text for "function" and the link just goes to my table of contents. How can I turn off these links for the pdf?
Upvotes: 2
Views: 872
Reputation: 44555
You can take advantage of the conditional text macros in the Rd format. The example given in Writing R Extensions is a quite simple demonstration of HTML versus LaTeX format:
\if{latex}{\out{\alpha}}\ifelse{html}{\out{α}}{alpha}
The conditionality can be expressed in an if-then (\if{format}{alternate}
) or if-then-else (\ifelse{format}{text}{alternate}
) structure. So, for your example, you might do something like:
\if{html}{\code{\link[package]{function}}}
or:
\ifelse{html}{\code{\link[package]{function}}}{\code{function}}
Note: You can also express multiple formats as a comma-separated list such as \ifelse{latex,html}{...}{...}
.
Upvotes: 3