Skip to content

First pass at rjournal template #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export(jss_article)
export(rjournal_article)
export(use_r_abstract)
24 changes: 24 additions & 0 deletions R/rjournal_article.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#' @export
rjournal_article <- function() {
template <- find_resource("rjournal_article", "template.tex")

base <- rmarkdown::pdf_document(template = template, keep_tex = TRUE)

# Mostly copied from knitr::render_sweave
base$knitr$opts_chunk$comment <- "#>"

hook_chunk <- function(x, options) {
if (knitr:::output_asis(x, options)) return(x)
paste0('\\begin{example}\n', x, '\\end{example}')
}
hook_input <- function(x, options) paste0(x, "\n")
hook_output <- function(x, options) paste0(x, "\n")

base$knitr$knit_hooks$chunk <- hook_chunk
base$knitr$knit_hooks$source <- hook_input
base$knitr$knit_hooks$output <- hook_output
base$knitr$knit_hooks$message <- hook_output
base$knitr$knit_hooks$warning <- hook_output

base
}
1 change: 1 addition & 0 deletions inst/rmarkdown/templates/rjournal_article/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pdf
52 changes: 52 additions & 0 deletions inst/rmarkdown/templates/rjournal_article/resources/template.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
% --- RJwrapper header ---

\documentclass[a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{RJournal}
\usepackage{amsmath,amssymb,array}
\usepackage{booktabs}

%% load any required packages here
$preamble$

\begin{document}

%% do not edit, for illustration only
\sectionhead{Contributed research article}
\volume{XX}
\volnumber{YY}
\year{20ZZ}
\month{AAAA}

\begin{article}

% --- body ---

% !TeX root = RJwrapper.tex
\title{$title$}
\author{by $for(author)$$author.name$$sep$, $endfor$}

\maketitle

\abstract{
$abstract$
}

$body$

$for(author)$
\address{
$author.name$\\
$author.affiliation$\\
$for(author.address)$$author.address$$sep$\\ $endfor$\\
}
$if(author.email)$$author.email$$endif$

$endfor$

% --- RJwrapper footer ---
\end{article}

\end{document}

Loading