# How to make Manual references appear in bibliography (citing R)

I would like to cite R in my bibliography. However I'm having trouble getting it to appear.

Here my mini.bib files contains

@Book{,
title = {ggplot2: Elegant Graphics for Data Analysis},
publisher = {Springer-Verlag New York},
year = {2016},
isbn = {978-3-319-24277-4},
url = {https://ggplot2.tidyverse.org},
}

@Manual{,
title = {R: A Language and Environment for Statistical Computing},
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
year = {2019},
url = {https://www.R-project.org/},
}


and my .tex file contains

\documentclass{article}
\usepackage{natbib}
\begin{document}
\bibliographystyle{apalike}
\bibliography{mini.bib}
\nocite{*}
\end{document}


My pdf output only cites the book, and not R. I think because it is type Manual. What can I do about this?

• You can't have two works with an empty entry key. (And you probably shouldn't have any empty entry key at all.) Write something like @Book{ggplot2, and @Manual{r-core,. – moewe May 30 at 18:42
• BTW: Technically \bibliography{mini.bib} should be \bibliography{mini}. \bibliography takes the name of the .bib file without the .bib extension. Some systems may be more forgiving an may work even if the .bib is present, but this is not something one should rely on (my MikTeX 2.9 on Win 10 usually does not find the file if you include the extension). – moewe May 30 at 18:43
• This solved my problem. This was great. Thank you – John-Henry May 30 at 18:44

Generally, all your entries must have a unique entry key. In the shown snippet the entry key for both entries is empty. This means that the second entry is simply skipped. Technically, BibTeX allows at most one entry with an empty key, but this is a really bad idea as those entries can't be cited explicitly and Biber will choke on them.

Just give your entries entry keys

@book{wickham,
title     = {ggplot2: Elegant Graphics for Data Analysis},
publisher = {Springer-Verlag},
year      = {2016},
isbn      = {978-3-319-24277-4},
url       = {https://ggplot2.tidyverse.org},
}
@manual{r-core,
title        = {R: A Language and Environment for Statistical Computing},
author       = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
year         = {2019},
url          = {https://www.R-project.org/},
}


Note also that technically \bibliography{mini.bib} should be

\bibliography{mini}


\bibliography takes the name of the .bib file without the .bib extension. Some systems may be more forgiving an may work even if the .bib is present, but this is not something one should rely on (my MikTeX 2.9 on Win 10 usually does not find the file if you include the extension).

While its is good to know that every reference should have a key, a R user should not edit bib files, at least to cite the R packages used in a report. Let R work for you.

Test.Rnw:

\documentclass{article}
\usepackage{natbib}
\begin{document}
<<echo=F,message=F>>=
bibtex::write.bib(c("ggplot2","tools"), file='test')
@
\bibliographystyle{apalike}
\bibliography{test.bib}
\nocite{*}
\end{document}


Test.pdf:

If you are more interested in the description of the package, you might also want to try this:

knitr::write_bib(names(sessionInfo()$otherPkgs),file="test.bib", tweak = F) Rcite = citation(); Rcite$key = "RCoreTeam"
write(toBibtex(Rcite),file="test.bib",append=T)


If you do not know about .Rnw files, see How to build Knitr document from the command line, or compile it with Rstudio to make the .tex and .pdf files automatically, but remember in any case that will not run bibtex. That is, one way or another, once generated the Test.tex and the first .pdf version, you should run bibtex Test, and compile again twice to solve cross-references, as in any normal LaTeX file.