Skip to content
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

Royal Society Open Science Journal #135

Merged
merged 4 commits into from
Sep 13, 2017
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
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ Authors@R: c(
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("Daniel", "Emaasit", role = c("aut", "cph"), email = "daniel.emaasit@gmail.com")
person("Daniel", "Emaasit", role = c("aut", "cph"), email = "daniel.emaasit@gmail.com"),
person("Thierry", "Onkelinx", role = c("aut", "cph"), email = "thierry.onkelinx@inbo.be")
)
Description: A suite of custom R Markdown formats and templates for
authoring journal articles and conference submissions.
License: GPL-3
Imports: utils, rmarkdown, knitr, yaml
SystemRequirements: GNU make
RoxygenNote: 6.0.1
Suggests: testthat
Suggests: testthat, bookdown
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,11 @@ export(peerj_article)
export(plos_article)
export(pnas_article)
export(rjournal_article)
export(rsos_article)
export(rss_article)
export(sim_article)
importFrom(rmarkdown,includes_to_pandoc_args)
importFrom(rmarkdown,knitr_options)
importFrom(rmarkdown,output_format)
importFrom(rmarkdown,pandoc_options)
importFrom(rmarkdown,pandoc_variable_arg)
109 changes: 109 additions & 0 deletions R/rsos_article.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#' Royal Society Open Science journal format.
#'
#' Format for creating submissions to Royal Society Open Science journals.
#'
#' @inheritParams rmarkdown::pdf_document
#' @param ... Additional arguments to \code{rmarkdown::pdf_document}
#'
#' @return R Markdown output format to pass to
#' \code{\link[rmarkdown:render]{render}}
#'
#' @export
#' @importFrom rmarkdown output_format knitr_options pandoc_options pandoc_variable_arg includes_to_pandoc_args
#' @author Thierry Onkelinx, \email{thierry.onkelinx@@inbo.be}
rsos_article <- function(
...,
keep_tex = TRUE,
pandoc_args = NULL,
includes = NULL,
fig_crop = TRUE
) {

extra <- list(...)

template <- system.file(
"rmarkdown/templates/rsos_article/resources/template.tex",
package = "rticles"
)
args <- c(
"--template", template,
"--latex-engine", "xelatex",
pandoc_variable_arg("documentclass", "article"),
pandoc_args,
"--natbib",
includes_to_pandoc_args(includes)
)

if (length(extra) > 0) {
args <- c(
args,
sapply(
names(extra),
function(x){
pandoc_variable_arg(x, extra[[x]])
}
)
)
}

opts_chunk <- list(
latex.options = "{}",
dev = "pdf",
fig.align = "center",
dpi = 300,
fig.width = 4.5,
fig.height = 2.9,
highlight = FALSE,
echo = FALSE
)
crop <- fig_crop &&
!identical(.Platform$OS.type, "windows") &&
nzchar(Sys.which("pdfcrop"))
if (crop) {
knit_hooks <- list(crop = knitr::hook_pdfcrop)
opts_chunk$crop <- TRUE
} else {
knit_hooks <- NULL
}

post_processor <- function(
metadata, input_file, output_file, clean, verbose
) {
text <- readLines(output_file, warn = FALSE)

# set correct text in fmtext environment
end_first_page <- grep("^\\\\EndFirstPage", text) #nolint
if (length(end_first_page)) {
maketitle <- grep("\\\\maketitle", text) #nolint
text <- c(
text[1:(maketitle - 1)],
"\\begin{fmtext}",
text[(maketitle + 1):(end_first_page - 1)],
"\\end{fmtext}",
"\\maketitle",
text[(end_first_page + 1):length(text)]
)
}
writeLines(enc2utf8(text), output_file, useBytes = TRUE)
output_file
}

output_format(
knitr = knitr_options(
opts_knit = list(
width = 75,
concordance = TRUE
),
opts_chunk = opts_chunk,
knit_hooks = knit_hooks
),
pandoc = pandoc_options(
to = "latex",
latex_engine = "xelatex",
args = args,
keep_tex = keep_tex
),
post_processor = post_processor,
clean_supporting = !keep_tex
)
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ The **rticles** package provides a suite of custom [R Markdown](http://rmarkdown

- [Statistics in Medicine](http://onlinelibrary.wiley.com/journal/10.1002/(ISSN)1097-0258/homepage/la_tex_class_file.htm) journal submissions

- [Royal Society Open Science](http://rsos.royalsocietypublishing.org/) 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
5 changes: 5 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
rticles 0.4.1
---------------------------------------------------------------------

- Add Royal Society Open Science journal template

rticles 0.2.0.9000
---------------------------------------------------------------------

Expand Down
117 changes: 117 additions & 0 deletions inst/rmarkdown/templates/rsos_article/resources/template.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
%% Author_tex.tex
%% V1.0
%% 2012/13/12
%% developed by Techset
%%
%% This file describes the coding for rsproca.cls

\documentclass[]{rsos}%%%%where rsos is the template name

$if(lineno)$
\usepackage{lineno}
\linenumbers
$endif$

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

$for(header-includes)$
$header-includes$
$endfor$

%%%% *** Do not adjust lengths that control margins, column widths, etc. ***

%%%%%%%%%%% Defining Enunciations %%%%%%%%%%%
\newtheorem{theorem}{\bf Theorem}[section]
\newtheorem{condition}{\bf Condition}[section]
\newtheorem{corollary}{\bf Corollary}[section]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

%%%% Article title to be placed here
\title{$title$}

\author{
$for(author)$
$author.name$$$^{$author.affiliation$}$$$sep$,
$endfor$
}

\address{
$for(address)$
$$^{$address.code$}$$$address.address$$sep$\\
$endfor$
}
%%%% Subject entries to be placed here %%%%
\subject{
$for(subject)$
$subject$$sep$,
$endfor$
}

%%%% Keyword entries to be placed here %%%%
\keywords{
$for(keywords)$
$keywords$$sep$,
$endfor$
}

%%%% Insert corresponding author and its email address}
\corres{
$corresp_author_name$\\
e-mail: $corresp_author_email$
}

%%%% Abstract text to be placed here %%%%%%%%%%%%
\begin{abstract}
$abstract$
\end{abstract}
%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Some pieces required from the pandoc template
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\providecommand{\EndFirstPage}{%
}

\maketitle

$body$

$if(ethics)$
\textbf{Ethics.} $ethics$
$endif$

$if(data_accessibility)$
\textbf{Data accessibility.} $data_accessibility$
$endif$

\textbf{Authors' contributions.} $author_contributions$

$if(conflict_of_interest)$
\textbf{Competing interests.} $conflict_of_interest$
$endif$

$if(funding)$
\textbf{Funding.} $funding$
$endif$

$if(permissions)$
\textbf{Permissions.} $permissions$
$endif$

$if(acknowledgements)$
\textbf{Acknowledgements} $acknowledgements$
$endif$

$if(natbib)$
\bibliographystyle{RS}
\bibliography{$bibliography$}
$endif$

$for(include-after)$
$include-after$
$endfor$

\end{document}
4 changes: 4 additions & 0 deletions inst/rmarkdown/templates/rsos_article/skeleton/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.tex
*.log
*.pdf
*_files
Binary file not shown.
Binary file not shown.
Loading