In R Markdown, I want a figure caption with a linked citation in R Markdown native citation style [@ref]
. However, when I insert the [@hawking_thermodynamics_1983]
snippet at the end into the caption, it's throwing just an error:
! Missing $ inserted.
<inserted text>
$
l.94 ...iontextfoo [@hawking_thermodynamics_1983]}
pandoc.exe: Error producing PDF
Error: pandoc document conversion failed with error 43
Example:
This is my code:
---
title: "Untitled"
author: "Author"
output: pdf_document
# bibliography: bibliography.bib
references:
- id: hawking_thermodynamics_1983
author:
- family: Hawking
given: S. W.
- family: Page
given: Don. N.
publisher: Communications in Mathematical Physics
title: Thermodynamics of Black Holes in Anti-de Sitter Space.
volume: 87
type: article-journal
issued:
year: 1983
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
\begin{figure}[h]
\centering
\includegraphics[width=13cm]{example.jpg}
\caption{Captiontextfoo}\label{fig1}
\end{figure}
[@hawking_thermodynamics_1983]
# Bibliography
with this output:
I want the citation in parentheses to appear inside the figure caption, with working link to the bibliography. The bibliography should appear automatically as usual.
How could I possibly achieve this?
Notes:
- I also tried
\[@...
or w/o brackets but didn't work. - I tried also this
\caption{Captiontextfoo \cite{[@hawking_thermodynamics_1983]}}
from this answer, but didn't work as well, shows only[?]
. - R version 3.4.3 (2017-11-30)
- Platform: x86_64-w64-mingw32/x64 (64-bit)
- Running under: Windows 7 x64 (build 7601) Service Pack 1
pandoc-citeproc
built-in. you seem to use that syntax... – Colotomy