ggplot2:为什么半透明+ pdflatex 会导致比普通 PDF 字体更重?
我遇到了一个问题pdf()
在 R 中输入,然后pdflatex
-ing ggplot2 图像会导致同一页面上的所有文本与图像变得粗体,但仅当alpha
require("ggplot2")
"%_%" <- function(a, b) paste(a, b, sep="")
test <- function(filename, alpha)
{
pdf(filename %_% "-fig.pdf")
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point(alpha=alpha)
print(p); dev.off()
latexDocument <- c(
"\\documentclass{article}",
"\\usepackage{Sweave}",
"%\\pdfpageattr{/Group <</S /Transparency /I true /CS /DeviceRGB>>}",
"\\begin{document}",
"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"\\begin{figure}",
"\\includegraphics{" %_% filename %_% "-fig}",
" \\caption{Figure Caption}",
"\\end{figure}",
"\\end{document}")
con <- file(filename %_% ".tex"); writeLines(latexDocument, con); close(con)
system("pdflatex " %_% filename)
}
test("test1", 1)
test("test2", 0.3)
比较输出文件测试1.pdf and 测试2.pdf,我注意到在 Acrobat 或 Acrobat Reader 中查看时,后一个文档具有较重的字体。问题已经讨论过了here https://stackoverflow.com/questions/5752170/ggplot2-adding-alpha-parameter-makes-all-other-text-darker-bold-in-pdf之前,但没有解决。
我似乎无法解决这个问题,这弄乱了我用 Sweave 生成的报告的外观。有人对此有任何见解吗?我在 Windows 上使用 R 版本 2.13.1。