diff --git a/NAMESPACE b/NAMESPACE index 237aadbe7..b7bf9a154 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ export(ctex_template) export(elsevier_article) export(ieee_article) export(jss_article) +export(peerj_article) export(plos_article) export(pnas_article) export(rjournal_article) diff --git a/R/peerj_article.R b/R/peerj_article.R new file mode 100644 index 000000000..3c9d7b5e0 --- /dev/null +++ b/R/peerj_article.R @@ -0,0 +1,34 @@ +#' PeerJ journal format. +#' +#' Format for creating submissions to The PeerJ. +#' +#' @inheritParams rmarkdown::pdf_document +#' @param ... Additional arguments to \code{rmarkdown::pdf_document} +#' @param base_format The function to use for the base format of the article. +#' By default, this is \code{rmarkdown::pdf_document}, but to use pandoc's +#' cross-referencing feature, this can be set to \code{bookdown::pdf_document2} +#' +#' +#' @return R Markdown output format to pass to +#' \code{\link[rmarkdown:render]{render}} +#' +#' @examples +#' +#' \dontrun{ +#' library(rmarkdown) +#' draft("MyArticle.Rmd", template = "peerj_article", package = "rticles") +#' } +#' +#' @export +peerj_article <- function(..., keep_tex = TRUE, citation_package = "natbib", + base_format = rmarkdown::pdf_document) { + if (inherits(base_format, "character")){ + FMT <- eval(parse(text = base_format)) + } else { + FMT <- match.fun(base_format) + } + out <- FMT(..., + citation_package = citation_package, + keep_tex = keep_tex, + template = find_resource("peerj_article", "template.tex")) +} diff --git a/inst/rmarkdown/templates/peerj_article/resources/template.tex b/inst/rmarkdown/templates/peerj_article/resources/template.tex new file mode 100644 index 000000000..bfaf5b857 --- /dev/null +++ b/inst/rmarkdown/templates/peerj_article/resources/template.tex @@ -0,0 +1,78 @@ +%% Submissions for peer-review must enable line-numbering +%% using the lineno option in the \documentclass command. +%% +%% Preprints and camera-ready submissions do not need +%% line numbers, and should have this option removed. +%% +%% Please note that the line numbering option requires +%% version 1.1 or newer of the wlpeerj.cls file, and +%% the corresponding author info requires v1.2 + +$if(preprint)$ +\documentclass[fleqn,10pt]{wlpeerj} % for preprint submissions +$else$ +\documentclass[fleqn,10pt,lineno]{wlpeerj} % for journal submissions +$endif$ + +% ZNK -- Adding headers for pandoc + +\setlength{\emergencystretch}{3em} +\providecommand{\tightlist}{ +\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} +\usepackage{lipsum} +\usepackage[unicode=true]{hyperref} +\usepackage{longtable} + + + +$for(header-includes)$ +$header-includes$ +$endfor$ + +\title{$title$} + +$for(author)$ +\author[$author.affiliation$]{$author.name$} + +$if(author.corresponding)$ +\corrauthor[$author.affiliation$]{$author.name$}{$author.email$} +$endif$ +$endfor$ + +$for(affiliation)$ +\affil[$affiliation.code$]{$affiliation.address$} +$endfor$ + + +% +% \author[1]{First Author} +% \author[2]{Second Author} +% \affil[1]{Address of first author} +% \affil[2]{Address of second author} +% \corrauthor[1]{First Author}{f.author@email.com} + +% $if(keywords)$ +% \keywords{$for(keywords)$$keywords$$sep$$endfor$} +% $endif$ + +\begin{abstract} +$abstract$ +% Dummy abstract text. Dummy abstract text. Dummy abstract text. Dummy abstract text. Dummy abstract text. Dummy abstract text. Dummy abstract text. Dummy abstract text. Dummy abstract text. Dummy abstract text. Dummy abstract text. +\end{abstract} + +\begin{document} + +\flushbottom +\maketitle +\thispagestyle{empty} + +$body$ + +$for(include-after)$ +$include-after$ +$endfor$ + +\bibliography{$bibliography$} + + +\end{document} diff --git a/inst/rmarkdown/templates/peerj_article/skeleton/sample.bib b/inst/rmarkdown/templates/peerj_article/skeleton/sample.bib new file mode 100644 index 000000000..fdd186c91 --- /dev/null +++ b/inst/rmarkdown/templates/peerj_article/skeleton/sample.bib @@ -0,0 +1,8 @@ +@ARTICLE{Figueredo:2009dg, + author = {Figueredo, A.~J. and Wolf, P. S.~A.}, + title = {Assortative pairing and life history strategy - a cross-cultural study.}, + journal = {Human Nature}, + volume = {20}, + pages = {317-330}, + year = {2009} +} \ No newline at end of file diff --git a/inst/rmarkdown/templates/peerj_article/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/peerj_article/skeleton/skeleton.Rmd new file mode 100755 index 000000000..7df00b5e3 --- /dev/null +++ b/inst/rmarkdown/templates/peerj_article/skeleton/skeleton.Rmd @@ -0,0 +1,177 @@ +--- +title: Template for preparing your research report submission to PeerJ using RMarkdown +preprint: false +author: + - name: Barbara McClintock + affiliation: 1 + corresponding: true + email: mcclintockb@cshl.edu + - name: Charles E. Darwin + affiliation: 2 +affiliation: + - code: 1 + address: Cold Spring Harbor Laboratory, One Bungtown Road Cold Spring Harbor, NY 11724 + - code: 2 + address: Down House, Luxted Rd, Downe, Orpington BR6 7JT, UK +abstract: > + The abstract of the article. + It can also be on *multiple* lines. +header-includes: > + \usepackage{lipsum} +bibliography: sample.bib +output: + rticles::peerj_article: + base_format: rmarkdown::pdf_document # bookdown::pdf_document2 # for using \@ref() +--- + + +# Introduction {-} + +Your introduction goes here! Some examples of commonly used commands and features are listed below, to help you get started. + +If you have a question, please use the help menu in the top right of the screen to get in touch. When your article or pre-print is complete, use the "Submit to PeerJ" button in the topbar to send your files to PeerJ. + +## About PeerJ {-} + +PeerJ is an award-winning open access publisher covering the biological and medical sciences. PeerJ provides authors with three publication venues: *PeerJ* and *PeerJ Computer Science* (peer-reviewed academic journals) and *PeerJ PrePrints* (a 'pre-print server'). See https://peerj.com/about/publications/ for more information. + +The PeerJ model allows an author to publish articles in their peer-reviewed journal via the purchase of a lifetime Publication Plan. Prices start from just \$99 (a one-off payment) which entitles an author to the lifetime ability to publish 1 article per year for free. Publication in PeerJ PrePrints is entirely free. + +# Some \LaTeX{} Examples {-} + +Use section and subsection commands to organize your document. \LaTeX{} handles all the formatting and numbering automatically. Use ref and label commands for cross-references. + +## Figures and Tables {-} + +Use the table and tabular commands for basic tables --- see Table \@ref(tab:simtab1), for example. You can upload a figure (JPEG, PNG or PDF) using the project menu. To include it in your document, use the includegraphics command as in the code for Figure \@ref(fig:view) below. + +Standard \LaTeX references will work as well (e.g. Fig. \ref{fig:view}). + + + +```{r view, out.width = "100%", fig.cap = "An example image.", echo = FALSE} +knitr::include_graphics("view.pdf") +``` + + + +Item Quantity +------- --------- +Widgets 42 +Gadgets 13 + +Table: (\#tab:widgets) An Example Table. + +## Citations {-} + +LaTeX formats citations and references automatically using the bibliography records in your .bib file, which you can edit via the project menu. Use the cite command for an inline citation, like @Figueredo:2009dg, and the citep command for a citation in parentheses [@Figueredo:2009dg]. + +## Mathematics {-} + +\LaTeX{} is great at typesetting mathematics. Let $X_1, X_2, \ldots, X_n$ be a sequence of independent and identically distributed random variables with $\text{E}[X_i] = \mu$ and $\text{Var}[X_i] = \sigma^2 < \infty$, and let +$$S_n = \frac{X_1 + X_2 + \cdots + X_n}{n} + = \frac{1}{n}\sum_{i}^{n} X_i$$ +denote their mean. Then as $n$ approaches infinity, the random variables $\sqrt{n}(S_n - \mu)$ converge in distribution to a normal $\mathcal{N}(0, \sigma^2)$. + +## Lists {-} + +You can make lists with automatic numbering \dots + + +1. Like this, +1. and like this. + +or bullet points... + +- Like this, +- and like this. + +or with descriptions... + +- **Word** Definition +- **Concept** Explanation +- **Idea** Text + + +We hope you find write\LaTeX\ useful for your PeerJ submission, and please let us know if you have any feedback. Further examples with dummy text are included in the following pages. + +# Methods {-} + +\lipsum[4] + +\begin{equation} +\cos^3 \theta =\frac{1}{4}\cos\theta+\frac{3}{4}\cos 3\theta +\label{eq:refname2} +\end{equation} + +\lipsum[5] + +## Subsection {-} + +\lipsum[6] + +\paragraph{Paragraph} \lipsum[7] +\paragraph{Paragraph} \lipsum[8] + +## Subsection {-} + +\lipsum[9] + + + + + + + +```{r results, fig.width = 5, fig.height = 4, out.width = "100%", fig.cap = "In-text Picture", echo = FALSE} +# knitr::include_graphics("figure/simulations/rd_sexrate.pdf") +time = seq(1.5, 8, 0.1) +plot(time, sin(time), type = "l", xlab = "time [s]", ylab = "amplitude [m]", + cex.main = 2, col = "blue", lwd = 3, font = 2, font.main = 2) +``` + + +Reference to Figure \@ref(fig:results). + +# Results and Discussion {-} + +\lipsum[10] + +## Subsection {-} + +\lipsum[11] + +### Subsubsection {-} + +\lipsum[12] + +### Subsubsection {-} + +\lipsum[14] + +## Subsection {-} + +\lipsum[15-20] + +# Acknowledgments {-} + +So long and thanks for all the fish. + +# References diff --git a/inst/rmarkdown/templates/peerj_article/skeleton/view.jpg b/inst/rmarkdown/templates/peerj_article/skeleton/view.jpg new file mode 100644 index 000000000..060d225fa Binary files /dev/null and b/inst/rmarkdown/templates/peerj_article/skeleton/view.jpg differ diff --git a/inst/rmarkdown/templates/peerj_article/skeleton/wlpeerj.cls b/inst/rmarkdown/templates/peerj_article/skeleton/wlpeerj.cls new file mode 100644 index 000000000..aba43c773 --- /dev/null +++ b/inst/rmarkdown/templates/peerj_article/skeleton/wlpeerj.cls @@ -0,0 +1,223 @@ +% +% An unofficial LaTeX class for PeerJ articles. +% +% Created by Overleaf (writeLaTeX). +% +% Based on the SelfArx document class. +% +\NeedsTeXFormat{LaTeX2e} +\ProvidesClass{wlpeerj}[18/08/2016, v1.2] +\RequirePackage[utf8]{inputenc} +\RequirePackage[english]{babel} + +\RequirePackage{ifthen} +\RequirePackage{calc} +\AtEndOfClass{\RequirePackage{microtype}} +\newif\if@peerjlineno +\DeclareOption{lineno}{\@peerjlinenotrue} +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} +\ProcessOptions* +\LoadClass{article} +\RequirePackage{times} % Loads the Times-Roman Fonts +\RequirePackage{mathptmx} % Loads the Times-Roman Math Fonts +\RequirePackage{lineno} % For numbering the lines if lineno option is given +\if@peerjlineno\linenumbers\fi + +\RequirePackage{ifpdf} + +\RequirePackage{amsmath,amsfonts,amssymb} +\RequirePackage{graphicx,xcolor} +\RequirePackage{booktabs} +\RequirePackage{authblk} + +\RequirePackage[left=5cm,% + right=2cm,% + top=2.25cm,% + bottom=2.25cm,% + headheight=12pt,% + letterpaper]{geometry}% + +\RequirePackage[labelfont={bf,sf},% + labelsep=period,% + justification=raggedright]{caption} + + +\RequirePackage{natbib} +\bibliographystyle{apalike} + +% writeLaTeX logo +% +\newcommand\wllogo{% +\renewcommand*\rmdefault{ugq}\normalfont\upshape{}write% +\renewcommand*\rmdefault{cmr}\normalfont\upshape{\bf\LaTeX}} + +% +% headers and footers +% +\RequirePackage{fancyhdr} % custom headers/footers +\RequirePackage{lastpage} % Number of pages in the document +\pagestyle{fancy} % Enables the custom headers/footers +% Headers +\lhead{}% +\chead{}% +\rhead{}% +% Footers +\lfoot{}% +\cfoot{}% +\rfoot{\small\sffamily\bfseries\thepage/\pageref{LastPage}}% +\renewcommand{\headrulewidth}{0pt}% % No header rule +\renewcommand{\footrulewidth}{0pt}% % No footer rule + +% +% section/subsection/paragraph set-up +% +\RequirePackage[explicit]{titlesec} +\titleformat{\section} + {\color{color1}\large\sffamily\bfseries} + {\thesection} + {0.5em} + {\MakeUppercase{#1}} + [] +\titleformat{name=\section,numberless} + {\color{color1}\large\sffamily\bfseries} + {} + {0em} + {\MakeUppercase{#1}} + [] +\titleformat{\subsection} + {\sffamily\bfseries} + {\thesubsection} + {0.5em} + {#1} + [] +\titleformat{\subsubsection} + {\sffamily\small\bfseries\itshape} + {\thesubsubsection} + {0.5em} + {#1} + [] +\titleformat{\paragraph}[runin] + {\sffamily\small\bfseries} + {} + {0em} + {#1} +\titlespacing*{\section}{0pc}{3ex \@plus4pt \@minus3pt}{5pt} +\titlespacing*{\subsection}{0pc}{2.5ex \@plus3pt \@minus2pt}{0pt} +\titlespacing*{\subsubsection}{0pc}{2ex \@plus2.5pt \@minus1.5pt}{0pt} +\titlespacing*{\paragraph}{0pc}{1.5ex \@plus2pt \@minus1pt}{10pt} + +% +% tableofcontents set-up +% +\usepackage{titletoc} +\contentsmargin{0cm} +\titlecontents{section}[\tocsep] + {\addvspace{4pt}\small\bfseries\sffamily} + {\contentslabel[\thecontentslabel]{\tocsep}} + {} + {\hfill\thecontentspage} + [] +\titlecontents{subsection}[\tocsep] + {\addvspace{2pt}\small\sffamily} + {\contentslabel[\thecontentslabel]{\tocsep}} + {} + {\ \titlerule*[.5pc]{.}\ \thecontentspage} + [] +\titlecontents*{subsubsection}[\tocsep] + {\footnotesize\sffamily} + {} + {} + {} + [\ \textbullet\ ] + +\RequirePackage{enumitem} +%\setlist{nolistsep} % Uncomment to remove spacing between items in lists (enumerate, itemize) + +% Remove brackets from numbering in List of References +\renewcommand{\@biblabel}[1]{\bfseries\color{color1}\textsuperscript{[#1]}} + +% +% article meta data +%% LLT 18 Aug 2016: no more! +% \newcommand{\keywords}[1]{\def\@keywords{#1}} +%% LLT 18 Aug 2016: but need corresponding author +\newcommand{\corrauthor}[3][]{% + \def\thecorrauthor{% + Corresponding author:\par #2$^{#1}$\par + \medskip + Email address: #3\par} +} + +\def\xabstract{abstract} +\long\def\abstract#1\end#2{\def\two{#2}\ifx\two\xabstract +\long\gdef\theabstract{\ignorespaces#1} +\def\go{\end{abstract}}\else +\typeout{^^J^^J PLEASE DO NOT USE ANY \string\begin\space \string\end^^J +COMMANDS WITHIN ABSTRACT^^J^^J}#1\end{#2} +\gdef\theabstract{\vskip12pt BADLY FORMED ABSTRACT: PLEASE DO +NOT USE {\tt\string\begin...\string\end} COMMANDS WITHIN +THE ABSTRACT\vskip12pt}\let\go\relax\fi +\go} + +% +% custom title page +% +\renewcommand{\@maketitle}{% +{% +\thispagestyle{empty}% +\vskip-36pt% +{\raggedright\sffamily\bfseries\fontsize{20}{25}\selectfont \@title\par}% +\vskip10pt +{\raggedright\sffamily\fontsize{12}{16}\selectfont \@author\par} +\vskip1em% +% LLT 18 Aug 2016: needs corresponding author now +\ifdefined\thecorrauthor + {\raggedright\sffamily\thecorrauthor\par} +\fi +\vskip18pt +{% +\noindent +{\parbox{\dimexpr\linewidth-2\fboxsep\relax}{\color{color1}\large\sffamily\textbf{ABSTRACT}}} +}% +\vskip10pt\nolinenumbers +{% +\noindent +\colorbox{color2}{% +\parbox{\dimexpr\linewidth-2\fboxsep\relax}{% +\sffamily\small\vskip1ex\if@peerjlineno\internallinenumbers\fi\theabstract +}% +}% +%% LLT 18 Aug 2016: no more keywords +% \vskip18pt% +% \noindent +% \parbox{\dimexpr\linewidth-2\fboxsep\relax}{% +% \if@peerjlineno\internallinenumbers\fi% +% {\color{color1}\keywordname\hspace*{1em}} \@keywords% +% }% +}% +\vskip25pt% +}% +}% +%----------------------------------------------- +\setlength{\columnsep}{0.55cm} % Distance between the two columns of text +\setlength{\fboxrule}{0.75pt} % Width of the border around the abstract + +\definecolor{color1}{RGB}{0,0,0} % Color of section headings +\definecolor{color2}{RGB}{250,232,207} % Color of the box behind the abstract +\newcommand{\keywordname}{Keywords:} % Defines the keywords heading name + +\renewcommand\Authfont{\fontsize{12}{14}\usefont{OT1}{phv}{b}{n}} +\renewcommand\Affilfont{\fontsize{10}{12}\usefont{OT1}{phv}{b}{n}} + +\newlength{\tocsep} +\setlength\tocsep{1.5pc} % Sets the indentation of the sections in the table of contents +\setcounter{tocdepth}{3} % Show only three levels in the table of contents section: sections, subsections and subsubsections + +\usepackage{lipsum} % Required to insert dummy text +%----------------------------------------------- +\let\oldbibliography\thebibliography +\renewcommand{\thebibliography}[1]{% +\addcontentsline{toc}{section}{\hspace*{-\tocsep}\refname}% +\oldbibliography{#1}% +\setlength\itemsep{0pt}% +} diff --git a/inst/rmarkdown/templates/peerj_article/template.yaml b/inst/rmarkdown/templates/peerj_article/template.yaml new file mode 100644 index 000000000..76271bbb8 --- /dev/null +++ b/inst/rmarkdown/templates/peerj_article/template.yaml @@ -0,0 +1,5 @@ +name: PeerJ Journal Article +description: > + Template for creating an article for submission to the PeerJ +create_dir: true + diff --git a/man/peerj_article.Rd b/man/peerj_article.Rd new file mode 100644 index 000000000..0ac820f0b --- /dev/null +++ b/man/peerj_article.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/peerj_article.R +\name{peerj_article} +\alias{peerj_article} +\title{PeerJ journal format.} +\usage{ +peerj_article(..., keep_tex = TRUE, citation_package = "natbib", + base_format = rmarkdown::pdf_document) +} +\arguments{ +\item{...}{Additional arguments to \code{rmarkdown::pdf_document}} + +\item{keep_tex}{Keep the intermediate tex file used in the conversion to PDF} + +\item{citation_package}{The LaTeX package to process citations, \code{natbib} +or \code{biblatex}. Use \code{none} if neither package is to be used.} + +\item{base_format}{The function to use for the base format of the article. +By default, this is \code{rmarkdown::pdf_document}, but to use pandoc's +cross-referencing feature, this can be set to \code{bookdown::pdf_document2}} +} +\value{ +R Markdown output format to pass to + \code{\link[rmarkdown:render]{render}} +} +\description{ +Format for creating submissions to The PeerJ. +} +\examples{ + +\dontrun{ +library(rmarkdown) +draft("MyArticle.Rmd", template = "peerj_article", package = "rticles") +} + +} diff --git a/tests/testthat/test_formats.R b/tests/testthat/test_formats.R index 1832e309b..4646ba713 100644 --- a/tests/testthat/test_formats.R +++ b/tests/testthat/test_formats.R @@ -45,4 +45,5 @@ test_format("aea_article") test_format("ieee_article") test_format("rjournal_article") test_format("sim_article") +test_format("peerj_article")