Skip to content

Commit

Permalink
disable out.width, out.height, out.extra, and fig.align for docx, ppt…
Browse files Browse the repository at this point in the history
…x, rtf and odt output
  • Loading branch information
yihui committed Aug 21, 2018
1 parent 5cb166d commit 575e18e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.20.14
Version: 1.20.15
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("Adam", "Vogt", role = "ctb"),
Expand Down
9 changes: 5 additions & 4 deletions R/hooks-md.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ hook_plot_md = function(x, options) {
# if not using R Markdown v2 or output is HTML, just return v1 output
if (is.null(to <- pandoc_to()) || is_html_output(to))
return(hook_plot_md_base(x, options))
office_output = to %in% c('docx', 'pptx', 'rtf', 'odt')
if (!is.null(options$out.width) || !is.null(options$out.height) ||
!is.null(options$out.extra) || options$fig.align != 'default' ||
!is.null(options$fig.subcap)) {
Expand All @@ -12,15 +13,15 @@ hook_plot_md = function(x, options) {
if (is.null(options$fig.scap)) options$fig.scap = NA
return(hook_plot_tex(x, options))
}
if (to == 'docx') {
if (office_output) {
warning('Chunk options fig.align, out.width, out.height, out.extra ',
'are not supported for Word output')
'are not supported for ', to, ' output')
options$out.width = options$out.height = options$out.extra = NULL
options$fig.align = 'default'
}
}
if (options$fig.show == 'hold' && to == 'docx') {
warning('The chunk option fig.show="hold" is not supported for Word output')
if (options$fig.show == 'hold' && office_output) {
warning('The chunk option fig.show="hold" is not supported for ', to, ' output')
options$fig.show = 'asis'
}
hook_plot_md_base(x, options)
Expand Down

0 comments on commit 575e18e

Please sign in to comment.