Skip to content

CHANGES IN knitr VERSION 1.8

Choose a tag to compare

@yihui yihui released this 11 Nov 20:36

NEW FEATURES

  • when using knitr with the rmarkdown package, the internal output hook for plots will be automatically switched to the LaTeX plot hook when necessary; for example, when the chunk options fig.align, out.width, out.height, and/or out.extra are specified, raw LaTeX code will be generated to align/set the size of plots, because there is no support for figure alignment or setting the size in the native Markdown syntax; for Word output, these options are simply ignored (related issues: #626, rstudio/rmarkdown#86, rstudio/rmarkdown#148, rstudio/rmarkdown#303)
  • added a new function fig_chunk() to provide a public API to get the figure filenames produced from code chunks; since knitr 1.7 changed the figure file numbering scheme, it broke documents with hard-coded figure filenames, e.g. for Rnw documents, \includegraphics{foo.pdf} should be \includegraphics{foo-1.pdf} after knitr 1.7, and such problems can be avoided by \includegraphics{\Sexpr{fig_chunk('foo', 'pdf')}} (thanks, @edwardabraham, #870)
  • added an argument escape = TRUE to kable() to escape special characters in LaTeX and HTML tables (thanks, @juba, #852)
  • added a new function knit_filter() to filter out code chunks and inline R expressions; this function can be used as the filter for the spell check function utils::aspell(); see ?knit_filter for examples (#581)
  • added a new function spin_child() to spin child R scripts when we spin() a main script (thanks, @krlmlr, #621)
  • added a new function inline_expr() to help authors write the "source code" of the inline expression, e.g. inline_expr('1+1') generates r 1+1 in R Markdown documents (#890)
  • the cache will attempt to preserve the order in which packages are stored on the search path (thanks, @dgrtwo, #867)
  • added a new argument table.envir to kable() for LaTeX tables only; if the table caption is specified (not NULL), the LaTeX environment table will be used by default (i.e. the table is generated in \begin{table} \end{table}), and you can specify alternative environments via kable(..., table.envir = '???') (thanks, @dalupus, #872)
  • chunk options are supported using the syntax # ---- label, options ---- in the R script passed to stitch() (thanks, @wibeasley, yihui/knitr-examples#35)
  • syntax highlighting for .Rnw and .Rhtml documents can be further customized by setting opts_knit$set(highr.opts = list(markup = cmd_mine)) where cmd_mine is a data frame for the markup argument of highr::hilight() (thanks, @lq, #869)
  • added a new language engine groovy (thanks, @VVeitas, #876)

BUG FIXES

  • fixed #862: the YAML metadata in child R Markdown documents was not correctly removed (thanks, @krlmlr)
  • fixed #874: for the engines dot and tikz, the figure directory will be created recursively (thanks, @WilDoane)
  • fixed #654: sub figures were not aligned correctly in LaTeX when the chunk option fig.align was specified (thanks, @lionandoil)
  • the vignette engine knitr::rmarkdown_notangle did not really work (thanks, @bbolker, http://stackoverflow.com/q/26726388/559676)