我有问题,获得正确的pdf输出的数字图例,其中包含一个网址。它的工作方式是bookdown::gitbook,而不是bookdown::pdf_book。
下面是一个示例:
---
output: bookdown::pdf_book
---
## Reference with URL doesn't work
In this experiment, we will use a [spectrophotometer] (https://en.wikipedia.org/wiki/Spectrophotometry) to measure the absorption of light of different wavelength by colored solutions.
(ref:spectrum) [Spectrum of light. V, violet; B, blue; G, green Y, yellow; O, orange; R, red](https://commons.wikimedia.org/wiki/File:Linear_visible_spectrum.svg)
```{r spectrum, fig.cap='(ref:spectrum)', echo=FALSE, message=FALSE, warning=FALSE}knitr::include_graphics("./figures/photosynthesis/spectrum.png")
## Reference without URL does work
In this experiment, we will use a [spectrophotometer] (https://en.wikipedia.org/wiki/Spectrophotometry) to measure the absorption of light of different wavelength by colored solutions.
(ref:spectrumNOurl) Spectrum of light. V, violet; B, blue; G, green Y, yellow; O, orange; R, red.
```{r spectrumNOurl, fig.cap='(ref:spectrumNOurl)', echo=FALSE, message=FALSE, warning=FALSE}knitr::include_graphics("./figures/photosynthesis/spectrum.png")
我想要的是图形传奇出现在例子中,没有url,但在脚注中有一个到url的上标。
附加信息
我在MacBook Pro 13的OS (10.13.5Beta)上使用bookdown (0.7.8)、rstudio (1.1.423)和Pandoc2.1.3。
我已尽我所能解决这个问题。我将所有Pandoc的评级降到了1.x版本,这是随bookdown而来的,但也遇到了同样的问题。不管我是使用pdflatex还是xelatex作为引擎,都不重要。
发布于 2018-04-30 09:41:38
这里有两个问题:
1.添加超链接作为脚注
默认情况下,输出LaTeX文档将不显示超链接。我们可以使用href命令重新定义LaTeX的工作方式。您可以将以下行添加到您的preamble.tex中,或者将其直接嵌入到标头中:
\let\oldhref\href
- \renewcommand{\href}[2]{#2\footnote{\url{#1}}}在YAML标题中使用此方法:
---
output: bookdown::pdf_book
header-includes:
- \let\oldhref\href
- \renewcommand{\href}[2]{#2\footnote{\url{#1}}}
---如果您喜欢将它保存为一个单独的文件(我建议使用更大的项目),您可以使用:
header-includes: preamble.tex2.在标题中不起作用的文本引用
造成此问题的原因是文本引用似乎不能包含任何特殊字符,包括_和-。我将此作为另一个问题提出,因为这似乎是您问题的一个具体子问题:如果URL包含特殊字符,则Bookdown文本引用不起作用。
解决这一问题的最简单方法似乎是使用像这这样的服务缩短URL。它是免费的,链接不会过期。
这里有一个部分有效的解决方案。Stackoverflow不允许包含来自google的URL,所以您必须用链接替换缩短的URL。
---
output: bookdown::pdf_book
header-includes:
- \let\oldhref\href
- \renewcommand{\href}[2]{#2\footnote{\url{#1}}}
---
The references work fine when not used within a text reference [Spectrum of light. V, violet; B, blue; G, green Y, yellow](https://commons.wikimedia.org/wiki/File:Linear_visible_spectrum.svg)
(ref:spectrum) [Spectrum of light. V, violet; B, blue; G, green Y, yellow](Shortened URL)
```{r spectrum, fig.cap='(ref:spectrum)', echo=FALSE, message=FALSE, warning=FALSE}阴谋(汽车)

我说这是部分工作:正如您所看到的,我们现在有了URL的脚注,但是标题中的脚注实际上并没有显示在页脚中!
我认为你最好的选择是使用参考书目,并在@ref中引用引用的数字。检查这里:https://bookdown.org/yihui/bookdown/citations.html
https://stackoverflow.com/questions/49990699
复制相似问题