From 928d6cd84373e2e084701a9ea9c6e485a6db1525 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Tue, 3 Jul 2018 11:03:58 -0500 Subject: [PATCH] fix #10, fix #49, fix #70, and fix #149 by putting chunk output in a raw latex block ```{=latex} for R Journal articles, which is the same fix as 8da3d29367de475c06a28f28e41f3a6c18eebdba --- DESCRIPTION | 2 +- NEWS | 7 ++++--- R/rjournal_article.R | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 24f193d03..2d40c7cb5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rticles Type: Package Title: Article Formats for R Markdown -Version: 0.4.5 +Version: 0.4.6 Authors@R: c( person("JJ", "Allaire", role = c("aut", "cre"), email = "jj@rstudio.com"), person(family = "R Foundation", role = c("aut", "cph")), diff --git a/NEWS b/NEWS index 420213f0d..22ea9738a 100644 --- a/NEWS +++ b/NEWS @@ -3,9 +3,10 @@ rticles 0.5 (unreleased) - Add MDPI journal template -- Fixed #6 and #132: dollar signs can be used in code chunks in JSS articles - now, but it will require Pandoc 2.x (you can use the Preview version of - RStudio if you do not want to install Pandoc separately). +- Fixed #6, #10, #49, #132, and #149: dollar signs and other special LaTeX + characters such as `^` can be used in code chunks in JSS and R Journal + articles now, but Pandoc 2.x will be required (you can use the Preview version + of RStudio if you do not want to install Pandoc separately). rticles 0.4.1 --------------------------------------------------------------------- diff --git a/R/rjournal_article.R b/R/rjournal_article.R index a3c1efdf9..ac4d9850a 100644 --- a/R/rjournal_article.R +++ b/R/rjournal_article.R @@ -20,6 +20,8 @@ #' @export rjournal_article <- function(...) { + rmarkdown::pandoc_available('2.2', TRUE) + template <- find_resource("rjournal_article", "template.tex") base <- inherit_pdf_document(..., template = template) @@ -45,7 +47,7 @@ rjournal_article <- function(...) { hilight_source <- knitr_fun('hilight_source') hook_chunk = function(x, options) { if (output_asis(x, options)) return(x) - paste('\\begin{Schunk}\n', x, '\\end{Schunk}', sep = '') + paste0('```{=latex}\n\\begin{Schunk}\n', x, '\\end{Schunk}\n```') } hook_input <- function(x, options) paste(c('\\begin{Sinput}', hilight_source(x, 'sweave', options), '\\end{Sinput}', ''),