问题描述
使用 Rmarkdown 构建包含引文的 pdf 时,默认会删除引文的超链接.
when using Rmarkdown to build a pdf with citations included, it removes the hyperlinks of the citations by default.
查看生成的latex文件,我可以在序言中看到usepackage{hyperref},但引用如下:
Looking at the latex file produced, I can see usepackage{hyperref} in the pre-amble, but the citations look as follows:
rmd input: @sharpe
latex output: sharpe (1999)
因此它会在 pdf 中生成 非动态引用.
Thus it produces a non-dynamic citation in pdf.
我期望的乳胶输出是:citet{sharpe},它会在 pdf 中生成超链接引用.
The latex output that I would expect is: citet{sharpe}, which produces hyperlinked citation in pdf.
任何想法为什么它会像这样写出我的 bibtex 输入以及如何将其设为超链接?
Any ideas why it writes out my bibtex inputs like this and how I can make it hyperlinked?
推荐答案
默认情况下 pandoc 会渲染引文.我看到了两种选择.
By default pandoc will do the rendering of the citations. I see two alternatives.
- 在 Rmd 中使用
citet{sharpe}
而不是@sharpe
.缺点:您只能将 Rmd 渲染为 pdf. - 使用
--natbib
参数.缺点:渲染成 pdf 时,您需要一个额外的bibtex
步骤.
- Use
citet{sharpe}
in the Rmd instead of@sharpe
. Downside: you can only render the Rmd into pdf. - Use the
--natbib
argument. Downside: You need an extrabibtex
step when rendering into pdf.
更新:您还可以在 YAML 中提供选项 link-citations: true
(自 pandoc v1.16
起)并保留引用的 pandoc 语法.
Update: You can also provide the option link-citations: true
in your YAML (since pandoc v1.16
) and keep the pandoc syntax for citations.
这篇关于Rmarkdown 删除引用超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!