如何解决在 rbookdown 的图参考标题中嵌入 https 链接
不确定这是如何完成的,但我在图片的标题中有一些引文和来源链接。但是,以下内容似乎不起作用:
(ref:my-caption) This is a [google link](https://google.com) in the caption of the figure.
```{r gim,fig.cap="(ref:my-caption)",fig.align='center',fig.asp=0.75,echo=FALSE,out.width='85%'}
knitr::include_graphics("./google-images.png")
```
来自 rbookdown 构建的错误包括:
! Argument of \caption@ydblarg has an extra }.
<inserted text>
\par
l.338 ...ogle link} in the caption of the figure.}
\label{fig:gim}
解决方法
你可以试试这个:
```{r gim,fig.cap=paste(ref_caption),fig.align='center',fig.asp=0.75,echo=FALSE,out.width='85%'}
ref_caption <- "This is a \\href{https://google.com}{google link} in the caption of the figure."
knitr::include_graphics("./google-images.png")
```
,
虽然@bttomio 提供的解决方案并没有完全解决问题,但对其进行小幅修改却起到了很大的作用!我跟进了 here 提供的解决方案,结果如下:
```{r gim,out.width='85%'}
ref_caption <- "This is a \\protect\\href{https://google.com}{google link} in the caption of the figure."
knitr::include_graphics("./google-images.png")
```
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。