I am creating a document called test.Rnw in RStudio, with a MWE as follows:
\documentclass[12pt,english,nohyper]{tufte-handout}
\usepackage{tabularx}
\usepackage{longtable}
\begin{document}
<<setup, echo = FALSE>>=
library(knitr)
library(xtable)
library(ggplot2)
@
<<diamondData, echo=FALSE, fig.env = "marginfigure", out.width = "0.95\\linewidth", fig.cap = "The diamond dataset has varibles depth and price.", fig.lp = "mar:">>=
print(qplot(depth,price,data=diamonds))
@
<<echo=FALSE,results='asis'>>=
myDF <- data.frame(a = rnorm(1:10), b = letters[1:10])
print(xtable(myDF, caption= 'This data frame shows ten random variables from the normal distribution and a corresponding letter', label='tab:dataFrame'), floating = FALSE, tabular.environment = "longtable", include.rownames=FALSE)
@
Figure \ref{mar:diamondData} shows the diamonds data set, with the variables price and depth. Table \ref{tab:dataFrame} shows letters a through j corresponding to a random variable from a normal distribution.
\end{document}
After I run knit("test.Rnw"), I get a test.tex file as well as a folder called "figure" with the diamonds image in it ("diamondData-1.pdf").
After that, I run pdflatex test.text to get a test.pdf file.
I have a two-part question:
1) The text of my figure caption ("Figure 1: The diamond dataset has variables depth and price.") appears gray instead of black (like the text in the rest of the document). Is there a way to correct this?
2) Is there a method to generate the diamond figure so that it is automatically embedded in the document? When I run pdflatex to get the test.pdf file, I afterward must delete the folder/diamondData-1.pdf file. It would be nice to not have to have the folder/diamondData-1.pdf file. If not, is there a method/option so that when I run pdflatex, after the test.pdf file is created, then the folder/diamondData-1.pdf file is automatically deleted?