I'm writing a document in R Markdown and use a Bibtex library for my citations. They work fine when I use them in the text, but give me trouble when I try to implement them in a figure caption.
The Bibtex reference is:
@book{TEST,
title = {R for Data Science},
author = {Test Person},
year = {2018},
}
How it works:
```{r carplot, echo=F, warning=F, fig.cap="This is a Test [@TEST]"}
plot(cars)
```
How it gets broken:
```{r carplot, echo=F, warning=F, fig.cap="This is a Test [@TEST]", fig.align="right"}
plot(cars)
```
I've tried other code chunk options like out.width=".7\\textwidth"
and out.extra = 'trim = {0 1.1cm 0 0}, clip'
which both cause the citation to break as well. Chunk options like echo=F
and warning=F
don't seem to be a problem though.
Any Ideas how i can put figure options in the code chunk options whithout it breaking my citation?
I have found a working solution for my problem, even though I still don't unterstand how it was caused in the first place. But for anybody looking for a workaround in the future, here is how I managed to do it:
(ref:CAP1) This is a Test [@TEST]
```{r carplot, echo=F, warning=F, fig.cap="(ref:CAP1)", fig.align="right"}
plot(cars)
```
Like this, the fig.align="right"
does not seem to be a problem anymore.