r - Knitr: how to update chunk options? -
i add chunk option, add_graph
, that, if true
, appends string link
figure caption. (really, want use latex attachfile package include separate copy of graph within caption thereof.) based on example knitr book, thought following work, doesn't.
hook_plot <- knit_hooks$get('plot') knit_hooks$set(plot=function(x, options){ if(!is.null(cap <- options$fig.cap)){ if(options$add_graph){ opts_chunk$set(fig.cap = paste(cap, "link.")) } } hook_plot(x, options) })
a subsequent chunk chunk option add_graph=true
, fig.cap
produce plot, nothing appended caption.
Comments
Post a Comment