but this didn't work either. I presume I don't have correct packages loaded, but I don't know how to get the bibliographies using R Markdown, knitr, and LaTeX.
Are you using Rmarkdown file to produce PDF output ?
The last chunk should have work in a .Rmd file
---
title: Test
author: cderv
output: pdf_document
bibliography: packages.bib
---
```{r, include = FALSE}
# Just creating a bib file for the example
knitr::write_bib("knitr", "packages.bib")
```
Use a citation from your bib file:
See @R-knitr
# References
We need more details on the issue if you have one.
Thanks for your response. I am using a .Rnw file and the .bib file is already created. This is what I tried
---
title: Test
author: David
output: pdf_document
bibliography: myref.bib
---
<<echo=TRUE,include=FALSE>>=
# Just creating a bib file for the example
knitr::write_bib("knitr", "myref.bib")
@
On the first page of the document, it printed
|title: Test author: David output: pdfdocumentbibliography : myref:bib
YAML header won't work with Rnw file. You are mixing some Rmarkdown and knitr feature here. Pandoc is not involved when using Rnw file so bibliography field can't work. And YAML header is not supported for Rnw file. It is for .Rmd only.
About Rnw:
This is for advanced usage when what you could get with Rmarkdown and .Rmd file with rmarkdown::latex_document() to get just a tex file or rmarkdown::pdf_document() as usually people wants the PDF output.
If you stick to Rnw, you would need to include the bib using directly a Latex command.
Thank you. So, just putting in a LaTeX line \bibliography{myref} seems to work. However, although it generates the Reference section, it does not insert the references in the text itself as it does when I'm using LaTeX outside of the R Markdown environment. This happens even when I typeset the document twice, which I need to do if I'm outside the Markdown environment.
On a similar topic if I have an equation that I have references with a label , for example
I am not sure to understand: If you are using Rnw file format, you are not using Markdown syntax. If you are using Rmd format, then you are using Rmd syntax.
I was under the impression you were using Rnw format so no markdown, but you talk about "outside markdown".
Which one are you using ? What are you trying to do ?
With Rmarkdown, you can use bibliography like that
by citing in the text using @key
For equation using Rmd document, you need to use one of the bookdown format to get the reference and numbering feature. See
Sorry for the confusion. I am using a .Rnw file format. I have the .Rnw file weaved using Knitr. Also, I have tinytex clicked.
My references are showing up nicely in a reference section using the LaTeX command \bibliography{}. The problem is that the references are not showing up inline. I get this.
It is an interesting historical fact that the inverse probability theorem was actually
developed by the mathematician Pierre-Simon Laplace (?, ?).
The citation to Laplace shows up in the Reference section, but not here inline.
Also, equation numbers are not showing up inline. Specifically, the equation is