我正在 RStudio 中创建一个名为 test.Rnw 的文档,其 MWE 如下:
\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}
运行 knit("test.Rnw") 后,我得到一个 test.tex 文件以及一个名为“figure”的文件夹,其中包含钻石图像(“diamondData-1.pdf”)。
之后,我运行 pdflatex test.text 来获取 test.pdf 文件。
我有一个由两部分组成的问题:
1) 我的图形标题的文本(“图 1:钻石数据集具有变量深度和价格。”)显示为灰色而不是黑色(就像文档其余部分中的文本一样)。有办法纠正这个问题吗?
2)有没有一种方法可以生成菱形图形,以便它自动嵌入到文档中?当我运行 pdflatex 来获取 test.pdf 文件时,我随后必须删除文件夹/diamondData-1.pdf 文件。如果不必拥有folder/diamondData-1.pdf 文件,那就太好了。如果没有,是否有一种方法/选项,以便当我运行 pdflatex 时,在创建 test.pdf 文件后,文件夹/diamondData-1.pdf 文件会自动删除?