title: how to control default packages loaded by RMarkdown/knitr to avoid option clash
body: <p>I use r markdown with knitr to produce tex documents. However, On several occasions I have run into an issue where the packages I am loading with the "mystyles.txt" document in the preamble conflict with packages that are loaded automatically by knitr. The error looks different depending on the issue but it is always characterized by an "option clash".</p>
  
  <p>I believe I understand where this problem is coming from (I think) -- I just don't know how to fix it. When I try to use a package in mystyles.txt such as <code>\usepackage[pdftex]{graphicx}</code> or <code>\usepackage[table]{xcolor}</code>, I get the option clash error because these package have already been loaded WITHOUT options by default. </p>
  
  <p>However, this presents an issue because I need to load the packages with the exact options I specified. Which means that somehow I need to supress or modify the package loading done automatically by r markdown/knitr. </p>
  
  <p>For example, knitr automatically calls <code>\usepackage{graphicx}</code>. If there was some way to specify in the preamble so that this was instead <code>\usepackage[pdftex]{graphicx}</code>, then I could just remove the identical line from mystyles.txt, and I would be good. Unfortunately, I have not been able to find any documentation of this issue, and the following reference guide does not provide any insights: <a href="http://rmarkdown.rstudio.com/RMarkdownReferenceGuide.pdf" rel="noreferrer">http://rmarkdown.rstudio.com/RMarkdownReferenceGuide.pdf</a>.</p>
  
  <p>Does anyone know how to deal with this problem?</p>
  
  <p>-Paul</p>