I have a new Windows 10 Dell laptop (i7 CPU) with the latest Versions of RStudio (Version 1.3.1056), R (4.0.1) and TexLive (2020). I am using knitr to write my reports and it works fine as long as I don't have references, and citations. If these are included in the document, a tex file is created but does not compile. I am using "Weave Rnw files using knitr" and "Typeset LaTeX into PDF using XeLaTeX". If I compile that .tex file in say WinEdt - it works fine and complies the document without any changes.
Here is an example of what I use:
testing.rnw
\documentclass[a4paper, 10pt, fleqn]{article}
\usepackage[paper = a4paper, left = 25mm, width = 160mm, top = 25mm, bottom = 25mm]{geometry}
\usepackage{apacite}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{graphics}
\usepackage[utf8]{inputenc}
\setlength{\parindent}{0em}
\setlength{\parskip}{14pt}
\usepackage{booktabs}
\usepackage[dvipsnames]{xcolor}
\usepackage{colortbl}
\usepackage{longtable}
\usepackage[light]{iwona}
\usepackage[T1]{fontenc}
\begin{document}
A linear mixed model using restricted maximum likelihood were used to
analyse the data using ASReml-R \cite{asremlr}. The model can symbolically be written as:
\begin{center}
\textsf{response \sim Site + Treatment + Site:Treatment + \emph{Replicate} }
\end{center}
\clearpage
\bibliographystyle{apacite}
\bibliography{ref2}
\end{document}
ref2.bib
@Manual{asremlr,
title = {asreml: asreml() fits the linear mixed model},
author = {David Butler},
year = {2009},
note = {R package version 3.0},
url = {www.vsni.co.uk},
}
@Manual{r,
title = {R: A Language and Environment for Statistical Computing},
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2016},
url = {https://www.R-project.org/},
}
The error says "There were undefined references". I should also say that I have tried using tinytex and Miktex but these have not helped. Can anyone help me to get this working properly, please?