Skip to content

Commit e792a5e

Browse files
committed
Merge pull request #4 from cwickham/master
fixed figures by using Sweave environments in hooks
2 parents f814c97 + 7049719 commit e792a5e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

R/rjournal_article.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,21 @@ rjournal_article <- function() {
2222
# Mostly copied from knitr::render_sweave
2323
base$knitr$opts_chunk$comment <- "#>"
2424

25-
hook_chunk <- function(x, options) {
25+
hook_chunk = function(x, options) {
2626
if (knitr:::output_asis(x, options)) return(x)
27-
paste0('\\begin{example}\n', x, '\\end{example}')
27+
paste('\\begin{Schunk}\n', x, '\\end{Schunk}', sep = '')
2828
}
29-
hook_input <- function(x, options) paste0(x, "\n")
30-
hook_output <- function(x, options) paste0(x, "\n")
29+
hook_input <- function(x, options)
30+
paste(c('\\begin{Sinput}', knitr:::hilight_source(x, 'sweave', options), '\\end{Sinput}', ''),
31+
collapse = '\n')
32+
hook_output <- function(x, options) paste('\\begin{Soutput}\n', x, '\\end{Soutput}\n', sep = '')
3133

3234
base$knitr$knit_hooks$chunk <- hook_chunk
3335
base$knitr$knit_hooks$source <- hook_input
3436
base$knitr$knit_hooks$output <- hook_output
3537
base$knitr$knit_hooks$message <- hook_output
3638
base$knitr$knit_hooks$warning <- hook_output
39+
base$knitr$knit_hooks$plot <- knitr:::hook_plot_tex
3740

3841
base
3942
}

0 commit comments

Comments
 (0)