You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for numeric inline output in LaTeX, the I() trick is no longer needed, e.g. $x=\Sexpr{1.2e10}$ is safe for LaTeX now due to \ensuremath{} (#137) (thanks, Randall Pruim)
the chunk option eval can take numeric values now, specifying which expressions to evaluate in a chunk (#383) (thanks, Jared Lander)
a new package option stop_on_error which specifies the behavior of errors in code chunks; this option is passed to the evaluate package, e.g. opts_knit$set(stop_on_error = 2L) will make knitr completely stop on errors (the default value is 0L which means to move on even if errors occurred); this makes it possible to see the call stacks via traceback() in an interactive R session when an error occurs (#344) (thanks, Hadley Wickham and Dzidorius Martinaitis)
knitr throws a warning when a cached chunk depends on an uncached chunk because this kind of dependency will be ignored (#431) (thanks, @ghostwheel)
a list of arguments can be passed to formatR::tidy.source() as the chunk option tidy.opts now, e.g. tidy.opts=list(width.cutoff=60, keep.blank.line=FALSE) (#429)
some chunk options are recycled for plots such as fig.env, out.width and out.extra, etc; this means if there are multiple plots per chunk, we can specify different output options for them individually (e.g. out.width=c('2in', '.4\\linewidth') for two plots); see https://github.com/yihui/knitr-examples/blob/master/067-graphics-options.Rnw for an example (motivated by #430) (thanks, @autumnlin)
added a new chunk option fig.subcap for captions of subfigures in LaTeX; when there are multiple plots in a chunk, and neither fig.subcap nor fig.cap is NULL, \subfloat{} will be used for individual plots (you need to add \usepackage{subfig} in the preamble); also see https://github.com/yihui/knitr-examples/blob/master/067-graphics-options.Rnw for an example (#388) (thanks, @skipperhoyer)
stitch() accepts labeled R scripts now; if an R script contains chunk headers of the form ## @knitr label, options, they will be used in the template (#411) (thanks, @jamiefolson)
the function read_chunk() gained a few new arguments so that we can reference external code chunks in another way, which was an idea from the SweaveListingUtils package (thanks, Peter Ruckdeschel)
a new function read_demo() based on read_chunk() to read demo scripts in R packages
render_jekyll() gained an argument highlight to specify which highlighting engine to use (Pygments or Prettify.js) (thanks, Yanping Chen)
two new chunk options for language engines: engine.path and engine.opts; the former can be used to specify the path of the program (e.g. <<engine='ruby', engine.path='/usr/bin/ruby1.9.1'>>=); the latter can be used to pass additional arguments to the engine program
added a preliminary engine for SAS which is basically a call like system('sas chunk-code.sas') (#354)
a new document hook to post-process the LaTeX output document to move code chunks out of figure/table environments so that code chunks will not float with the environments; see ?hook_movecode for details
chunk hooks are called in the reverse order after a chunk (and natural order before a chunk); this allows one to, e.g. write an opening environment before a chunk and close it properly after a chunk
all language engines also respect the comment option when writing output just like R code chunks (by default the output is commented out by ##)
added a new function set_alias() as a wrapper to opts_knit$set(aliases = ...), e.g. set_alias(w = 'fig.width') sets w as an alias for the chunk option fig.width
MAJOR CHANGES
global options are strongly recommended to be set via real R code opts_chunk$set(opt = value) in a code chunk instead of the old syntax in text chunks like \SweaveOpts{opt = value}, or <!--roptions opt=value-->, etc, which will be deprecated in the next version; this will make it cleaner and safer to parse the source documents, e.g. we can write arbitrarily complicated expressions like opts_chunk$set(fig.width = if (foo == 'beamer') { 5 } else { 7 }) which is impossible in the old syntax; if you still use the old syntax like \SweaveOpts{}, you will see a warning with a pause of 10 seconds
based on the same reason, it is recommended to use the chunk option child to input child documents; old syntax like \SweaveInput{} will be deprecated
for markdown output, results from inline R code will no longer be put in a pair of backticks (#379)
the package option opts_knit$get('cache.extra') was removed because this option should really be a chunk option instead; see http://yihui.name/knitr/demo/cache/ for the updated documentation (#404 and #405) (thanks, Jim Hester)
the chunk option highlight.opts was deprecated and renamed to engine.opts; this affects users who use Andre Simon's highlight through the highlight engine in knitr
the pattern knit_pattern$get('ref.label') was deprecated since it is unlikely to be customized; a fixed pattern '^#+\\s*@knitr(.*)$' will be used instead
MINOR CHANGES
when opts_knit$get('verbose') is TRUE, a timestamp() will be printed before each code chunk is evaluated (#377) (thanks, Carl Boettiger)
stitch() will no longer copy the template over to the current working directory (thanks, Michael Friendly)
stitch() will no longer open the PDF/HTML output automatically (#411) (thanks, Michel Kuhlmann)
the script inst/bin/knit can also convert R Markdown documents to HTML now; the argument --pdf was removed and a new argument --no-convert was added
dots in figure filenames will not be replaced with _ when the output is not LaTeX (thanks, Stewart Macarthur)
BUG FIXES
fixed #410: when the inline R code returns NA_real_, the scientific notation of numbers will run into errors (thanks, Rafik)
the syntax pattern for Rnw documents was not quite right: all_patterns$rnw$chunk.end = '^\\s*@\\s*%*' actually allows any characters after @, but only LaTeX comments and white spaces are allowed; it has been fixed to ^\\s*@\\s*(%+.*|)$ now