I am not sure whether this an R, LaTeX, or BibTex problem.
I am trying to automatically generate a .bib file containing citations for R packages and then list them at the end. I am able to generate the BibTex file and I don't see anything wrong with the BibTex file, but the entries don't appear when I compile the PDF.
I'm not sure if R is not producing a BibTex file correctly, if some LaTeX syntax is wrong, or if the BibTex file needs to be pre-compiled or whatever. I noticed that \bibliography{NOT A REAL FILENAME}
will produce a References section without complaining, but I don't think that is the problem.
Minimal working example:
\documentclass[10pt]{amsart}
\usepackage[margin=1in, headheight=20pt, footskip=20pt]{geometry}
\begin{document}
<<label='Create References'>>=
require(knitr) # Needed for write_bib()
# Load some packages to the session:
require(xtable)
require(ggplot2)
# Select packages to cite:
citPkgs <- names(sessionInfo()$otherPkgs)
# Write the bibtex file:
write_bib(citPkgs, file="R-Pckgs.bib")
@
\nocite{*}
\bibliographystyle{plain}
\bibliography{R-Pckgs.bib}
\end{document}
Any help or suggestions would be appreciated.
To cite the 'rmarkdown' package in publications, please use: JJ Allaire and Yihui Xie and Jonathan McPherson and Javier Luraschi and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and Winston Chang and Richard Iannone (2020). rmarkdown: Dynamic Documents for R. R package version 2.5.
Run your search, and export your marked results in BibTeX format. Browse for the . bib file and click Add. In the Content section, choose from the dropdown to select all references or only those that are cited.
Just replace \bibliography{R-Pckgs.bib}
with \bibliography{R-Pckgs}
, and it should work fine.
On Windows 7, with an up-to-date MikTeX installation and current R and R packages, the following worked:
"eg.Rnw"
and edit to remove the extraneous ".bib"
"eg.Rnw"
is located.library(knitr); knit2pdf("eg.Rnw")
Note: There are obviously many workflows for going from *.Rnw
to *.pdf
, but if you want to use knit2pdf()
(at least), make sure that you run it from the directory containing the *.Rnw
to be processed.
Add a \nocite{dummycite}
to your document - to create a citation so that the bibliography is printed.
Note that this is obsolete if you already have other citation in your document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With