Skip to content

Commit ab3797d

Browse files
committed
reuse knitr's sweave hooks like 965d378
1 parent a1fa9e7 commit ab3797d

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

R/rjournal_article.R

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,9 @@ rjournal_article <- function(..., keep_tex = TRUE, citation_package = 'natbib')
129129
# Mostly copied from knitr::render_sweave
130130
base$knitr$opts_chunk$comment <- "#>"
131131

132-
hilight_source <- knitr_fun('hilight_source')
133-
hook_chunk = function(x, options) {
134-
if (output_asis(x, options)) return(x)
135-
paste0('```{=latex}\n\\begin{Schunk}\n', x, '\\end{Schunk}\n```')
136-
}
137-
hook_input <- function(x, options)
138-
paste(c('\\begin{Sinput}', hilight_source(x, 'sweave', options), '\\end{Sinput}', ''),
139-
collapse = '\n')
140-
hook_output <- function(x, options) paste('\\begin{Soutput}\n', x, '\\end{Soutput}\n', sep = '')
141-
142-
base$knitr$knit_hooks <- merge_list(base$knitr$knit_hooks, list(
143-
chunk = hook_chunk,
144-
source = hook_input,
145-
output = hook_output,
146-
message = hook_output,
147-
warning = hook_output,
148-
plot = knitr::hook_plot_tex
149-
))
132+
hooks <- knitr::hooks_sweave()
133+
hooks[['chunk']] <- latex_block(x, options, hooks[['chunk']])
134+
base$knitr$knit_hooks <- merge_list(base$knitr$knit_hooks, hooks)
150135

151136
base
152137
}

0 commit comments

Comments
 (0)