Skip to content

Commit

Permalink
add a new chunk option fig.env to set the figure environment; fixed #364
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Aug 22, 2012
1 parent a2d2d64 commit b1bd23c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ opts_chunk = new_defaults(list(
fig.keep = 'high', fig.show = 'asis', fig.align = 'default',
fig.path = 'figure/', fig.ext = NULL, dev = 'pdf', dpi = 72,
dev.args = NULL, fig.width = 7, fig.height = 7,
fig.cap = NULL, fig.scap = NULL, fig.lp = 'fig:', fig.pos = '',
fig.env = 'figure', fig.cap = NULL, fig.scap = NULL, fig.lp = 'fig:', fig.pos = '',
out.width = NULL, out.height = NULL, out.extra = NULL,
resize.width = NULL, resize.height = NULL,
external = TRUE, sanitize = FALSE,
Expand Down
4 changes: 2 additions & 2 deletions R/hooks-latex.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ hook_plot_tex = function(x, options) {
}
if(length(cap) && !is.na(cap)) {
if (plot1) {
fig1 = sprintf('\\begin{figure}[%s]\n', options$fig.pos)
fig1 = sprintf('\\begin{%s}[%s]\n', options$fig.env, options$fig.pos)
}
if (plot2) {
lab = str_c(options$fig.lp, options$label, ifelse(mcap, fig.cur, ''))
if (is.null(scap)) scap = str_split(cap, '\\.|;|:')[[1L]][1L]
scap = if(is.na(scap)) '' else str_c('[', scap, ']')
fig2 = sprintf('\\caption%s{%s\\label{%s}}\n\\end{figure}\n', scap, cap, lab)
fig2 = sprintf('\\caption%s{%s\\label{%s}}\n\\end{%s}\n', scap, cap, lab, options$fig.env)
}
}

Expand Down

0 comments on commit b1bd23c

Please sign in to comment.