I am using Sweave in RStudio to build a pdf with the following settings:
Weave Rnw files using: knitr
Typeset LaTeX into PDF using: pdfLaTeX
I am also on Windows and using MiKTeX.
The pdf successfully compiles each time, with the exception of the citations, which are appearing as [? ].
Here is an example of the file, called filename.rnw:
<<setup-knitr, cache=FALSE, include=FALSE>>=
library(knitr)
@
\documentclass{article}
\begin{document}
The lumen is calculated by weighting a spectra of light by the photopic luminosity function \cite{CVRL2008}
\reftitle{References}
\externalbibliography{yes}
\bibliography{bibliography}
\end{document}
With the following bibliography (bibliography.bib) file:
@misc{CVRL2008,
title = "CIE (2008) physiologically-relevant 2-deg V($\lambda$) luminous efficiency functions",
author = "CVRL",
organization = "The Colour & Vision Research laboratory",
type = "Database",
howpublished = "ONLINE",
year = "2008",
url = "http://www.cvrl.org/"
}
And here is the .pdf that is built
"The lumen is calculated by weighting a spectra of light by the photopic luminosity function [?]
References"
I first resolved this issue with the following steps:
Ensuring that MiKTeX was installed in the same directory as R & RStudio,
Making sure the user/administrator updates were not out of sync in MiKTeX
Switching to admin mode
Running the following commands in Command Prompt, in accordance with this thread (https://tex.stackexchange.com/questions/63852/question-mark-or-bold-citation-key-instead-of-citation-number):
latex filename
bibtex filename
latex filename
latex filename
Compiling the .pdf
However, every time I add an additional reference I need to run bibtex and latex in the command prompt to update the .bbl file, so the references will appear in the .pdf when I compile it.
Is there a way to permanently fix this?
Any help would be greatly appreciated.