6

Using dev = c("pdf", "png"), I can create both pdf and png format graphs. I wonder how can I force knitr to use pdf format graphs in the final document. My following MWE using png format graphs in the final document. I asked a similar question before.

\documentclass{article} 
\begin{document}
<<setup, include=FALSE, cache=FALSE>>=
opts_chunk$set(
                 fig.path   = 'figure/'
               , cache.path = 'cache/'
               , cache      = FALSE
               , dev        = c("pdf", "png")
               , fig.align  = 'center'
               , fig.show   = 'hold'
               , fig.width  = 8
               , fig.height = 6
               , out.width  = '.8\\linewidth'
               , par        = TRUE
               , echo       = FALSE
               , warning    = FALSE
               , message    = FALSE
               )
options(replace.assign = TRUE, width=80)
knit_hooks$set(par = function(before, options, envir){
if (before && options$fig.show!='none')
 par(
      mar=c(4, 4, 0.1, 0.1)
   , cex.lab = 0.95
   , cex.axis =0.9
   , mgp = c(2, 0.7, 0)
   , tcl = -0.3
   )
}, crop = hook_pdfcrop)
@


<< hist-test >>=
X <- rnorm(n=100, mean=0, sd=)
hist(x=X)
@ 

\end{document}
halfer
  • 19,824
  • 17
  • 99
  • 186
MYaseen208
  • 22,666
  • 37
  • 165
  • 309

1 Answers1

4

easy, tell latex your preference,

\DeclareGraphicsExtensions{%
    .pdf,.PDF,%
    .png,.PNG,%
    .jpg,.jpeg}
baptiste
  • 75,767
  • 19
  • 198
  • 294
  • Hi @baptiste, I have [another relevant question here](http://stackoverflow.com/q/27674431/707145). Please help me for this question if you can. Thanks – MYaseen208 Dec 31 '14 at 16:43
  • for completeness, here's [a trick for pandoc](http://comments.gmane.org/gmane.comp.lang.r.knitr/487) – baptiste Dec 31 '14 at 16:43
  • @MYaseen208 it doesn't seem related, and I know nothing of ggvis, sorry – baptiste Dec 31 '14 at 16:45