2

当我在 R 中编写函数文档并引用我使用的外部包 \code{\link[package]{function}}时,它对?交互式 R 中的函数非常有用。

但后来我的 pdf 文件链接了“函数”的文本,链接只是转到我的目录。如何关闭 pdf 的这些链接?

4

1 回答 1

3

您可以利用 Rd 格式的条件文本宏。编写 R 扩展中给出的示例是 HTML 与 LaTeX 格式的一个非常简单的演示:

\if{latex}{\out{\alpha}}\ifelse{html}{\out{α}}{alpha}

条件可以用 if-then ( \if{format}{alternate}) 或 if-then-else ( \ifelse{format}{text}{alternate}) 结构来表示。因此,对于您的示例,您可能会执行以下操作:

\if{html}{\code{\link[package]{function}}}

或者:

\ifelse{html}{\code{\link[package]{function}}}{\code{function}}

注意:您还可以将多种格式表示为逗号分隔的列表,例如\ifelse{latex,html}{...}{...}.

于 2015-10-01T22:06:10.903 回答