Skip to content

Commit

Permalink
Merge pull request #97 from Emaasit/ieee
Browse files Browse the repository at this point in the history
Template for the IEEE Transaction Journals
  • Loading branch information
jjallaire authored Jun 8, 2017
2 parents be71a03 + 92f7563 commit f54e466
Show file tree
Hide file tree
Showing 13 changed files with 9,653 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Authors@R: c(
person("Ben", "Marwick", role = c("aut", "cph"), email = "bmarwick@uw.edu"),
person("Charlotte", "Wickham", role = c("aut", "cph"), email = "cwickham@gmail.com"),
person("Oliver", "Keyes", role = c("aut", "cph"), email = "okeyes@wikimedia.org"),
person("Miao", "Yu", role = c("aut", "cph"), email = "yufreecas@gmail.com")
person("Miao", "Yu", role = c("aut", "cph"), email = "yufreecas@gmail.com"),
person("Daniel", "Emaasit", role = c("aut", "cph"), email = "daniel.emaasit@gmail.com")
)
Description: A suite of custom R Markdown formats and templates for
authoring journal articles and conference submissions.
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export(asa_article)
export(ctex)
export(ctex_template)
export(elsevier_article)
export(ieee_article)
export(jss_article)
export(plos_article)
export(pnas_article)
Expand Down
102 changes: 102 additions & 0 deletions R/ieee_article.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#' IEEE Transactions journal format.
#'
#' Format for creating submissions to IEEE Transaction journals. Adapted from
#' \href{http://www.ieee.org/publications_standards/publications/authors/author_templates.html}{http://www.ieee.org/publications_standards/publications/authors/author_templates.html}.
#'
#' @inheritParams rmarkdown::pdf_document
#' @param draftmode Specify the draft mode to control spacing and whether images
#' should be rendered. Valid options are: \code{"final"} (default), \code{"draft"},
#' \code{"draftcls"}, or \code{"draftclsnofoot"}.
#' @param hyphenfixes A \code{character} value that provides the correct
#' hyphenations for ambiguous words. Separate new words with spaces.
#' @param IEEEspecialpaper A \code{character} value containing the publication's
#' special paper designation.
#' @param with_ifpdf A \code{logical} value turning on (\code{TRUE}) or off
#' (\code{FALSE}) the \code{ifpdf} LaTeX package.
#' @param with_cite A \code{logical} value turning on (\code{TRUE}) or off
#' (\code{FALSE}) the \code{cite} LaTeX package.
#' @param with_amsmath A \code{logical} value turning on (\code{TRUE}) or off
#' (\code{FALSE}) the \code{amsmath} LaTeX package.
#' @param with_algorithmic A \code{logical} value turning on (\code{TRUE}) or
#' off (\code{FALSE}) the \code{algorithmic} LaTeX package.
#' @param with_subfig A \code{logical} value turning on (\code{TRUE}) or off
#' (\code{FALSE}) the \code{subfig} LaTeX package.
#' @param with_array A \code{logical} value turning on (\code{TRUE}) or off
#' (\code{FALSE}) the \code{array} LaTeX package.
#' @param with_dblfloatfix A \code{logical} value turning on (\code{TRUE}) or
#' off (\code{FALSE}) the \code{dblfloatfix} LaTeX package.
#' @param ... Additional arguments to \code{rmarkdown::pdf_document}
#'
#' @return R Markdown output format to pass to
#' \code{\link[rmarkdown:render]{render}}
#'
#' @examples
#'
#' \dontrun{
#' library(rmarkdown)
#' draft("MyArticle.Rmd", template = "ieee_article", package = "rticles")
#' }
#'
#' @details
#' Presently, only the \code{"conference"} paper mode offered by the
#' \code{IEEEtran.cls} is supported.
#'
#' @references
#' Shell, Michael. "How to use the IEEEtran LATEX class." Journal of LATEX Class
#' Files 1.11 (2002): 10-20.
#' \url{http://mirrors.rit.edu/CTAN/macros/latex/contrib/IEEEtran/IEEEtran_HOWTO.pdf}
#' @export
ieee_article <- function(...,
draftmode = c("final", "draft", "draftcls",
"draftclsnofoot"),
hyphenfixes = "op-tical net-works semi-conduc-tor",
IEEEspecialpaper = "",
with_ifpdf = FALSE,
with_cite = FALSE,
with_amsmath = FALSE,
with_algorithmic = FALSE,
with_subfig = FALSE,
with_array = FALSE,
with_dblfloatfix = FALSE,
keep_tex = TRUE,
md_extensions = c("-autolink_bare_uris")) {

args <- c()

draftmode <- match.arg(draftmode)
args <- c(args, "draftmode" = draftmode)

args <- c(args, "hyphenfixes" = hyphenfixes)

# Avoid declaration of pandoc variable if field is empty
if(nchar(IEEEspecialpaper) > 1){
args <- c(args, "IEEEspecialpaper" = IEEEspecialpaper)
}

plist <- c("with_ifpdf" = with_ifpdf,
"with_cite" = with_cite,
"with_amsmath" = with_amsmath,
"with_algorithmic" = with_algorithmic,
"with_subfig" = with_subfig,
"with_array" = with_array,
"with_dblfloatfix" = with_dblfloatfix)

# Obtain only variables that should be turned on
requested_withs <- sapply(plist, isTRUE)

args <- c(args, plist[requested_withs])

# pandoc_variable_arg not exported from rmarkdown
pandoc_arg_variable = function(var_name, value){
c("-V", paste0(var_name, "=", value))
}

# Convert to pandoc arguments
pandoc_arg_list <- mapply(pandoc_arg_variable, names(args), args)

inherit_pdf_document(...,
pandoc_args = pandoc_arg_list,
template = find_resource("ieee_article", "template.tex"),
keep_tex = keep_tex,
md_extensions = md_extensions)
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ The **rticles** package provides a suite of custom [R Markdown](http://rmarkdown

- [AEA](https://www.aeaweb.org/journals/policies/templates) journal submissions

- [IEEE Transaction](http://www.ieee.org/publications_standards/publications/authors/author_templates.html) journal submissions

Under the hood, LaTeX templates are used to ensure that documents conform precisely to submission standards. At the same time, composition and formatting can be done using lightweight [markdown](http://rmarkdown.rstudio.com/authoring_basics.html) syntax, and R code and its output can be seamlessly included using [knitr](http://yihui.name/knitr/).

Using **rticles** requires the prerequisites described below. You can get most of these automatically by installing the latest release of RStudio (instructions for using **rticles** without RStudio are also provided).
Expand Down
6 changes: 6 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
rticles 0.2.0.9000
---------------------------------------------------------------------

- Add Institute of Electrical and Electronics Engineers (IEEE) IEEEtrans
template for Conferences


rticles 0.2
---------------------------------------------------------------------
Expand Down
Loading

0 comments on commit f54e466

Please sign in to comment.