title: ggplot2: Why Does Semi-Transparency + pdflatex Cause Heavier-Than-Normal PDF Fonts?
body: <p>ggplot2: Why Does Semi-Transparency + pdflatex Cause Heavier-Than-Normal PDF Fonts?</p>
  
  <p>I've run into a problem where <code>pdf()</code>ing in R and then <code>pdflatex</code>-ing a ggplot2 image causes all of the text on the same page as the image to become emboldened, but only when <code>alpha</code> &lt; 1. Here's a minimal example in R:</p>
  
  <pre><code>require("ggplot2")
  "%_%" &lt;- function(a, b) paste(a, b, sep="")
  test &lt;- function(filename, alpha)
  {
    pdf(filename %_% "-fig.pdf")
    p &lt;- ggplot(mtcars, aes(wt, mpg)) + geom_point(alpha=alpha)
    print(p); dev.off()
  
    latexDocument &lt;- c(
      "\\documentclass{article}",
      "\\usepackage{Sweave}",
      "%\\pdfpageattr{/Group &lt;&lt;/S /Transparency /I true /CS /DeviceRGB&gt;&gt;}",
      "\\begin{document}",
      "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
      "\\begin{figure}",
      "\\includegraphics{" %_% filename %_% "-fig}",
      "  \\caption{Figure Caption}",
      "\\end{figure}",
      "\\end{document}")
  
    con &lt;- file(filename %_% ".tex"); writeLines(latexDocument, con); close(con)
    system("pdflatex " %_% filename)
  }
  
  test("test1", 1)
  test("test2", 0.3)
  </code></pre>
  
  <p>Comparing the output files <em>test1.pdf</em> and <em>test2.pdf</em>, I notice that the latter document has heavier fonts when viewed in Acrobat or Acrobat Reader. The problem has been discussed <a href="https://stackoverflow.com/questions/5752170/ggplot2-adding-alpha-parameter-makes-all-other-text-darker-bold-in-pdf">here</a> before, but to no resolution.</p>
  
  <p>I can't seem to solve the problem, which messes up the look of reports I generate with Sweave. Does anyone have any insight into it? I'm using R version 2.13.1 on Windows.</p>