diff --git a/NAMESPACE b/NAMESPACE
index 01a2d077c..d84ab7ba0 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -6,4 +6,5 @@ export(ctex)
export(ctex_template)
export(elsevier_article)
export(jss_article)
+export(pnas_article)
export(rjournal_article)
diff --git a/R/pnas_article.R b/R/pnas_article.R
new file mode 100644
index 000000000..60c8c6827
--- /dev/null
+++ b/R/pnas_article.R
@@ -0,0 +1,23 @@
+#' PNAS journal format.
+#'
+#' Format for creating submissions to PNAS 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}}
+#'
+#' @examples
+#'
+#' \dontrun{
+#' library(rmarkdown)
+#' draft("MyArticle.Rmd", template = "pnas_article", package = "rticles")
+#' }
+#'
+#' @export
+pnas_article <- function(..., keep_tex = TRUE) {
+ inherit_pdf_document(...,
+ keep_tex = keep_tex,
+ template = find_resource("pnas_article", "template.tex"))
+}
diff --git a/inst/rmarkdown/templates/elsevier_article/skeleton/skeleton.pdf b/inst/rmarkdown/templates/elsevier_article/skeleton/skeleton.pdf
new file mode 100644
index 000000000..68caf397e
Binary files /dev/null and b/inst/rmarkdown/templates/elsevier_article/skeleton/skeleton.pdf differ
diff --git a/inst/rmarkdown/templates/elsevier_article/skeleton/skeleton.tex b/inst/rmarkdown/templates/elsevier_article/skeleton/skeleton.tex
new file mode 100644
index 000000000..e90d9072b
--- /dev/null
+++ b/inst/rmarkdown/templates/elsevier_article/skeleton/skeleton.tex
@@ -0,0 +1,184 @@
+\documentclass[]{elsarticle} %review=doublespace preprint=single 5p=2 column
+%%% Begin My package additions %%%%%%%%%%%%%%%%%%%
+\usepackage[hyphens]{url}
+\usepackage{lineno} % add
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+
+\bibliographystyle{elsarticle-harv}
+\biboptions{sort&compress} % For natbib
+\usepackage{graphicx}
+\usepackage{booktabs} % book-quality tables
+%% Redefines the elsarticle footer
+%\makeatletter
+%\def\ps@pprintTitle{%
+% \let\@oddhead\@empty
+% \let\@evenhead\@empty
+% \def\@oddfoot{\it \hfill\today}%
+% \let\@evenfoot\@oddfoot}
+%\makeatother
+
+% A modified page layout
+\textwidth 6.75in
+\oddsidemargin -0.15in
+\evensidemargin -0.15in
+\textheight 9in
+\topmargin -0.5in
+%%%%%%%%%%%%%%%% end my additions to header
+
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+\usepackage{amssymb,amsmath}
+\usepackage{ifxetex,ifluatex}
+\usepackage{fixltx2e} % provides \textsubscript
+% use upquote if available, for straight quotes in verbatim environments
+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
+ \usepackage[utf8]{inputenc}
+\else % if luatex or xelatex
+ \usepackage{fontspec}
+ \ifxetex
+ \usepackage{xltxtra,xunicode}
+ \fi
+ \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
+ \newcommand{\euro}{€}
+\fi
+% use microtype if available
+\IfFileExists{microtype.sty}{\usepackage{microtype}}{}
+\ifxetex
+ \usepackage[setpagesize=false, % page size defined by xetex
+ unicode=false, % unicode breaks when used with xetex
+ xetex]{hyperref}
+\else
+ \usepackage[unicode=true]{hyperref}
+\fi
+\hypersetup{breaklinks=true,
+ bookmarks=true,
+ pdfauthor={},
+ pdftitle={Short Paper},
+ colorlinks=true,
+ urlcolor=blue,
+ linkcolor=magenta,
+ pdfborder={0 0 0}}
+\urlstyle{same} % don't use monospace font for urls
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{6pt plus 2pt minus 1pt}
+\setlength{\emergencystretch}{3em} % prevent overfull lines
+\setcounter{secnumdepth}{0}
+% Pandoc toggle for numbering sections (defaults to be off)
+\setcounter{secnumdepth}{0}
+% Pandoc header
+
+
+\usepackage[nomarkers]{endfloat}
+
+\begin{document}
+\begin{frontmatter}
+
+ \title{Short Paper}
+ \author[Some Institute of Technology]{Alice Anonymous\corref{c1}}
+ \ead{alice@example.com}
+ \cortext[c1]{Corresponding Author}
+ \author[Another University]{Bob Security}
+ \ead{bob@example.com}
+
+ \address[Some Institute of Technology]{Department, Street, City, State, Zip}
+ \address[Another University]{Department, Street, City, State, Zip}
+
+ \begin{abstract}
+ This is the abstract.
+
+ It consists of two paragraphs.
+ \end{abstract}
+
+ \end{frontmatter}
+
+\emph{Text based on elsarticle sample manuscript, see
+\url{http://www.elsevier.com/author-schemas/latex-instructions\#elsarticle}}
+
+\section{The Elsevier article class}\label{the-elsevier-article-class}
+
+\paragraph{Installation}\label{installation}
+
+If the document class \emph{elsarticle} is not available on your
+computer, you can download and install the system package
+\emph{texlive-publishers} (Linux) or install the LaTeX~package
+\emph{elsarticle} using the package manager of your TeX~installation,
+which is typically TeX~Live or MikTeX.
+
+\paragraph{Usage}\label{usage}
+
+Once the package is properly installed, you can use the document class
+\emph{elsarticle} to create a manuscript. Please make sure that your
+manuscript follows the guidelines in the Guide for Authors of the
+relevant journal. It is not necessary to typeset your manuscript in
+exactly the same way as an article, unless you are submitting to a
+camera-ready copy (CRC) journal.
+
+\paragraph{Functionality}\label{functionality}
+
+The Elsevier article class is based on the standard article class and
+supports almost all of the functionality of that class. In addition, it
+features commands and options to format the
+
+\begin{itemize}
+\item
+ document style
+\item
+ baselineskip
+\item
+ front matter
+\item
+ keywords and MSC codes
+\item
+ theorems, definitions and proofs
+\item
+ lables of enumerations
+\item
+ citation style and labeling.
+\end{itemize}
+
+\section{Front matter}\label{front-matter}
+
+The author names and affiliations could be formatted in two ways:
+
+\begin{enumerate}
+\def\labelenumi{(\arabic{enumi})}
+\item
+ Group the authors per affiliation.
+\item
+ Use footnotes to indicate the affiliations.
+\end{enumerate}
+
+See the front matter of this document for examples. You are recommended
+to conform your choice to the journal you are submitting to.
+
+\section{Bibliography styles}\label{bibliography-styles}
+
+There are various bibliography styles available. You can select the
+style of your choice in the preamble of this document. These styles are
+Elsevier styles based on standard styles like Harvard and Vancouver.
+Please use BibTeX~to generate your bibliography and include DOIs
+whenever available.
+
+Here are two sample references: Feynman and Vernon Jr. (1963; Dirac
+1953).
+
+\section*{References}\label{references}
+\addcontentsline{toc}{section}{References}
+
+\hypertarget{refs}{}
+\hypertarget{ref-Dirac1953888}{}
+Dirac, P.A.M. 1953. ``The Lorentz Transformation and Absolute Time.''
+\emph{Physica} 19 (1---12): 888--96.
+doi:\href{https://doi.org/10.1016/S0031-8914(53)80099-6}{10.1016/S0031-8914(53)80099-6}.
+
+\hypertarget{ref-Feynman1963118}{}
+Feynman, R.P, and F.L Vernon Jr. 1963. ``The Theory of a General Quantum
+System Interacting with a Linear Dissipative System.'' \emph{Annals of
+Physics} 24: 118--73.
+doi:\href{https://doi.org/10.1016/0003-4916(63)90068-X}{10.1016/0003-4916(63)90068-X}.
+
+\end{document}
+
+
diff --git a/inst/rmarkdown/templates/pnas_article/resources/pnas-new.cls b/inst/rmarkdown/templates/pnas_article/resources/pnas-new.cls
new file mode 100644
index 000000000..ff9fa84f5
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/resources/pnas-new.cls
@@ -0,0 +1,414 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% pnas-new.cls, v1.2, 2016/02/28
+%
+% This class file enables authors to prepare research
+% articles for submission to PNAS.
+%
+% Please note that whilst this template provides a
+% preview of the typeset manuscript for submission, it
+% will not necessarily be the final publication layout.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either
+% version 1.3 of this license or any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt and
+% version 1.3 or later is part of all distributions
+% of LaTeX version 2005/12/01 or later.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% For use with latex+dvipdfm, pdflatex, xelatex & lualatex
+% For compiling with plain latex, please use latex+dvipdfm
+% to produce the PDF, not dvis -> ps -> pdf nor dvipdf
+%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{pnas-new}[28/02/2015, v1.2]
+\AtEndOfClass{\RequirePackage{microtype}}
+% Option for line numbers
+\newif\if@pnaslineno
+\DeclareOption{lineno}{\@pnaslinenotrue}
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{extarticle}}
+\ProcessOptions*
+\LoadClass{extarticle}
+
+%% Fonts and language
+\RequirePackage[utf8]{inputenc}
+\RequirePackage[english]{babel}
+\RequirePackage{amsmath,amsfonts,amssymb}
+\RequirePackage{lmodern}
+\RequirePackage[scaled]{helvet}
+\RequirePackage[T1]{fontenc}
+\RequirePackage{lettrine} % For dropped capitals
+
+%% For the Significance Statement & footnote on the first page
+\RequirePackage{afterpage}
+\RequirePackage{ifpdf,ifxetex}
+\ifpdf\else
+ \ifxetex\else
+ \def\pgfsysdriver{pgfsys-dvipdfm.def}
+ \pdfpagewidth=\paperwidth
+ \pdfpageheight=\paperheight
+\fi\fi
+\RequirePackage{xcolor}
+\RequirePackage{tikz}
+\RequirePackage[framemethod=tikz]{mdframed}
+
+%% For single column equations and balancing the columns on final page
+\RequirePackage{widetext}
+
+%% Hyperlinking
+\RequirePackage[colorlinks=true, allcolors=blue]{hyperref}
+
+%% Set up main title page fonts
+\newcommand{\headerfont}{\normalfont\sffamily\fontsize{7}{9} \selectfont}
+\newcommand{\footerfont}{\normalfont\sffamily\fontsize{7}{9} \selectfont}
+\newcommand{\titlefont}{\fontfamily{lmss}\bfseries\fontsize{22pt}{24pt}\selectfont}
+\newcommand{\dropcapfont}{\fontfamily{lmss}\bfseries\fontsize{26pt}{28pt}\selectfont}
+\newcommand{\datesfont}{\normalfont\sffamily\fontsize{7}{8}\selectfont}
+\newcommand{\absfont}{\normalfont\sffamily\bfseries\fontsize{8}{11}\selectfont}
+\newcommand{\keywordsfont}{\normalfont\rmfamily\fontsize{7}{10}\selectfont}
+\newcommand{\copyrightfont}{\normalfont\rmfamily\fontsize{6}{8}\selectfont}
+
+%% Set URL link color & font
+\renewcommand\UrlFont{\color{black}\sffamily}
+
+%% Author and affiliation
+\RequirePackage{authblk}
+\setlength{\affilsep}{8.5pt} % 16.5pts between base of author line and base of affil line
+\renewcommand\Authfont{\color{color0}\normalfont\sffamily\bfseries\fontsize{9}{11}\selectfont}
+\renewcommand\Affilfont{\color{color0}\normalfont\sffamily\fontsize{7}{8}\selectfont}
+\makeatletter
+\renewcommand\AB@affilsepx{; \protect\Affilfont}
+\makeatother
+\renewcommand\Authands{, and }
+
+%% Choose template type
+\newcommand*{\templatetype}[1]{%
+ \RequirePackage{#1}}
+
+%% Options for element switching
+\RequirePackage{xifthen}
+\newboolean{shortarticle}
+\newboolean{singlecolumn}
+
+%% For numbering just one line of an equation
+\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}
+
+%% Watermark
+\usepackage[printwatermark]{xwatermark}
+\newboolean{displaywatermark}
+\setboolean{displaywatermark}{true} % Set to false to remove the watermark
+\ifthenelse{\boolean{displaywatermark}}{%
+\newwatermark[allpages,color=gray!20,angle=45,scale=3,xpos=0,ypos=0]{DRAFT}}{}
+
+%% Copyright statement (not used)
+\newboolean{displaycopyright}
+\setboolean{displaycopyright}{false} % Confirmed as not required
+\RequirePackage{textcomp} % For copyright symbol styling
+\newcommand{\copyrightstatement}{\, \textcopyright\, 2015 by The National Academy of Sciences of the USA}
+
+%% Graphics, tables and other formatting
+\RequirePackage{graphicx,xcolor}
+\RequirePackage{colortbl}
+\RequirePackage{booktabs}
+\RequirePackage{algorithm}
+\RequirePackage[noend]{algpseudocode}
+\RequirePackage{changepage}
+\RequirePackage[twoside,%
+ letterpaper,includeheadfoot,%
+ layoutsize={8.125in,10.875in},%
+ layouthoffset=0.1875in,%
+ layoutvoffset=0.0625in,%
+ left=38.5pt,%
+ right=43pt,%
+ top=43pt,% 10pt provided by headsep
+ bottom=32pt,%
+ headheight=0pt,% No Header
+ headsep=10pt,%
+ footskip=25pt]{geometry}
+\RequirePackage[labelfont={bf,sf},%
+ labelsep=period,%
+ figurename=Fig.]{caption}
+\setlength{\columnsep}{13.5pt} % Distance between the two columns of text
+\setlength{\parindent}{12pt} % Paragraph indent
+
+%% Set document color scheme
+\definecolor{black50}{gray}{0.5} % 50% black for hrules
+\definecolor{color0}{RGB}{0,0,0} % Base
+\definecolor{color1}{RGB}{59,90,198} % author email, doi
+\definecolor{color2}{RGB}{16,131,16} %
+% For sig statement box
+\definecolor{pnasbluetext}{RGB}{0,101,165} %
+\definecolor{pnasblueback}{RGB}{205,217,235} %
+%\definecolor{pnasbluetext}{RGB}{0,115,209} % Not used
+%\definecolor{pnasblueback}{RGB}{210,230,247} % Not used
+
+%% Bibliography
+\RequirePackage[numbers,sort&compress]{natbib}
+\setlength{\bibsep}{0.0pt}
+\bibliographystyle{pnas2011}
+\renewcommand{\bibsection}{} % Remove header
+\renewcommand\bibfont{\normalfont\sffamily\fontsize{6}{8}\selectfont} % set font to be sans serif
+
+\makeatletter
+\renewcommand\@biblabel[1]{ #1.} % Remove brackets from label
+\def\tagform@#1{\maketag@@@{\bfseries(\ignorespaces#1\unskip\@@italiccorr)}}
+\renewcommand{\eqref}[1]{\textup{{\normalfont Eq.~(\ref{#1}}\normalfont)}}
+\makeatother
+
+%% Figure caption style
+\DeclareCaptionFormat{pnasformat}{\normalfont\sffamily\fontsize{7}{9}\selectfont#1#2#3}
+\captionsetup{format=pnasformat}
+
+%% Table style
+\RequirePackage{etoolbox}
+\captionsetup[table]{labelfont+={small},textfont+={small,sf,bf},skip=10pt,position=above}
+% booktabs provide nice spacing, but rule widths and distances need fixing
+\setlength{\heavyrulewidth}{0.5pt}
+\setlength{\lightrulewidth}{0.5pt}
+\setlength{\aboverulesep}{1.5pt}
+\setlength{\belowrulesep}{1.5pt}
+\setlength{\belowbottomsep}{10pt}
+\AtBeginEnvironment{tabular}{
+\sffamily\fontsize{7.5}{10}\selectfont
+}
+\newcommand{\addtabletext}[1]{{\setlength{\leftskip}{9pt}\fontsize{7}{9}\selectfont#1}}
+
+%% Equation numbering - use square brackets
+\makeatletter
+\renewcommand\tagform@[1]{\maketag@@@ {[\ignorespaces #1\unskip \@@italiccorr ]}}
+\makeatother
+
+%% Headers and footers
+\RequirePackage{fancyhdr} % custom headers/footers
+\RequirePackage{lastpage} % Number of pages in the document
+\pagestyle{fancy} % Enables the custom headers/footers
+
+%% For the line numbers overlay
+\def\leftlinenos{%
+ \pgfmathtruncatemacro{\leftstartlineno}{2*(\thepage - 1)*62 + 1}%
+ \pgfmathtruncatemacro{\leftendlineno}{(2*(\thepage - 1) + 1)*62}%
+ \foreach \x in {\leftstartlineno,...,\leftendlineno}{\noindent\x\\}%
+}
+\def\rightlinenos{%
+ \pgfmathtruncatemacro{\rightstartlineno}{(2*(\thepage - 1) + 1)*62 + 1}%
+ \pgfmathtruncatemacro{\rightendlineno}{(2*\thepage)*62}%
+ \foreach \x in {\rightstartlineno,...,\rightendlineno}{\noindent\x\\}%
+}
+
+\makeatletter
+\fancypagestyle{firststyle}{
+ \fancyfoot[R]{\footerfont PNAS\hspace{7pt}|\hspace{7pt}\textbf{\today}\hspace{7pt}|\hspace{7pt}vol. XXX\hspace{7pt}|\hspace{7pt}no. XX\hspace{7pt}|\hspace{7pt}\textbf{\thepage\textendash\pageref{LastPage}}}
+ \fancyfoot[L]{\footerfont\@ifundefined{@doi}{}{\@doi}}
+}
+\makeatother
+
+% Headers
+\fancyhead[LE,RO]{}
+\fancyhead[LO,RE]{}
+% Footers
+\lfoot{}%
+\cfoot{}%
+\rfoot{}%
+\makeatletter
+\fancyfoot[LE]{\footerfont\textbf{\thepage}\hspace{7pt}|\hspace{7pt}\@ifundefined{@doi}{}{\@doi}}
+\fancyfoot[RO]{\footerfont PNAS\hspace{7pt}|\hspace{7pt}\textbf{\today}\hspace{7pt}|\hspace{7pt}vol. XXX\hspace{7pt}|\hspace{7pt}no. XX\hspace{7pt}|\hspace{7pt}\textbf{\thepage}}
+\fancyfoot[RE,LO]{\footerfont\@ifundefined{@leadauthor}{}{\@leadauthor}\ifnum \value{authors} > 1\hspace{5pt}\textit{et al.}\fi}
+
+% Use footer routine for line numbers
+\AtBeginDocument{
+ \if@pnaslineno
+ \ifthenelse{\boolean{singlecolumn}}{
+ % use lineno package if singlecolumn
+ \RequirePackage{lineno}
+ \linenumbers
+ }{% use tikz if twocolumn
+ \fancyfoot[C]{\begin{tikzpicture}[remember picture,overlay]
+ \node at([xshift=1.5em,yshift=\dimexpr -0.0625in-53pt] current page.north west)[anchor=north west,text width=3em,font=\rmfamily,align=right] {\leftlinenos};%
+ \node at([xshift=-1.5em,yshift=\dimexpr -0.0625in-53pt] current page.north east)[anchor=north east,text width=3em,font=\rmfamily,align=left] {\rightlinenos};%
+ \end{tikzpicture}}
+ }
+ \fi
+}
+\makeatother
+
+\renewcommand{\headrulewidth}{0pt}% % No header rule
+\renewcommand{\footrulewidth}{0pt}% % No footer rule
+
+%% Section/subsection/paragraph set-up
+\RequirePackage[explicit]{titlesec}
+\renewcommand{\thesubsection}{\Alph{subsection}}
+
+\titleformat{\section}
+ {\large\sffamily\bfseries}
+ {\thesection.}
+ {0.5em}
+ {#1}
+ []
+\titleformat{name=\section,numberless}
+ {\large\sffamily\bfseries}
+ {}
+ {0em}
+ {#1}
+ []
+\titleformat{\subsection}[runin]
+ {\sffamily\bfseries}
+ {\thesubsection.}
+ {0.5em}
+ {#1. }
+ []
+\titleformat{\subsubsection}[runin]
+ {\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}{2pt}
+\titlespacing*{\subsubsection}{0pc}{2ex \@plus2.5pt \@minus1.5pt}{2pt}
+\titlespacing*{\paragraph}{0pc}{1.5ex \@plus2pt \@minus1pt}{12pt}
+
+%% Article meta data additional fields
+\newcommand{\additionalelement}[1]{\def\@additionalelement{#1}}
+\newcommand{\dates}[1]{\def\@dates{#1}}
+\newcommand{\doi}[1]{\def\@doi{#1}}
+\newcommand{\leadauthor}[1]{\def\@leadauthor{#1}}
+\newcommand{\etal}[1]{\def\@etal{#1}}
+\newcommand{\keywords}[1]{\def\@keywords{#1}}
+\newcommand{\authorcontributions}[1]{\def\@authorcontributions{#1}}
+\newcommand{\authordeclaration}[1]{\def\@authordeclaration{#1}}
+\newcommand{\equalauthors}[1]{\def\@equalauthors{#1}}
+\newcommand{\correspondingauthor}[1]{\def\@correspondingauthor{#1}}
+\newcommand{\significancestatement}[1]{\def\@significancestatement{#1}}
+\newcommand{\matmethods}[1]{\def\@matmethods{#1}}
+\newcommand{\acknow}[1]{\def\@acknow{#1}}
+
+%% Dropped capital for first letter of main text
+\newcommand{\dropcap}[1]{\lettrine[lines=2,lraise=0.05,findent=0.1em, nindent=0em]{{\dropcapfont{#1}}}{}}
+
+%% Abstract formatting
+\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}
+
+% Define an environment with abstract content and styling
+\newcommand{\abscontent}{
+\noindent
+{%
+\parbox{\dimexpr\linewidth}{%
+ \vskip3pt%
+ \absfont \theabstract
+}%
+}%
+\vskip10pt%
+\noindent
+{\parbox{\dimexpr\linewidth}{%
+{
+ \keywordsfont \@ifundefined{@keywords}{}{\@keywords}}%
+}}%
+\vskip12pt%
+}
+
+% Option to format abstract differently for certain layouts (not used)
+\newcommand{\abscontentformatted}{
+\abscontent
+}
+
+%% Manual adjustment to line up main content with line numbers
+\newlength\pnas@vertadjust
+\newcommand\verticaladjustment[1]{\setlength{\pnas@vertadjust}{#1}}
+
+%% Custom title page
+\renewcommand{\@maketitle}{%
+{%
+\ifthenelse{\boolean{shortarticle}}
+{\ifthenelse{\boolean{singlecolumn}}{}{
+{\raggedright\baselineskip= 24pt\titlefont \@title\par}%
+\vskip10pt% 21pts between base of title and base of author line
+{\raggedright \@author\par}
+\vskip8pt% 16pts between base of affiliations and base of dates line
+{\raggedright \datesfont \@ifundefined{@dates}{}{\@dates}\par}
+\vskip12pt%
+}}
+{% else
+%
+\vskip10pt%
+{\raggedright\baselineskip= 24pt\titlefont \@title\par}%
+\vskip10pt% 21pts between base of title and base of author line
+{\raggedright \@author\par}
+\vskip8pt% 16pts between base of affiliations and base of dates line
+{\raggedright \datesfont \@ifundefined{@dates}{}{\@dates}\par}
+\vskip12pt
+{%
+\abscontent
+}%
+\vskip25pt%
+}%
+%%%
+\@additionalelement
+}%
+\vskip\pnas@vertadjust
+}%
+
+%% Footnotes set up
+\RequirePackage[flushmargin,ragged]{footmisc}
+\renewcommand*{\footnotelayout}{\normalfont\sffamily\fontsize{6}{8}\selectfont} % set the footnote font
+\renewcommand{\footnoterule}{% Set the footnote hrule style
+ \kern -3pt
+ {\color{black50} \hrule width 72pt height 0.25pt}
+ \kern 2.5pt
+}
+
+%% Set up the acknowledgments field
+\titleclass{\acknow@section}{straight}[\part]
+\newcounter{acknow@section}
+\providecommand*{\toclevel@acknow@section}{0}
+% Format is set for research articles by default
+\titleformat{\acknow@section}[runin]
+ {\sffamily\normalsize\bfseries}
+ {}
+ {0em}
+ {#1.}
+ []
+\titlespacing{\acknow@section}
+ {0pt}
+ {3.25ex plus 1ex minus .2ex}
+ {1.5ex plus .2ex}
+\newcommand{\showacknow}{% Display acknowledgments section
+\@ifundefined{@acknow}{}{\acknow@section{ACKNOWLEDGMENTS}\small\@acknow}
+}
+
+%% Set up the materials&methods field
+\titleclass{\matmethods@section}{straight}[\part]
+\newcounter{matmethods@section}
+\providecommand*{\toclevel@matmethods@section}{0}
+% Format is set for research articles by default
+\titleformat{\matmethods@section}
+ {\sffamily\normalsize\bfseries}
+ {}
+ {0em}
+ {#1}
+ []
+\titlespacing{\matmethods@section}
+ {0pt}
+ {3.25ex plus 1ex minus .2ex}
+ {1.5ex plus .2ex}
+\newcommand{\showmatmethods}{% Display materials&methods section
+\@ifundefined{@matmethods}{}{\matmethods@section{Materials and Methods}{\small\noindent\@matmethods}}
+}
+
+%% Other packages
+\RequirePackage{enumitem} % For reducing bullet list item separation
\ No newline at end of file
diff --git a/inst/rmarkdown/templates/pnas_article/resources/pnas.csl b/inst/rmarkdown/templates/pnas_article/resources/pnas.csl
new file mode 100644
index 000000000..9c546ae36
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/resources/pnas.csl
@@ -0,0 +1,165 @@
+
+
diff --git a/inst/rmarkdown/templates/pnas_article/resources/template.tex b/inst/rmarkdown/templates/pnas_article/resources/template.tex
new file mode 100755
index 000000000..de806708d
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/resources/template.tex
@@ -0,0 +1,95 @@
+\documentclass[9pt,twocolumn,twoside]{pnas-new}
+
+%% Some pieces required from the pandoc template
+\providecommand{\tightlist}{%
+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
+
+% Use the lineno option to display guide line numbers if required.
+% Note that the use of elements such as single-column equations
+% may affect the guide line number alignment.
+$if(lineno)$
+\lineno
+$endif$
+
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+$if(tables)$
+\usepackage{longtable}
+$endif$
+
+$for(header-includes)$
+$header-includes$
+$endfor$
+
+$if(pnas_type)$
+\templatetype{$pnas_type$} % Choose template
+$else$
+\templatetype{pnasresearcharticle}
+$endif$
+
+\title{$title$}
+
+$for(author)$
+\author[$author.affiliation$]{$author.name$}
+$endfor$
+
+$for(address)$
+ \affil[$address.code$]{$address.address$}
+$endfor$
+
+
+% Please give the surname of the lead author for the running footer
+\leadauthor{$lead_author_surname$}
+
+% Please add here a significance statement to explain the relevance of your work
+\significancestatement{$significance$}
+
+
+\authorcontributions{$author_contributions$}
+
+$if(conflict_of_interest)$
+\authordeclaration{$conflict_of_interest$}
+$endif$
+
+$if(equal_authors)$
+\equalauthors{\textsuperscript{$equal_authors.code$} $equal_authors.text$}
+$endif$
+
+\correspondingauthor{\textsuperscript{$corresponding_author.code$} $corresponding_author.text$}
+
+% Keywords are not mandatory, but authors are strongly encouraged to provide them. If provided, please include two to five keywords, separated by the pipe symbol, e.g:
+$if(keywords)$ \keywords{ $for(keywords)$ $keywords$ $sep$| $endfor$ $endif$ }
+
+\begin{abstract}
+$abstract$
+\end{abstract}
+
+\dates{This manuscript was compiled on \today}
+\doi{\url{www.pnas.org/cgi/doi/10.1073/pnas.XXXXXXXXXX}}
+
+\begin{document}
+
+% Optional adjustment to line up main text (after abstract) of first page with line numbers, when using both lineno and twocolumn options.
+% You should only change this length when you've finalised the article contents.
+\verticaladjustment{-2pt}
+
+\maketitle
+\thispagestyle{firststyle}
+\ifthenelse{\boolean{shortarticle}}{\ifthenelse{\boolean{singlecolumn}}{\abscontentformatted}{\abscontent}}{}
+
+% If your first paragraph (i.e. with the \dropcap) contains a list environment (quote, quotation, theorem, definition, enumerate, itemize...), the line after the list may have some extra indentation. If this is the case, add \parshape=0 to the end of the list environment.
+
+\acknow{$acknowledgements$}
+
+$body$
+
+$for(include-after)$
+$include-after$
+$endfor$
+
+
+% Bibliography
+% \bibliography{pnas-sample}
+
+\end{document}
+
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/algorithm.sty b/inst/rmarkdown/templates/pnas_article/skeleton/algorithm.sty
new file mode 100644
index 000000000..4ad31b578
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/algorithm.sty
@@ -0,0 +1,108 @@
+%%%%%%%%%%% ALGORITHMS STYLE %%%%%%%%%%%
+% This style defines an environment for algorithms with the following
+% features:
+%
+% 1) Defines an Theorem like environment (not exactly one) for
+% algorithms called ``algorithm''.
+% \begin{algorithm}{NAME} ... \end{algorithm}
+% NAME is the NAME of the algorithm.
+% Algorithms are numbered using a counter called ``algorithm''.
+%
+% 2) Inside this environment, the following commands are defined.
+%
+% \= Put the small left arrow commonly used for assignment.
+%
+% \invariant{INVARIANT} Use to describe invariants, put its parameter
+% between ``{}'' in math mode.
+%
+% \begin{Block} ... \end{Block} Environment use to start a indented
+% block of instructions \end{Block} put
+% an ``end'' to close the block.
+%
+% \nextBlock{SEPARATOR} Inside a Block, it allows to put a separator
+% of parts of the indented block. Usefull for
+% constructions like ``IF..THEN..ELSE..END''
+% i.e. If cond then
+% \begin{Block}
+% then part
+% \nextBlock{else}
+% else part
+% \end{Block}
+%
+% 3) \Blockindent and \algorithmindent are length that specify the
+% indentention of Blocks and of the algorithm resp.
+%
+% 4) Instructions are separated by ``\\'', ``\par'' or by leaving a
+% blank line. Before an ``\end{Block}'' a ``\\'' can't be used.
+%
+%
+% Created by Jose Alberto Fernandez R.
+% e-mail: alberto@cs.umd.edu
+%
+
+%
+\newcounter{algorithm}
+\newtheorem{Alg@orithm}[algorithm]{Algorithm}
+% Invariants
+\newcommand{\inv@ariant}[1]{\mbox{$\{#1\}$}}
+% Steps environment
+\newenvironment{ste@ps}[1]{
+\begin{list}{}
+{\setlength\labelsep{0in}
+\addtolength\partopsep\topsep
+\addtolength\partopsep\parsep
+\setlength\parsep{0in}
+\setlength\topsep{0in}
+\setlength\itemsep{0in}
+\setlength\labelwidth{0in}
+\setlength\rightmargin{0in}
+\setlength\leftmargin{#1}}
+}{
+\end{list}
+}
+
+% Block environment
+% Indentation of the Block
+\newlength{\Blockindent}
+% NextBlock command
+\newcommand{\next@Block}[1]{
+\end{ste@ps}
+#1
+\begin{ste@ps}{\Blockindent}
+\item
+}
+
+\newenvironment{Blo@ck}{
+\let\nextBlock\next@Block
+\begin{ste@ps}{\Blockindent}
+\item
+}{
+\end{ste@ps}
+end
+}
+% Algorithm environment
+% Assign command
+\newcommand{\ass@ign}{\mbox{$\leftarrow$}}
+% Indentation of the algorithm
+\newlength{\algorithmindent}
+% Algorithm definition
+\newenvironment{algorithm}[1]{
+\let\=\ass@ign
+\let\invariant\inv@ariant
+\let\Block\Blo@ck
+\let\endBlock\endBlo@ck
+\begin{Alg@orithm} #1
+\rm\par
+\begin{ste@ps}{\algorithmindent}
+\item
+}{
+\end{ste@ps}
+\bf end
+\end{Alg@orithm}
+}
+
+% Setting default indentation
+\setlength{\algorithmindent}{1em}
+\setlength{\Blockindent}{2em}
+
+% End of algorithm.sty
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/algorithmicx.sty b/inst/rmarkdown/templates/pnas_article/skeleton/algorithmicx.sty
new file mode 100644
index 000000000..bfb7dabaf
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/algorithmicx.sty
@@ -0,0 +1,786 @@
+% ALGORITHMIC STYLE -- Released 27 APR 2005
+% for LaTeX version 2e
+%
+% Copyright Szasz Janos
+% E-mail szaszjanos@users.sourceforge.net
+%
+%
+% *** INITIALISING ***
+%
+%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{algorithmicx}[2005/04/27 v1.2 Algorithmicx]
+\RequirePackage{ifthen}
+\typeout{Document Style algorithmicx 1.2 - a greatly improved `algorithmic' style}
+%
+\newcounter{ALG@line}
+\newcounter{ALG@rem}
+\newcounter{ALG@nested}
+\newlength{\ALG@tlm}
+\newlength{\ALG@thistlm}
+\newcounter{ALG@Lnr}% the number of defined languages
+\setcounter{ALG@Lnr}{0}
+\newcounter{ALG@blocknr}% the number of defined blocks
+\setcounter{ALG@blocknr}{0}
+\newcounter{ALG@storecount}% number of stored but not restored algorithmic environments
+\setcounter{ALG@storecount}{0}
+\newcounter{ALG@tmpcounter}% only to decrement things
+\newlength\ALG@tmplength%
+%\def\algorithmicnoindent{-\ALG@tlm}
+% \def\algbackskipbegin{\hskip\ALG@ctlm}
+%\def\algbackskip{\hskip-\ALG@thistlm}
+%\def\algbackskipend{\hskip-\ALG@tlm}
+\def\ALG@defaultindent{\algorithmicindent}
+%
+% conditional states
+%
+\def\ALG@newcondstate#1%
+ {%
+ \expandafter\edef\csname ALG@x@#1\endcsname%
+ {\expandafter\noexpand\csname @@ALG@x@#1\endcsname}%
+ }%
+\ALG@newcondstate{notext}%
+\ALG@newcondstate{default}%
+%
+%
+% *** ALGORITHMIC ***
+%
+%
+\newcommand\ALG@beginblock[1]% #1 - indentation
+ {%
+ \ALG@thistlm\ALG@tlm%
+ \addtolength\ALG@tlm{#1}%
+ \addtocounter{ALG@nested}{1}%
+ \setlength\ALG@tmplength{#1}%
+ \expandafter\edef\csname ALG@ind@\theALG@nested\endcsname{\the\ALG@tmplength}%
+ }%
+\newcommand\ALG@endblock%
+ {%
+ \addtolength\ALG@tlm{-\csname ALG@ind@\theALG@nested\endcsname}%
+ \addtocounter{ALG@nested}{-1}%
+ \ALG@thistlm\ALG@tlm%
+ }%
+%
+% algorithmic environment
+%
+\def\ALG@step%
+ {%
+ \addtocounter{ALG@line}{1}%
+ \addtocounter{ALG@rem}{1}%
+ \ifthenelse{\equal{\arabic{ALG@rem}}{\ALG@numberfreq}}%
+ {\setcounter{ALG@rem}{0}\alglinenumber{\arabic{ALG@line}}}%
+ {}%
+ }%
+\newenvironment{algorithmic}[1][0]%
+ {%
+ \edef\ALG@numberfreq{#1}%
+ \def\@currentlabel{\theALG@line}%
+ %
+ \setcounter{ALG@line}{0}%
+ \setcounter{ALG@rem}{0}%
+ %
+ \let\\\algbreak%
+ %
+ \expandafter\edef\csname ALG@currentblock@\theALG@nested\endcsname{0}%
+ \expandafter\let\csname ALG@currentlifetime@\theALG@nested\endcsname\relax%
+ %
+ \begin{list}%
+ {\ALG@step}%
+ {%
+ \rightmargin\z@%
+ \itemsep\z@ \itemindent\z@ \listparindent2em%
+ \partopsep\z@ \parskip\z@ \parsep\z@%
+ \labelsep 0.5em \topsep 0.2em%\skip 1.2em
+ \ifthenelse{\equal{#1}{0}}%
+ {\labelwidth 0.5em}%
+ {\labelwidth 1.2em}%
+ \leftmargin\labelwidth \addtolength{\leftmargin}{\labelsep}% Ok. the perfect leftmargin :-))
+ \ALG@tlm\z@%
+ }%
+ \setcounter{ALG@nested}{0}%
+ \ALG@beginalgorithmic%
+ }%
+ {% end{algorithmic}
+ % check if all blocks are closed
+ \ALG@closeloops%
+ \expandafter\ifnum\csname ALG@currentblock@\theALG@nested\endcsname=0\relax%
+ \else%
+ \PackageError{algorithmicx}{Some blocks are not closed!!!}{}%
+ \fi%
+ \ALG@endalgorithmic%
+ \end{list}%
+ }%
+%
+%
+% *** Functional core ***
+%
+%
+\def\ALG@makeentity#1% execute the entity (#1)
+ {%
+ \def\ALG@thisentity{#1}%
+ \expandafter\ifx\csname ALG@b@\ALG@L @#1@0\endcsname\relax%
+ \let\ALG@makenobeginrepeat\ALG@makenobegin\ALG@makenobeginrepeat% this entitie ends or continues blocks
+ \else%
+ \let\ALG@makebeginrepeat\ALG@makebegin\ALG@makebeginrepeat% this entitie can open blocks
+ \fi%
+ \ALG@entitiecommand%
+ }%
+%
+\def\ALG@makebegin% executes an entitie that can open blocks
+ {%
+ \expandafter\let\expandafter\ALG@thislifetime\csname ALG@currentlifetime@\theALG@nested\endcsname%
+ \ifx\ALG@thislifetime\relax%
+ \let\ALG@makebeginrepeat\ALG@doentity% in infinite block I can open my block
+ \else%
+ \ifnum\ALG@thislifetime>0\relax%
+ \ifnum\ALG@thislifetime>65534\else%
+ \setcounter{ALG@tmpcounter}{\ALG@thislifetime}% the block has 'space' for another included block
+ \addtocounter{ALG@tmpcounter}{-1}%
+ \expandafter\edef\csname ALG@currentlifetime@\theALG@nested\endcsname{\arabic{ALG@tmpcounter}}%
+ \fi%
+ \let\ALG@makebeginrepeat\ALG@doentity%
+ \else% the block needs to be closed
+ \expandafter\ifx\csname ALG@b@\ALG@L @\ALG@thisentity @\csname ALG@currentblock@\theALG@nested\endcsname\endcsname\relax%
+ \ALG@closebyforce% I can not close this block, continue after it is closed by force
+% \ALG@makebegin%
+ \else%
+ % the block would be closed automatically, but this entitie can close it, so let's do it with the entity
+ \let\ALG@makebeginrepeat\ALG@doentity%
+ \fi%
+ \fi%
+ \fi%
+ \ALG@makebeginrepeat%
+ }%
+%
+\def\ALG@makenobegin% executes an entitie that can not open blocks
+ {%
+ \expandafter\ifx\csname ALG@currentlifetime@\theALG@nested\endcsname\relax%
+ \let\ALG@makenobeginrepeat\ALG@doentity% an infinite block must be broken
+ \else%
+ \expandafter\ifx\csname ALG@b@\ALG@L @\ALG@thisentity @\csname ALG@currentblock@\theALG@nested\endcsname\endcsname\relax%
+ \ALG@closebyforce% the block must be ended by force,
+ \else%
+ \let\ALG@makenobeginrepeat\ALG@doentity% I can continue / end this block, let's do it
+ \fi%
+ \fi%
+ \ALG@makenobeginrepeat%
+ }%
+%
+\def\ALG@dobegin%
+ {%
+ \ALG@beginblock{\csname ALG@i@\ALG@L @\ALG@thisentity @\ALG@thisblock\endcsname}%
+ \expandafter\edef\csname ALG@currentblock@\theALG@nested\endcsname{\csname ALG@b@\ALG@L @\ALG@thisentity @\ALG@thisblock\endcsname}%
+ \expandafter\ifx\csname ALG@c@\ALG@L @\ALG@thisentity @\ALG@thisblock\endcsname\relax%
+ \expandafter\let\csname ALG@currentlifetime@\theALG@nested\endcsname\relax%
+ \else%
+ \expandafter\edef\csname ALG@currentlifetime@\theALG@nested\endcsname{\csname ALG@c@\ALG@L @\ALG@thisentity @\ALG@thisblock\endcsname}%
+ \fi%
+ }%
+%
+\def\ALG@doend%
+ {%
+ \ALG@endblock%
+ }%
+%
+\def\ALG@doentity% the number of the closed block, the entitie
+ {%
+ \edef\ALG@thisblock{\csname ALG@currentblock@\theALG@nested\endcsname}%
+ \expandafter\ifx\csname ALG@b@\ALG@L @\ALG@thisentity @\ALG@thisblock\endcsname\relax%
+ \def\ALG@thisblock{0}%
+ \fi%
+ \ALG@getentitytext%
+ \ifnum\ALG@thisblock=0\else\ALG@doend\fi%
+ \ifx\ALG@text\ALG@x@notext%
+ \item[]\nointerlineskip%\vskip-\prevdepth\nointerlineskip% bug: if there are no text and no lines, then this is wrong
+ \else%
+ \item%
+ \fi%
+ \noindent\hskip\ALG@tlm%
+ \expandafter\ifnum0=\csname ALG@b@\ALG@L @\ALG@thisentity @\ALG@thisblock\endcsname\else%
+ \ALG@dobegin%
+ \fi%
+ \def\ALG@entitiecommand{\ALG@displayentity}%
+ }%
+%
+\def\ALG@getentitytext%
+ {%
+ \expandafter\let\expandafter\ALG@text\csname ALG@t@\ALG@L @\ALG@thisentity @\ALG@thisblock\endcsname%
+ \ifx\ALG@text\ALG@x@default%
+ % block specific - default
+ \expandafter\let\expandafter\ALG@text\csname ALG@t@\ALG@L @\ALG@thisentity\endcsname%
+ \ifx\ALG@text\ALG@x@default%
+ % block specific - default, language specific - default
+ \def\ALG@text{\ALG@deftext{\ALG@thisentity}}%
+ \fi%
+ \fi%
+ }%
+%
+\def\ALG@deftext{\csname ALG@deftext@\ALG@L\endcsname}%
+%
+\def\ALG@displayentity%
+ {%
+ \ifx\ALG@text\ALG@x@notext%
+ \let\ALG@text\relax%
+ \fi
+ \ALG@text%
+ }%
+%
+\def\ALG@closebyforce%
+ {%
+ \ALG@endblock%
+ }%
+%
+\def\ALG@closeloops% closes all finite blocks
+ {%
+ \expandafter\ifx\csname ALG@currentlifetime@\theALG@nested\endcsname\relax%
+ \else% only if it is finite
+ \ALG@closebyforce% the block must be ended by force,
+ \ALG@closeloops% the command still runs
+ \fi%
+ }%
+%
+%
+% *** Low level block/entitie defining commands ***
+%
+%
+\def\ALG@bl@{0}% the BIG block
+\let\ALG@bl@@\ALG@bl@% the BIG block
+%
+% Create a block
+%
+\def\ALG@createblock#1% create the block #1, if it does not exists
+ {%
+ \@ifundefined{ALG@bl@\ALG@Ld @#1}% needs to be created?
+ {%
+ \addtocounter{ALG@blocknr}{1}% increment the block counter
+ \expandafter\edef\csname ALG@bl@\ALG@Ld @#1\endcsname{\arabic{ALG@blocknr}}% set the block number
+ }%
+ {}%
+ }%
+%
+% Get the block number
+%
+\def\ALG@getblocknumber#1{\csname ALG@bl@\ALG@Ld @#1\endcsname}%
+%
+% Create an entitie
+%
+\def\ALG@createentitie#1% create the entitie #1, if it does not exists
+ {%
+ \expandafter\ALG@edefcmd\csname #1\endcsname{\noexpand\ALG@makeentity{#1}}%
+ \@ifundefined{ALG@t@\ALG@Ld @#1}% the entity text is defined in this language?
+ {%
+ \expandafter\let\csname ALG@t@\ALG@Ld @#1\endcsname\ALG@x@default%
+ }%
+ {}%
+ }%
+%
+\def\ALG@createtext#1#2% #1 = closed block; #2 = entitie; creates \ALG@t@#2@#1
+ {%
+ \expandafter\let\csname ALG@t@\ALG@Ld @#2@#1\endcsname\ALG@x@default%
+ }%
+%
+% End and Continue block
+%
+\def\ALG@endandcontinueblock#1#2#3#4#5% #1 = new block; #2 = old block; #3 = entitie; #4 = credits; #5 = indent
+ {%
+ \ifthenelse{\equal{#3}{}}{}% execute only if the entity is not empty
+ {%
+ \ALG@createentitie{#3}% create the entitie
+ \ALG@createblock{#2}% create the old block, if needed
+ \ifthenelse{\equal{#1}{}}% whe need to open a new block?
+ {\expandafter\edef\csname ALG@b@\ALG@Ld @#3@\ALG@getblocknumber{#2}\endcsname{0}}% no, just close the old one
+ {% yes,
+ \ALG@createblock{#1}% create the block
+ \expandafter\edef\csname ALG@b@\ALG@Ld @#3@\ALG@getblocknumber{#2}\endcsname{\ALG@getblocknumber{#1}}% ending the old block opens a new one
+ \ifthenelse{\equal{#4}{}}% infinite or finite credits?
+ {\expandafter\let\csname ALG@c@\ALG@Ld @#3@\ALG@getblocknumber{#2}\endcsname\relax}% infinite credits
+ {\expandafter\edef\csname ALG@c@\ALG@Ld @#3@\ALG@getblocknumber{#2}\endcsname{#4}}% finite credits
+ \ifthenelse{\equal{#5}{}}% default or specified indentation
+ {\expandafter\let\csname ALG@i@\ALG@Ld @#3@\ALG@getblocknumber{#2}\endcsname\ALG@defaultindent}% default indentation
+ {\expandafter\edef\csname ALG@i@\ALG@Ld @#3@\ALG@getblocknumber{#2}\endcsname{#5}}% indentation is specified
+ }%
+ \ALG@createtext{\ALG@getblocknumber{#2}}{#3}%
+ }%
+ }%
+%
+% macros used in declarations
+%
+\def\ALG@p@endtext@E{\algrenewtext{\ALG@v@end}}%
+\def\ALG@p@endtext@xE{\algrenewtext[\ALG@v@newblock]{\ALG@v@end}}%
+\def\ALG@p@endtext@nE{\algnotext{\ALG@v@end}}%
+\def\ALG@p@endtext@xnE{\algnotext[\ALG@v@newblock]{\ALG@v@end}}%
+\def\ALG@p@endtext@{}%
+% starttext defines are more compex -- care must be taken for the optional parameters
+\def\ALG@p@starttext@S{\ALG@p@s@process{\algrenewtext}}%
+\def\ALG@p@starttext@C{\ALG@p@s@process{\algrenewtext}}%
+\def\ALG@p@starttext@xC{\ALG@p@s@process{\algrenewtext[\ALG@v@oldblock]}}%
+\def\ALG@p@s@process#1%
+ {%
+ \ifthenelse{\equal{\ALG@v@start}{}}%
+ {\ALG@p@endtext}%
+ {\@ifnextchar{[}{\ALG@p@s@getparamcount{#1}}{\ALG@p@s@simple{#1}}}%
+ }%
+\def\ALG@p@s@getparamcount#1[#2]%
+ {%
+ \@ifnextchar{[}{\ALG@p@s@getdefparam{#1}{#2}}{\ALG@p@s@param{#1}{#2}}%
+ }%
+\def\ALG@p@s@getdefparam#1#2[#3]%
+ {%
+ \ALG@p@s@defparam{#1}{#2}{#3}%
+ }%
+\def\ALG@p@s@simple#1#2{#1{\ALG@v@start}{#2}\ALG@p@endtext}%
+\def\ALG@p@s@param#1#2#3{#1{\ALG@v@start}[#2]{#3}\ALG@p@endtext}%
+\def\ALG@p@s@defparam#1#2#3#4{#1{\ALG@v@start}[#2][#3]{#4}\ALG@p@endtext}%
+% the rest of the crew
+\def\ALG@p@starttext@nS{\algnotext{\ALG@v@start}\ALG@p@endtext}%
+\def\ALG@p@starttext@nC{\algnotext{\ALG@v@start}\ALG@p@endtext}%
+\def\ALG@p@starttext@xnC{\algnotext[\ALG@v@oldblock]{\ALG@v@start}\ALG@p@endtext}%
+\def\ALG@p@starttext@{\ALG@p@endtext}%
+\def\ALG@p@indent@def#1{\def\ALG@v@indent{#1}\ALG@p@setup}%
+\def\ALG@p@indent@{\def\ALG@v@indent{}\ALG@p@setup}%
+\def\ALG@p@credits@def#1{\def\ALG@v@credits{#1}\ALG@p@indent}%
+\def\ALG@p@credits@{\ALG@p@indent}%
+\def\ALG@p@end@def#1{\def\ALG@v@end{#1}\ALG@p@credits}%
+\def\ALG@p@end@{\def\ALG@v@end{}\ALG@p@credits}%
+\def\ALG@p@start@def#1{\def\ALG@v@start{#1}\ALG@p@end}%
+\def\ALG@p@start@{\def\ALG@v@start{}\ALG@p@end}%
+\def\ALG@p@oldblock@def#1{\def\ALG@v@oldblock{#1}\ALG@p@start}%
+\def\ALG@p@oldblock@{\def\ALG@v@oldblock{}\ALG@p@start}%
+\newcommand\ALG@p@newblock[1][]{\def\ALG@v@newblock{#1}\ALG@p@oldblock}%
+\def\ALG@p@setup%
+ {%
+ \ifthenelse{\equal{\ALG@v@newblock}{}}%
+ {%
+ \ifthenelse{\equal{\ALG@v@start}{}}%
+ {%
+ \PackageError{algorithmicx}{Block or starting entitie must be specified!!!}{}%
+ }%
+ {%
+ \let\ALG@v@newblock\ALG@v@start%
+ }%
+ }%
+ {%
+ }%
+ \ALG@endandcontinueblock%
+ {\ALG@v@newblock}{\ALG@v@oldblock}{\ALG@v@start}%
+ {\ALG@v@credits}{\ALG@v@indent}%
+ \ALG@endandcontinueblock%
+ {}{\ALG@v@newblock}{\ALG@v@end}%
+ {}{}%
+ \ALG@p@starttext%
+ }%
+%
+% param handling
+%
+\newcommand\ALG@p@def[2][def]%
+ {%
+ \expandafter\let\csname ALG@p@#2\expandafter\endcsname\csname ALG@p@#2@#1\endcsname%
+ }%
+\def\ALG@p@undef{\ALG@p@def[]}%
+%
+\def\ALG@p@ons{\ALG@p@def{start}}%
+\def\ALG@p@onS{\ALG@p@def{start}\ALG@p@def[S]{starttext}}%
+\def\ALG@p@onc{\ALG@p@def{oldblock}\ALG@p@def{start}}%
+\def\ALG@p@onC{\ALG@p@def{oldblock}\ALG@p@def{start}\ALG@p@def[C]{starttext}}%
+\def\ALG@p@one{\ALG@p@def{end}}%
+\def\ALG@p@onE{\ALG@p@def{end}\ALG@p@def[E]{endtext}}%
+\def\ALG@p@onxC{\ALG@p@def{oldblock}\ALG@p@def{start}\ALG@p@def[xC]{starttext}}%
+\def\ALG@p@onxE{\ALG@p@def{end}\ALG@p@def[xE]{endtext}}%
+\def\ALG@p@onnS{\ALG@p@def{start}\ALG@p@def[nS]{starttext}}%
+\def\ALG@p@onnC{\ALG@p@def{oldblock}\ALG@p@def{start}\ALG@p@def[nC]{starttext}}%
+\def\ALG@p@onnE{\ALG@p@def{end}\ALG@p@def[nE]{endtext}}%
+\def\ALG@p@onxnC{\ALG@p@def{oldblock}\ALG@p@def{start}\ALG@p@def[xnC]{starttext}}%
+\def\ALG@p@onxnE{\ALG@p@def{end}\ALG@p@def[xnE]{endtext}}%
+\def\ALG@p@onb{\def\ALG@v@credits{}}%
+\def\ALG@p@onl{\def\ALG@v@credits{1}}%
+\def\ALG@p@onL{\ALG@p@def{credits}}%
+\def\ALG@p@oni{\ALG@p@def{indent}}%
+%
+\def\ALG@p@main#1%
+ {%
+ \@ifundefined{ALG@ps@\ALG@p@state @#1}%
+ {%
+ \csname ALG@ps@\ALG@p@state @other\endcsname{#1}%
+ }%
+ {%
+ \csname ALG@ps@\ALG@p@state @#1\endcsname%
+ }%
+ \ALG@p@rec%
+ }%
+% STATE : <>
+\expandafter\def\csname ALG@ps@@]\endcsname{\let\ALG@p@rec\relax}%
+\def\ALG@ps@@s{\ALG@p@ons}%
+\def\ALG@ps@@S{\ALG@p@onS}%
+\def\ALG@ps@@c{\ALG@p@onc}%
+\def\ALG@ps@@C{\ALG@p@onC}%
+\def\ALG@ps@@e{\ALG@p@one}%
+\def\ALG@ps@@E{\ALG@p@onE}%
+\def\ALG@ps@@N{\typeout{algdef: 'N' obsoloted, use 'nE'.}\ALG@p@onnE}%
+\def\ALG@ps@@b{\ALG@p@onb}%
+\def\ALG@ps@@l{\ALG@p@onl}%
+\def\ALG@ps@@L{\ALG@p@onL}%
+\def\ALG@ps@@i{\ALG@p@oni}%
+\def\ALG@ps@@x{\def\ALG@p@state{x}}%
+\def\ALG@ps@@n{\def\ALG@p@state{n}}%
+\def\ALG@ps@@other#1{\typeout{algdef: Ignoring unknown token #1}}%
+% STATE : x
+\def\ALG@ps@x@C{\def\ALG@p@state{}\ALG@p@onxC}%
+\def\ALG@ps@x@E{\def\ALG@p@state{}\ALG@p@onxE}%
+\def\ALG@ps@x@N{\def\ALG@p@state{}\typeout{algdef: 'xN' obsoloted, use 'xnE'.}\ALG@p@onxnE}%
+\def\ALG@ps@x@n{\def\ALG@p@state{xn}}%
+\def\ALG@ps@x@other#1%
+ {%
+ \typeout{algdef: Ignoring 'x' before '#1'.}%
+ \def\ALG@p@state{}%
+ \def\ALG@p@rec{\let\ALG@p@rec\ALG@p@main\ALG@p@rec#1}%
+ }%
+% STATE : n
+\def\ALG@ps@n@S{\def\ALG@p@state{}\ALG@p@onnS}%
+\def\ALG@ps@n@C{\def\ALG@p@state{}\ALG@p@onnC}%
+\def\ALG@ps@n@E{\def\ALG@p@state{}\ALG@p@onnE}%
+\def\ALG@ps@n@x{\def\ALG@p@state{nx}}%
+\def\ALG@ps@n@other#1%
+ {%
+ \typeout{algdef: Ignoring 'n' before '#1'.}%
+ \def\ALG@p@state{}%
+ \def\ALG@p@rec{\let\ALG@p@rec\ALG@p@main\ALG@p@rec#1}%
+ }%
+% STATE : xn
+\def\ALG@ps@xn@C{\def\ALG@p@state{}\ALG@p@onxnC}%
+\def\ALG@ps@xn@E{\def\ALG@p@state{}\ALG@p@onxnE}%
+\def\ALG@ps@xn@x{\typeout{algdef: Ignoring 'x' after 'xn'.}}%
+\def\ALG@ps@xn@n{\typeout{algdef: Ignoring 'n' after 'xn'.}}%
+\def\ALG@ps@xn@other#1%
+ {%
+ \typeout{algdef: Ignoring 'xn' before '#1'.}%
+ \def\ALG@p@state{}%
+ \def\ALG@p@rec{\let\ALG@p@rec\ALG@p@main\ALG@p@rec#1}%
+ }%
+% STATE : nx
+\def\ALG@ps@nx@C{\def\ALG@p@state{}\ALG@p@onxnC}%
+\def\ALG@ps@nx@E{\def\ALG@p@state{}\ALG@p@onxnE}%
+\def\ALG@ps@nx@x{\typeout{algdef: Ignoring 'x' after 'nx'.}}%
+\def\ALG@ps@nx@n{\typeout{algdef: Ignoring 'n' after 'nx'.}}%
+\def\ALG@ps@nx@other#1%
+ {%
+ \typeout{algdef: Ignoring 'nx' before '#1'.}%
+ \def\ALG@p@state{}%
+ \def\ALG@p@rec{\let\ALG@p@rec\ALG@p@main\ALG@p@rec#1}%
+ }%
+%
+%
+% *** User level block/entitie commands ***
+%
+%
+%
+% algdef{switches}... -- the king of all definitions in the algorithmicx package
+%
+\newcommand\algdef[1]%
+ {%
+ \ALG@p@undef{oldblock}%
+ \ALG@p@undef{start}%
+ \ALG@p@undef{end}%
+ \def\ALG@v@credits{}%
+ \ALG@p@undef{credits}%
+ \ALG@p@undef{indent}%
+ \ALG@p@undef{starttext}%
+ \ALG@p@undef{endtext}%
+ \def\ALG@p@state{}%
+ \let\ALG@p@rec\ALG@p@main%
+ \ALG@p@rec#1]%
+ \ALG@p@newblock%
+ }%
+%
+% a lot of other macros are provided for convenience
+%
+\def\algblock{\algdef{se}}%
+\def\algcblock{\algdef{ce}}%
+\def\algloop{\algdef{sl}}%
+\def\algcloop{\algdef{cl}}%
+\def\algsetblock{\algdef{seLi}}%
+\def\algsetcblock{\algdef{ceLi}}%
+\def\algblockx{\algdef{SxE}}%
+\def\algblockdefx{\algdef{SE}}%
+\def\algcblockx{\algdef{CxE}}%
+\def\algcblockdefx{\algdef{CE}}%
+\def\algsetblockx{\algdef{SxELi}}%
+\def\algsetblockdefx{\algdef{SELi}}%
+\def\algsetcblockx{\algdef{CxELi}}%
+\def\algsetcblockdefx{\algdef{CELi}}%
+\def\algloopdefx{\algdef{Sl}}%
+\def\algcloopx{\algdef{xCl}}%
+\def\algcloopdefx{\algdef{Cl}}%
+% algloopx is not correct, use algloopdefx
+%
+% Text output commands
+%
+\newcommand\algrenewtext[2][]% [block]{entity}
+ {%
+ \ifthenelse{\equal{#2}{}}{}%
+ {%
+ \ifthenelse{\equal{#1}{}}%
+ {%
+ \expandafter\let\csname ALG@t@\ALG@Ld @#2\endcsname\relax%
+ \expandafter\newcommand\csname ALG@t@\ALG@Ld @#2\endcsname%
+ }%
+ {%
+ \expandafter\let\csname ALG@t@\ALG@Ld @#2@\ALG@getblocknumber{#1}\endcsname\relax%
+ \expandafter\newcommand\csname ALG@t@\ALG@Ld @#2@\ALG@getblocknumber{#1}\endcsname%
+ }%
+ }%
+ }%
+%
+\def\ALG@letentitytext#1#2% [block]{entity}
+ {%
+ \ifthenelse{\equal{#2}{}}{}%
+ {%
+ \ifthenelse{\equal{#1}{}}%
+ {%
+ \expandafter\let\csname ALG@t@\ALG@Ld @#2\endcsname%
+ }%
+ {%
+ \expandafter\let\csname ALG@t@\ALG@Ld @#2@\ALG@getblocknumber{#1}\endcsname%
+ }%
+ }%
+ }%
+%
+\newcommand\algnotext[2][]% [block]{entity}
+ {%
+ \ALG@letentitytext{#1}{#2}\ALG@x@notext%
+ }%
+%
+\newcommand\algdefaulttext[2][]% [block]{entity}
+ {%
+ \ALG@letentitytext{#1}{#2}\ALG@x@default%
+ }%
+%
+\def\ALG@notext*{\algnotext}%
+\def\algtext{\@ifnextchar{*}{\ALG@notext}{\algrenewtext}}%
+%
+%
+% *** LANGUAGE SWITCHING ***
+%
+%
+%
+\newcommand\algnewlanguage[1]%
+ {%
+ \@ifundefined{ALG@L@#1}% needs to be created?
+ {}%
+ {%
+ \PackageError{algorithmicx}{Language '#1' already defined!}{}%
+ }%
+ \addtocounter{ALG@Lnr}{1}% increment the language counter
+ \expandafter\edef\csname ALG@L@#1\endcsname{\arabic{ALG@Lnr}}% set the language number
+ \edef\ALG@Ld{\csname ALG@L@#1\endcsname}%
+ \expandafter\let\csname ALG@bl@\ALG@Ld @\endcsname\ALG@bl@% the BIG block
+ \expandafter\let\csname ALG@bl@\ALG@Ld @@\endcsname\ALG@bl@% the BIG block
+ \algdef{SL}[STATE]{State}{0}{}%
+ \expandafter\def\csname ALG@deftext@\ALG@Ld\endcsname{\textbf}%
+ \algnewcommand\algorithmiccomment[1]{\hfill\(\triangleright\) ##1}%
+ \algnewcommand\algorithmicindent{1.5em}%
+ \algnewcommand\alglinenumber[1]{\footnotesize ##1:}%
+ \algnewcommand\ALG@beginalgorithmic\relax% for user overrides
+ \algnewcommand\ALG@endalgorithmic\relax% for user overrides
+ }%
+%
+\newcommand\algsetlanguage[1]%
+ {%
+ \@ifundefined{ALG@L@#1}% needs to be created?
+ {%
+ \PackageError{algorithmicx}{Language '#1' is not yet defined!}{}%
+ }{}%
+ \edef\ALG@L{\csname ALG@L@#1\endcsname}%
+ }%
+%
+\newcommand\algdeflanguage[1]%
+ {%
+ \@ifundefined{ALG@L@#1}% needs to be created?
+ {%
+ \PackageError{algorithmicx}{Language '#1' is not yet defined!}{}%
+ }{}%
+ \edef\ALG@Ld{\csname ALG@L@#1\endcsname}%
+ }%
+%
+\newcommand\alglanguage[1]%
+ {%
+ \algdeflanguage{#1}%
+ \algsetlanguage{#1}%
+ }%
+%
+%
+% *** Defining language dependent stuff ***
+%
+%
+\def\ALG@eatoneparam#1{}%
+\def\ALG@defbasecmd#1#2%
+ {%
+ \edef\ALG@tmp{\expandafter\ALG@eatoneparam\string #2}%
+ \@ifundefined\ALG@tmp{\edef #2{\noexpand\csname ALG@cmd@\noexpand\ALG@L @\ALG@tmp\endcsname}}{}%
+ \expandafter#1\csname ALG@cmd@\ALG@Ld @\ALG@tmp\endcsname%
+ }%
+\newcommand\algnewcommand{\ALG@defbasecmd\newcommand}%
+\newcommand\algrenewcommand{\ALG@defbasecmd\renewcommand}%
+\def\ALG@letcmd{\ALG@defbasecmd\let}%
+\def\ALG@defcmd{\ALG@defbasecmd\def}%
+\def\ALG@edefcmd{\ALG@defbasecmd\edef}%
+%
+%
+% *** OTHERS ***
+%
+%
+\def\BState{\State \algbackskip}%
+\def\Statex{\item[]}% an empty line
+\newcommand\algrenewcomment{\algrenewcommand\algorithmiccomment}%
+\def\Comment{\algorithmiccomment}%
+\def\algref#1#2{\ref{#1}.\ref{#2}}%
+\algnewlanguage{default}%
+\algsetlanguage{default}%
+%
+%
+% *** Line breaks ***
+%
+%
+\newcommand\algbreak% for multiline parameters !!! needs fix
+ {%
+ \item%
+% \hskip\ALG@parindent%!!! not yet implemented
+% \hskip-\algorithmicindent%
+ }%
+%
+\def\ALG@noputindents%
+ {%
+ \hskip\ALG@tlm%
+ }%
+%
+%
+% *** algorithm store / restore ***
+%
+%
+% store
+%
+\ALG@newcondstate{mustrestore}%
+\def\algstore%
+ {%
+ \renewcommand\ALG@beginblock%
+ {%
+ \PackageError{algorithmicx}{The environment must be closed after store!}{}%
+ }%
+ \@ifstar{\ALG@starstore}{\ALG@nostarstore}%
+ }%
+\def\ALG@nostarstore#1% save all infos into #1 and terminate the algorithmic block
+ {%
+ \addtocounter{ALG@storecount}{1}%
+ \expandafter\global\expandafter\let\csname ALG@save@mustrestore@#1\endcsname\ALG@x@mustrestore%
+ \ALG@starstore{#1}%
+ }%
+\def\ALG@starstore#1%
+ {%
+ \@ifundefined{ALG@save@line@#1}{}%
+ {\PackageError{algorithmicx}{This save name '#1' is already used!}{}}%
+ \def\ALG@savename{#1}%
+ \expandafter\xdef\csname ALG@save@totalnr@\ALG@savename\endcsname{\theALG@nested}%
+ \expandafter\xdef\csname ALG@save@line@\ALG@savename\endcsname{\theALG@line}%
+ \expandafter\xdef\csname ALG@save@numberfreq@\ALG@savename\endcsname{\ALG@numberfreq}%
+ \expandafter\xdef\csname ALG@save@rem@\ALG@savename\endcsname{\theALG@rem}%
+ \let\ALG@storerepeat\ALG@store%
+ \ALG@storerepeat%
+ }%
+\def\ALG@store% simply terminate all open blocks
+ {%
+ \ifnum\theALG@nested=0\let\ALG@storerepeat\relax%
+ \else%
+ \expandafter\xdef\csname ALG@save@currentblock@\ALG@savename @\theALG@nested\endcsname%
+ {\csname ALG@currentblock@\theALG@nested\endcsname}%
+ \expandafter\ifx\csname ALG@currentlifetime@\theALG@nested\endcsname\relax%
+ \else%
+ \expandafter\xdef\csname ALG@save@currentlifetime@\ALG@savename @\theALG@nested\endcsname%
+ {\csname ALG@currentlifetime@\theALG@nested\endcsname}%
+ \fi%
+ \expandafter\xdef\csname ALG@save@ind@\ALG@savename @\theALG@nested\endcsname%
+ {\csname ALG@ind@\theALG@nested\endcsname}%
+ \ALG@closebyforce%
+ \fi%
+ \ALG@storerepeat%
+ }%
+%
+% restore
+%
+\def\algrestore%
+ {%
+ \@ifstar{\ALG@starrestore}{\ALG@nostarrestore}%
+ }%
+\def\ALG@starrestore%
+ {%
+ \let\ALG@restorerem\relax%
+ \let\ALG@restorereprem\relax%
+ \ALG@restoremain%
+ }%
+\def\ALG@nostarrestore%
+ {%
+ \let\ALG@restorerem\ALG@restoreremovesave%
+ \let\ALG@restorereprem\ALG@restorerepremovesave%
+ \ALG@restoremain%
+ }%
+\def\ALG@restoreremovesave%
+ {%
+ \expandafter\global\expandafter\let\csname ALG@save@totalnr@\ALG@savename\endcsname\relax%
+ \expandafter\global\expandafter\let\csname ALG@save@line@\ALG@savename\endcsname\relax%
+ \expandafter\global\expandafter\let\csname ALG@save@rem@\ALG@savename\endcsname\relax%
+ \expandafter\global\expandafter\let\csname ALG@save@totalnr@\ALG@savename\endcsname\relax%
+ \expandafter\global\expandafter\let\csname ALG@save@numberfreq@\ALG@savename\endcsname\relax%
+ }%
+\def\ALG@restorerepremovesave%
+ {%
+ \expandafter\global\expandafter\let\csname ALG@save@currentblock@\ALG@savename @\theALG@tmpcounter\endcsname\relax%
+ \expandafter\global\expandafter\let\csname ALG@save@currentlifetime@\ALG@savename @\theALG@tmpcounter\endcsname\relax%
+ \expandafter\global\expandafter\let\csname ALG@save@currentlifetime@\ALG@savename @\theALG@tmpcounter\endcsname\relax%
+ \expandafter\global\expandafter\let\csname ALG@save@ind@\ALG@savename @\theALG@tmpcounter\endcsname\relax%
+ }%
+\def\ALG@restoremain#1% restore all infos from #1 in an open algorithmic block
+ {%
+ \ifnum\theALG@line=0%
+ \else\PackageError{algorithmicx}{Restore might be used only at the beginning of the environment!}{}%
+ \fi%
+ \def\ALG@savename{#1}%
+ \expandafter\ifx\csname ALG@save@totalnr@\ALG@savename\endcsname\relax%
+ \PackageError{algorithmicx}{Save '\ALG@savename'\space not defined!!!}{}%
+ \fi%
+ \@ifundefined{ALG@save@mustrestore@\ALG@savename}{}%
+ {%
+ \addtocounter{ALG@storecount}{-1}%
+ \expandafter\global\expandafter\let\csname ALG@save@mustrestore@\ALG@savename\endcsname\relax%
+ }%
+ \setcounter{ALG@line}{\csname ALG@save@line@\ALG@savename\endcsname}%
+ \edef\ALG@numberfreq{\csname ALG@save@numberfreq@\ALG@savename\endcsname}%
+ \setcounter{ALG@rem}{\csname ALG@save@rem@\ALG@savename\endcsname}%
+ \setcounter{ALG@tmpcounter}{\csname ALG@save@totalnr@\ALG@savename\endcsname}%
+ \setcounter{ALG@nested}{0}%
+ \ALG@restorerem%
+ \let\ALG@restorerepeat\ALG@restore%
+ \ALG@restorerepeat%
+ }%
+\def\ALG@restore%
+ {%
+ \ifnum\theALG@tmpcounter>0%
+ \expandafter\edef\csname ALG@currentblock@\theALG@tmpcounter\endcsname%
+ {\csname ALG@save@currentblock@\ALG@savename @\theALG@tmpcounter\endcsname}%
+ \expandafter\ifx\csname ALG@save@currentlifetime@\ALG@savename @\theALG@tmpcounter\endcsname\relax%
+ \expandafter\let\csname ALG@currentlifetime@\theALG@tmpcounter\endcsname\relax%
+ \else%
+ \expandafter\edef\csname ALG@currentlifetime@\theALG@tmpcounter\endcsname%
+ {\csname ALG@save@currentlifetime@\ALG@savename @\theALG@tmpcounter\endcsname}%
+ \fi%
+ %
+ \ALG@beginblock{\csname ALG@save@ind@\ALG@savename @\theALG@tmpcounter\endcsname}%
+ \ALG@restorereprem%
+ \addtocounter{ALG@tmpcounter}{-1}%
+ \else\let\ALG@restorerepeat\relax%
+ \fi%
+ \ALG@restorerepeat%
+ }%
+\AtEndDocument%
+ {%
+ \ifnum\theALG@storecount>0\relax%
+ \PackageError{algorithmicx}{Some stored algorithms are not restored!}{}%
+ \fi%
+ }%
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/algpseudocode.sty b/inst/rmarkdown/templates/pnas_article/skeleton/algpseudocode.sty
new file mode 100644
index 000000000..fca966ac6
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/algpseudocode.sty
@@ -0,0 +1,92 @@
+% PSEUDOCODE ALGORITHMIC STYLE -- Released 27 APR 2005
+% for LaTeX version 2e
+%
+% Copyright Szasz Janos
+% E-mail szaszjanos@users.sourceforge.net
+% Based on Peter Williams's algorithmic.sty
+%
+\NeedsTeXFormat{LaTeX2e}%
+\ProvidesPackage{algpseudocode}%
+\RequirePackage{ifthen}%
+\RequirePackage{algorithmicx}%
+\typeout{Document Style - pseudocode environments for use with the `algorithmicx' style}%
+%
+\def\ALG@noend{f}%
+\newboolean{ALG@compatible}%
+\setboolean{ALG@compatible}{false}%
+%
+\DeclareOption{noend}{\def\ALG@noend{t}}%
+\DeclareOption{end}{\def\ALG@noend{f}}%
+\DeclareOption{compatible}{\typeout{For compatibility mode use algcompatible.sty!!!}\setboolean{ALG@compatible}{true}}%
+\DeclareOption{noncompatible}{\setboolean{ALG@noncompatible}{false}}%
+\ProcessOptions%
+%
+% *** DECLARATIONS ***
+%
+\algnewlanguage{pseudocode}%
+\alglanguage{pseudocode}%
+%
+% *** KEYWORDS ***
+%
+\algnewcommand\algorithmicend{\textbf{end}}
+\algnewcommand\algorithmicdo{\textbf{do}}
+\algnewcommand\algorithmicwhile{\textbf{while}}
+\algnewcommand\algorithmicfor{\textbf{for}}
+\algnewcommand\algorithmicforall{\textbf{for all}}
+\algnewcommand\algorithmicloop{\textbf{loop}}
+\algnewcommand\algorithmicrepeat{\textbf{repeat}}
+\algnewcommand\algorithmicuntil{\textbf{until}}
+\algnewcommand\algorithmicprocedure{\textbf{procedure}}
+\algnewcommand\algorithmicfunction{\textbf{function}}
+\algnewcommand\algorithmicif{\textbf{if}}
+\algnewcommand\algorithmicthen{\textbf{then}}
+\algnewcommand\algorithmicelse{\textbf{else}}
+\algnewcommand\algorithmicrequire{\textbf{Require:}}
+\algnewcommand\algorithmicensure{\textbf{Ensure:}}
+\algnewcommand\algorithmicreturn{\textbf{return}}
+\algnewcommand\textproc{\textsc}
+%
+% *** DECLARED LOOPS ***
+%
+\algdef{SE}[WHILE]{While}{EndWhile}[1]{\algorithmicwhile\ #1\ \algorithmicdo}{\algorithmicend\ \algorithmicwhile}%
+\algdef{SE}[FOR]{For}{EndFor}[1]{\algorithmicfor\ #1\ \algorithmicdo}{\algorithmicend\ \algorithmicfor}%
+\algdef{S}[FOR]{ForAll}[1]{\algorithmicforall\ #1\ \algorithmicdo}%
+\algdef{SE}[LOOP]{Loop}{EndLoop}{\algorithmicloop}{\algorithmicend\ \algorithmicloop}%
+\algdef{SE}[REPEAT]{Repeat}{Until}{\algorithmicrepeat}[1]{\algorithmicuntil\ #1}%
+\algdef{SE}[IF]{If}{EndIf}[1]{\algorithmicif\ #1\ \algorithmicthen}{\algorithmicend\ \algorithmicif}%
+\algdef{C}[IF]{IF}{ElsIf}[1]{\algorithmicelse\ \algorithmicif\ #1\ \algorithmicthen}%
+\algdef{Ce}[ELSE]{IF}{Else}{EndIf}{\algorithmicelse}%
+\algdef{SE}[PROCEDURE]{Procedure}{EndProcedure}%
+ [2]{\algorithmicprocedure\ \textproc{#1}\ifthenelse{\equal{#2}{}}{}{(#2)}}%
+ {\algorithmicend\ \algorithmicprocedure}%
+\algdef{SE}[FUNCTION]{Function}{EndFunction}%
+ [2]{\algorithmicfunction\ \textproc{#1}\ifthenelse{\equal{#2}{}}{}{(#2)}}%
+ {\algorithmicend\ \algorithmicfunction}%
+%
+\ifthenelse{\equal{\ALG@noend}{t}}%
+ {%
+ \algtext*{EndWhile}%
+ \algtext*{EndFor}%
+ \algtext*{EndLoop}%
+ \algtext*{EndIf}%
+ \algtext*{EndProcedure}%
+ \algtext*{EndFunction}%
+ }{}%
+%
+% *** OTHER DECLARATIONS ***
+%
+\algnewcommand\Require{\item[\algorithmicrequire]}%
+\algnewcommand\Ensure{\item[\algorithmicensure]}%
+\algnewcommand\Return{\algorithmicreturn{} }%
+\algnewcommand\Call[2]{\textproc{#1}\ifthenelse{\equal{#2}{}}{}{(#2)}}%
+%
+%
+%
+\ifthenelse{\boolean{ALG@compatible}}%
+ {%
+ \ifthenelse{\equal{\ALG@noend}{t}}%
+ {\RequirePackage[noend]{algcompatible}}%
+ {\RequirePackage{algcompatible}}%
+ }%
+ {}%
+%
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/frog.png b/inst/rmarkdown/templates/pnas_article/skeleton/frog.png
new file mode 100644
index 000000000..db62d3470
Binary files /dev/null and b/inst/rmarkdown/templates/pnas_article/skeleton/frog.png differ
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/pnas-new.cls b/inst/rmarkdown/templates/pnas_article/skeleton/pnas-new.cls
new file mode 100644
index 000000000..ff9fa84f5
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/pnas-new.cls
@@ -0,0 +1,414 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% pnas-new.cls, v1.2, 2016/02/28
+%
+% This class file enables authors to prepare research
+% articles for submission to PNAS.
+%
+% Please note that whilst this template provides a
+% preview of the typeset manuscript for submission, it
+% will not necessarily be the final publication layout.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either
+% version 1.3 of this license or any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt and
+% version 1.3 or later is part of all distributions
+% of LaTeX version 2005/12/01 or later.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% For use with latex+dvipdfm, pdflatex, xelatex & lualatex
+% For compiling with plain latex, please use latex+dvipdfm
+% to produce the PDF, not dvis -> ps -> pdf nor dvipdf
+%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesClass{pnas-new}[28/02/2015, v1.2]
+\AtEndOfClass{\RequirePackage{microtype}}
+% Option for line numbers
+\newif\if@pnaslineno
+\DeclareOption{lineno}{\@pnaslinenotrue}
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{extarticle}}
+\ProcessOptions*
+\LoadClass{extarticle}
+
+%% Fonts and language
+\RequirePackage[utf8]{inputenc}
+\RequirePackage[english]{babel}
+\RequirePackage{amsmath,amsfonts,amssymb}
+\RequirePackage{lmodern}
+\RequirePackage[scaled]{helvet}
+\RequirePackage[T1]{fontenc}
+\RequirePackage{lettrine} % For dropped capitals
+
+%% For the Significance Statement & footnote on the first page
+\RequirePackage{afterpage}
+\RequirePackage{ifpdf,ifxetex}
+\ifpdf\else
+ \ifxetex\else
+ \def\pgfsysdriver{pgfsys-dvipdfm.def}
+ \pdfpagewidth=\paperwidth
+ \pdfpageheight=\paperheight
+\fi\fi
+\RequirePackage{xcolor}
+\RequirePackage{tikz}
+\RequirePackage[framemethod=tikz]{mdframed}
+
+%% For single column equations and balancing the columns on final page
+\RequirePackage{widetext}
+
+%% Hyperlinking
+\RequirePackage[colorlinks=true, allcolors=blue]{hyperref}
+
+%% Set up main title page fonts
+\newcommand{\headerfont}{\normalfont\sffamily\fontsize{7}{9} \selectfont}
+\newcommand{\footerfont}{\normalfont\sffamily\fontsize{7}{9} \selectfont}
+\newcommand{\titlefont}{\fontfamily{lmss}\bfseries\fontsize{22pt}{24pt}\selectfont}
+\newcommand{\dropcapfont}{\fontfamily{lmss}\bfseries\fontsize{26pt}{28pt}\selectfont}
+\newcommand{\datesfont}{\normalfont\sffamily\fontsize{7}{8}\selectfont}
+\newcommand{\absfont}{\normalfont\sffamily\bfseries\fontsize{8}{11}\selectfont}
+\newcommand{\keywordsfont}{\normalfont\rmfamily\fontsize{7}{10}\selectfont}
+\newcommand{\copyrightfont}{\normalfont\rmfamily\fontsize{6}{8}\selectfont}
+
+%% Set URL link color & font
+\renewcommand\UrlFont{\color{black}\sffamily}
+
+%% Author and affiliation
+\RequirePackage{authblk}
+\setlength{\affilsep}{8.5pt} % 16.5pts between base of author line and base of affil line
+\renewcommand\Authfont{\color{color0}\normalfont\sffamily\bfseries\fontsize{9}{11}\selectfont}
+\renewcommand\Affilfont{\color{color0}\normalfont\sffamily\fontsize{7}{8}\selectfont}
+\makeatletter
+\renewcommand\AB@affilsepx{; \protect\Affilfont}
+\makeatother
+\renewcommand\Authands{, and }
+
+%% Choose template type
+\newcommand*{\templatetype}[1]{%
+ \RequirePackage{#1}}
+
+%% Options for element switching
+\RequirePackage{xifthen}
+\newboolean{shortarticle}
+\newboolean{singlecolumn}
+
+%% For numbering just one line of an equation
+\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}
+
+%% Watermark
+\usepackage[printwatermark]{xwatermark}
+\newboolean{displaywatermark}
+\setboolean{displaywatermark}{true} % Set to false to remove the watermark
+\ifthenelse{\boolean{displaywatermark}}{%
+\newwatermark[allpages,color=gray!20,angle=45,scale=3,xpos=0,ypos=0]{DRAFT}}{}
+
+%% Copyright statement (not used)
+\newboolean{displaycopyright}
+\setboolean{displaycopyright}{false} % Confirmed as not required
+\RequirePackage{textcomp} % For copyright symbol styling
+\newcommand{\copyrightstatement}{\, \textcopyright\, 2015 by The National Academy of Sciences of the USA}
+
+%% Graphics, tables and other formatting
+\RequirePackage{graphicx,xcolor}
+\RequirePackage{colortbl}
+\RequirePackage{booktabs}
+\RequirePackage{algorithm}
+\RequirePackage[noend]{algpseudocode}
+\RequirePackage{changepage}
+\RequirePackage[twoside,%
+ letterpaper,includeheadfoot,%
+ layoutsize={8.125in,10.875in},%
+ layouthoffset=0.1875in,%
+ layoutvoffset=0.0625in,%
+ left=38.5pt,%
+ right=43pt,%
+ top=43pt,% 10pt provided by headsep
+ bottom=32pt,%
+ headheight=0pt,% No Header
+ headsep=10pt,%
+ footskip=25pt]{geometry}
+\RequirePackage[labelfont={bf,sf},%
+ labelsep=period,%
+ figurename=Fig.]{caption}
+\setlength{\columnsep}{13.5pt} % Distance between the two columns of text
+\setlength{\parindent}{12pt} % Paragraph indent
+
+%% Set document color scheme
+\definecolor{black50}{gray}{0.5} % 50% black for hrules
+\definecolor{color0}{RGB}{0,0,0} % Base
+\definecolor{color1}{RGB}{59,90,198} % author email, doi
+\definecolor{color2}{RGB}{16,131,16} %
+% For sig statement box
+\definecolor{pnasbluetext}{RGB}{0,101,165} %
+\definecolor{pnasblueback}{RGB}{205,217,235} %
+%\definecolor{pnasbluetext}{RGB}{0,115,209} % Not used
+%\definecolor{pnasblueback}{RGB}{210,230,247} % Not used
+
+%% Bibliography
+\RequirePackage[numbers,sort&compress]{natbib}
+\setlength{\bibsep}{0.0pt}
+\bibliographystyle{pnas2011}
+\renewcommand{\bibsection}{} % Remove header
+\renewcommand\bibfont{\normalfont\sffamily\fontsize{6}{8}\selectfont} % set font to be sans serif
+
+\makeatletter
+\renewcommand\@biblabel[1]{ #1.} % Remove brackets from label
+\def\tagform@#1{\maketag@@@{\bfseries(\ignorespaces#1\unskip\@@italiccorr)}}
+\renewcommand{\eqref}[1]{\textup{{\normalfont Eq.~(\ref{#1}}\normalfont)}}
+\makeatother
+
+%% Figure caption style
+\DeclareCaptionFormat{pnasformat}{\normalfont\sffamily\fontsize{7}{9}\selectfont#1#2#3}
+\captionsetup{format=pnasformat}
+
+%% Table style
+\RequirePackage{etoolbox}
+\captionsetup[table]{labelfont+={small},textfont+={small,sf,bf},skip=10pt,position=above}
+% booktabs provide nice spacing, but rule widths and distances need fixing
+\setlength{\heavyrulewidth}{0.5pt}
+\setlength{\lightrulewidth}{0.5pt}
+\setlength{\aboverulesep}{1.5pt}
+\setlength{\belowrulesep}{1.5pt}
+\setlength{\belowbottomsep}{10pt}
+\AtBeginEnvironment{tabular}{
+\sffamily\fontsize{7.5}{10}\selectfont
+}
+\newcommand{\addtabletext}[1]{{\setlength{\leftskip}{9pt}\fontsize{7}{9}\selectfont#1}}
+
+%% Equation numbering - use square brackets
+\makeatletter
+\renewcommand\tagform@[1]{\maketag@@@ {[\ignorespaces #1\unskip \@@italiccorr ]}}
+\makeatother
+
+%% Headers and footers
+\RequirePackage{fancyhdr} % custom headers/footers
+\RequirePackage{lastpage} % Number of pages in the document
+\pagestyle{fancy} % Enables the custom headers/footers
+
+%% For the line numbers overlay
+\def\leftlinenos{%
+ \pgfmathtruncatemacro{\leftstartlineno}{2*(\thepage - 1)*62 + 1}%
+ \pgfmathtruncatemacro{\leftendlineno}{(2*(\thepage - 1) + 1)*62}%
+ \foreach \x in {\leftstartlineno,...,\leftendlineno}{\noindent\x\\}%
+}
+\def\rightlinenos{%
+ \pgfmathtruncatemacro{\rightstartlineno}{(2*(\thepage - 1) + 1)*62 + 1}%
+ \pgfmathtruncatemacro{\rightendlineno}{(2*\thepage)*62}%
+ \foreach \x in {\rightstartlineno,...,\rightendlineno}{\noindent\x\\}%
+}
+
+\makeatletter
+\fancypagestyle{firststyle}{
+ \fancyfoot[R]{\footerfont PNAS\hspace{7pt}|\hspace{7pt}\textbf{\today}\hspace{7pt}|\hspace{7pt}vol. XXX\hspace{7pt}|\hspace{7pt}no. XX\hspace{7pt}|\hspace{7pt}\textbf{\thepage\textendash\pageref{LastPage}}}
+ \fancyfoot[L]{\footerfont\@ifundefined{@doi}{}{\@doi}}
+}
+\makeatother
+
+% Headers
+\fancyhead[LE,RO]{}
+\fancyhead[LO,RE]{}
+% Footers
+\lfoot{}%
+\cfoot{}%
+\rfoot{}%
+\makeatletter
+\fancyfoot[LE]{\footerfont\textbf{\thepage}\hspace{7pt}|\hspace{7pt}\@ifundefined{@doi}{}{\@doi}}
+\fancyfoot[RO]{\footerfont PNAS\hspace{7pt}|\hspace{7pt}\textbf{\today}\hspace{7pt}|\hspace{7pt}vol. XXX\hspace{7pt}|\hspace{7pt}no. XX\hspace{7pt}|\hspace{7pt}\textbf{\thepage}}
+\fancyfoot[RE,LO]{\footerfont\@ifundefined{@leadauthor}{}{\@leadauthor}\ifnum \value{authors} > 1\hspace{5pt}\textit{et al.}\fi}
+
+% Use footer routine for line numbers
+\AtBeginDocument{
+ \if@pnaslineno
+ \ifthenelse{\boolean{singlecolumn}}{
+ % use lineno package if singlecolumn
+ \RequirePackage{lineno}
+ \linenumbers
+ }{% use tikz if twocolumn
+ \fancyfoot[C]{\begin{tikzpicture}[remember picture,overlay]
+ \node at([xshift=1.5em,yshift=\dimexpr -0.0625in-53pt] current page.north west)[anchor=north west,text width=3em,font=\rmfamily,align=right] {\leftlinenos};%
+ \node at([xshift=-1.5em,yshift=\dimexpr -0.0625in-53pt] current page.north east)[anchor=north east,text width=3em,font=\rmfamily,align=left] {\rightlinenos};%
+ \end{tikzpicture}}
+ }
+ \fi
+}
+\makeatother
+
+\renewcommand{\headrulewidth}{0pt}% % No header rule
+\renewcommand{\footrulewidth}{0pt}% % No footer rule
+
+%% Section/subsection/paragraph set-up
+\RequirePackage[explicit]{titlesec}
+\renewcommand{\thesubsection}{\Alph{subsection}}
+
+\titleformat{\section}
+ {\large\sffamily\bfseries}
+ {\thesection.}
+ {0.5em}
+ {#1}
+ []
+\titleformat{name=\section,numberless}
+ {\large\sffamily\bfseries}
+ {}
+ {0em}
+ {#1}
+ []
+\titleformat{\subsection}[runin]
+ {\sffamily\bfseries}
+ {\thesubsection.}
+ {0.5em}
+ {#1. }
+ []
+\titleformat{\subsubsection}[runin]
+ {\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}{2pt}
+\titlespacing*{\subsubsection}{0pc}{2ex \@plus2.5pt \@minus1.5pt}{2pt}
+\titlespacing*{\paragraph}{0pc}{1.5ex \@plus2pt \@minus1pt}{12pt}
+
+%% Article meta data additional fields
+\newcommand{\additionalelement}[1]{\def\@additionalelement{#1}}
+\newcommand{\dates}[1]{\def\@dates{#1}}
+\newcommand{\doi}[1]{\def\@doi{#1}}
+\newcommand{\leadauthor}[1]{\def\@leadauthor{#1}}
+\newcommand{\etal}[1]{\def\@etal{#1}}
+\newcommand{\keywords}[1]{\def\@keywords{#1}}
+\newcommand{\authorcontributions}[1]{\def\@authorcontributions{#1}}
+\newcommand{\authordeclaration}[1]{\def\@authordeclaration{#1}}
+\newcommand{\equalauthors}[1]{\def\@equalauthors{#1}}
+\newcommand{\correspondingauthor}[1]{\def\@correspondingauthor{#1}}
+\newcommand{\significancestatement}[1]{\def\@significancestatement{#1}}
+\newcommand{\matmethods}[1]{\def\@matmethods{#1}}
+\newcommand{\acknow}[1]{\def\@acknow{#1}}
+
+%% Dropped capital for first letter of main text
+\newcommand{\dropcap}[1]{\lettrine[lines=2,lraise=0.05,findent=0.1em, nindent=0em]{{\dropcapfont{#1}}}{}}
+
+%% Abstract formatting
+\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}
+
+% Define an environment with abstract content and styling
+\newcommand{\abscontent}{
+\noindent
+{%
+\parbox{\dimexpr\linewidth}{%
+ \vskip3pt%
+ \absfont \theabstract
+}%
+}%
+\vskip10pt%
+\noindent
+{\parbox{\dimexpr\linewidth}{%
+{
+ \keywordsfont \@ifundefined{@keywords}{}{\@keywords}}%
+}}%
+\vskip12pt%
+}
+
+% Option to format abstract differently for certain layouts (not used)
+\newcommand{\abscontentformatted}{
+\abscontent
+}
+
+%% Manual adjustment to line up main content with line numbers
+\newlength\pnas@vertadjust
+\newcommand\verticaladjustment[1]{\setlength{\pnas@vertadjust}{#1}}
+
+%% Custom title page
+\renewcommand{\@maketitle}{%
+{%
+\ifthenelse{\boolean{shortarticle}}
+{\ifthenelse{\boolean{singlecolumn}}{}{
+{\raggedright\baselineskip= 24pt\titlefont \@title\par}%
+\vskip10pt% 21pts between base of title and base of author line
+{\raggedright \@author\par}
+\vskip8pt% 16pts between base of affiliations and base of dates line
+{\raggedright \datesfont \@ifundefined{@dates}{}{\@dates}\par}
+\vskip12pt%
+}}
+{% else
+%
+\vskip10pt%
+{\raggedright\baselineskip= 24pt\titlefont \@title\par}%
+\vskip10pt% 21pts between base of title and base of author line
+{\raggedright \@author\par}
+\vskip8pt% 16pts between base of affiliations and base of dates line
+{\raggedright \datesfont \@ifundefined{@dates}{}{\@dates}\par}
+\vskip12pt
+{%
+\abscontent
+}%
+\vskip25pt%
+}%
+%%%
+\@additionalelement
+}%
+\vskip\pnas@vertadjust
+}%
+
+%% Footnotes set up
+\RequirePackage[flushmargin,ragged]{footmisc}
+\renewcommand*{\footnotelayout}{\normalfont\sffamily\fontsize{6}{8}\selectfont} % set the footnote font
+\renewcommand{\footnoterule}{% Set the footnote hrule style
+ \kern -3pt
+ {\color{black50} \hrule width 72pt height 0.25pt}
+ \kern 2.5pt
+}
+
+%% Set up the acknowledgments field
+\titleclass{\acknow@section}{straight}[\part]
+\newcounter{acknow@section}
+\providecommand*{\toclevel@acknow@section}{0}
+% Format is set for research articles by default
+\titleformat{\acknow@section}[runin]
+ {\sffamily\normalsize\bfseries}
+ {}
+ {0em}
+ {#1.}
+ []
+\titlespacing{\acknow@section}
+ {0pt}
+ {3.25ex plus 1ex minus .2ex}
+ {1.5ex plus .2ex}
+\newcommand{\showacknow}{% Display acknowledgments section
+\@ifundefined{@acknow}{}{\acknow@section{ACKNOWLEDGMENTS}\small\@acknow}
+}
+
+%% Set up the materials&methods field
+\titleclass{\matmethods@section}{straight}[\part]
+\newcounter{matmethods@section}
+\providecommand*{\toclevel@matmethods@section}{0}
+% Format is set for research articles by default
+\titleformat{\matmethods@section}
+ {\sffamily\normalsize\bfseries}
+ {}
+ {0em}
+ {#1}
+ []
+\titlespacing{\matmethods@section}
+ {0pt}
+ {3.25ex plus 1ex minus .2ex}
+ {1.5ex plus .2ex}
+\newcommand{\showmatmethods}{% Display materials&methods section
+\@ifundefined{@matmethods}{}{\matmethods@section{Materials and Methods}{\small\noindent\@matmethods}}
+}
+
+%% Other packages
+\RequirePackage{enumitem} % For reducing bullet list item separation
\ No newline at end of file
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/pnas-sample.bib b/inst/rmarkdown/templates/pnas_article/skeleton/pnas-sample.bib
new file mode 100644
index 000000000..f9a0a6c54
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/pnas-sample.bib
@@ -0,0 +1,29 @@
+@inproceedings{belkin2002using,
+ title={Using manifold stucture for partially labeled classification},
+ author={Belkin, Mikhail and Niyogi, Partha},
+ booktitle={Advances in neural information processing systems},
+ pages={929--936},
+ year={2002}
+}
+
+@article{berard1994embedding,
+ title={Embedding Riemannian manifolds by their heat kernel},
+ author={B{\'e}rard, Pierre and Besson, G{\'e}rard and Gallot, Sylvain},
+ journal={Geometric \& Functional Analysis GAFA},
+ volume={4},
+ number={4},
+ pages={373--398},
+ year={1994},
+ publisher={Springer}
+}
+
+@article{coifman2005geometric,
+ title={Geometric diffusions as a tool for harmonic analysis and structure definition of data: Diffusion maps},
+ author={Coifman, Ronald R and Lafon, Stephane and Lee, Ann B and Maggioni, Mauro and Nadler, Boaz and Warner, Frederick and Zucker, Steven W},
+ journal={Proceedings of the National Academy of Sciences of the United States of America},
+ volume={102},
+ number={21},
+ pages={7426--7431},
+ year={2005},
+ publisher={National Acad Sciences}
+}
\ No newline at end of file
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/pnas.csl b/inst/rmarkdown/templates/pnas_article/skeleton/pnas.csl
new file mode 100644
index 000000000..9c546ae36
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/pnas.csl
@@ -0,0 +1,165 @@
+
+
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/pnasinvited.sty b/inst/rmarkdown/templates/pnas_article/skeleton/pnasinvited.sty
new file mode 100644
index 000000000..01eceae29
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/pnasinvited.sty
@@ -0,0 +1,139 @@
+%%% PNAS Invited Submission style file
+%%% For use with pnas-new.cls
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{pnasinvited}[2016/02/28 v1.2 PNAS Invited Submission style]
+
+%% Set whether the abstract is set into the first column
+\setboolean{shortarticle}{false}
+% true = set into first column
+% false = spans page width
+
+%% Set colors
+\definecolor{color2}{RGB}{200,89,45} % color
+
+%% Set up the author information
+\newsavebox{\authfootinfo}
+\additionalelement{} % Don't use the \additionalelement field (set blank)
+% Author affiliation as footnote
+% Patch the \@author from authblk -- shouldn't display affiliation here
+\patchcmd{\@author}{\\[\affilsep]\AB@affillist}{}{}{}
+
+\appto{\maketitle}{%
+ \savebox{\authfootinfo}{%
+ \begin{minipage}{\textwidth}
+ \footnotesize
+ \vskip4pt\hrule\vskip6pt
+ \AB@affillist\par
+ \@authorcontributions\par
+ \@equalauthors\par
+ \@correspondingauthor\par
+ \@authordeclaration\par
+ \end{minipage}%
+ }
+ \newlength\authfootheight
+ \settoheight{\authfootheight}{\usebox{\authfootinfo}}
+ \addtolength{\authfootheight}{\baselineskip}
+ \begin{authfoot}
+ \usebox{\authfootinfo}
+ \end{authfoot}
+ \afterpage{%
+ \begin{authfoot}
+ \vskip\dimexpr(\authfootheight+\baselineskip)
+ \end{authfoot}
+ }
+}
+
+% Author information in a box at the bottom as two floats.
+\RequirePackage{float}
+\floatstyle{plain}
+\newfloat{authfoot}{b!}{auf}
+
+%% Set sans as default font
+\renewcommand{\familydefault}{\sfdefault}
+\renewcommand{\keywordsfont}{\sffamily}
+
+% Add line after abstract
+\appto{\abscontent}{\par\textcolor{color2}{\hrulefill}}
+
+% Add colour to the title
+\appto{\titlefont}{\color{color2}}
+
+% ...and section headings
+\titleformat{\section}
+ {\large\sffamily\bfseries\color{color2}}
+ {\thesection.}
+ {0.5em}
+ {#1}
+ []
+\titleformat{name=\section,numberless}
+ {\large\sffamily\bfseries\color{color2}}
+ {}
+ {0em}
+ {#1}
+ []
+\titleformat{\subsection}[runin]
+ {\sffamily\bfseries\itshape}
+ {\thesubsection.}
+ {0.5em}
+ {#1. }
+ []
+% Other section headings left unchanged.
+
+%% No dropcaps. So re-define to do nothing in case user switches
+% from the research article template
+\renewcommand{\dropcap}[1]{\noindent #1}
+
+%% Tweaks to footer
+\fancypagestyle{firststyle}{
+ \fancyfoot[R]{\footerfont PNAS\hspace{7pt}|\hspace{7pt}\textbf{\today}\hspace{7pt}|\hspace{7pt}vol. XXX\hspace{7pt}|\hspace{7pt}no. XX\hspace{7pt}|\hspace{7pt}\textbf{\thepage\space of\space\pageref{LastPage}}}
+ \fancyfoot[L]{\footerfont\@doi}
+}
+
+\fancyfoot[LE]{\footerfont\textbf{\thepage\space of\space\pageref{LastPage}}\hspace{7pt}|\hspace{7pt}\@doi}
+
+%% Make the bibliography number labels bold
+\renewcommand\@biblabel[1]{\textbf{#1}}
+
+%% Adjust the style of the Materials & Methods section
+\titleformat{\matmethods@section}
+ {\large\sffamily\bfseries\color{color2}}
+ {}
+ {0em}
+ {#1}
+ []
+\titlespacing{\matmethods@section}
+ {0pt}
+ {3.25ex plus 1ex minus .2ex}
+ {1.5ex plus .2ex}
+\renewcommand{\showmatmethods}{% Display materials&methods section
+\@ifundefined{@matmethods}{}{\matmethods@section{Materials and Methods}{\noindent\@matmethods}}
+}
+
+%% Adjust the style of the acknowledgments section
+\titleformat{\acknow@section}
+ {\large\sffamily\bfseries\color{color2}}
+ {}
+ {0em}
+ {#1}
+ []
+\titlespacing{\acknow@section}
+ {0pt}
+ {3.25ex plus 1ex minus .2ex}
+ {1.5ex plus .2ex}
+\renewcommand{\showacknow}{% Display acknowledgments section
+\@ifundefined{@acknow}{}{\acknow@section{Acknowledgments}\noindent\@acknow}
+}
+
+%% Break at end of article (before references)
+% The blank line before the strip command ensures there is nothing placed
+% directly before the break (which can cause formatting issues).
+\newcommand{\pnasbreak}{
+
+\begin{strip}
+\vskip-5pt
+\hrule
+\vskip-6pt
+\end{strip}
+}
+
+\endinput
\ No newline at end of file
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/pnasmathematics.sty b/inst/rmarkdown/templates/pnas_article/skeleton/pnasmathematics.sty
new file mode 100644
index 000000000..3cc54c518
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/pnasmathematics.sty
@@ -0,0 +1,48 @@
+%%% PNAS one column mathematics article style file
+%%% For use with pnas-new.cls
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{pnasmathematics}[2016/02/28 v1.2 PNAS one column mathematics article style]
+
+%% Set whether the abstract is set into the first column
+\setboolean{shortarticle}{false}
+% true = set into first column
+% false = spans page width
+
+%% Set to single column style
+\onecolumn
+\setboolean{singlecolumn}{true}
+
+%% Set colors
+\definecolor{color2}{RGB}{130,0,0} % color
+
+%% Set up the first page footnote/fact box here
+\RequirePackage{float}
+\floatstyle{plain}
+\newfloat{sigstatement}{b!}{sst}
+
+\additionalelement{%
+\begin{sigstatement}
+\sffamily
+\mdfdefinestyle{pnassigstyle}{linewidth=0.7pt,backgroundcolor=pnasblueback,linecolor=pnasbluetext,fontcolor=pnasbluetext,innertopmargin=6pt,innerrightmargin=6pt,innerbottommargin=6pt,innerleftmargin=6pt}
+\@ifundefined{@significancestatement}{}{%
+ \begin{mdframed}[style=pnassigstyle]%
+ \section*{Significance Statement}%
+ \@significancestatement
+ \end{mdframed}}
+% \medskip
+\scriptsize
+\@ifundefined{@authorcontributions}{}{\@authorcontributions}
+\vskip5pt%
+\@ifundefined{@authordeclaration}{}{\@authordeclaration}
+\vskip5pt%
+\@ifundefined{@equalauthors}{}{\@equalauthors}
+\vskip5pt%
+\@ifundefined{@correspondingauthor}{}{\@correspondingauthor}
+\end{sigstatement}
+}
+
+%% No additional elements nor pnasbreak required
+%\additionalelement{}
+\def\pnasbreak{}
+
+\endinput
\ No newline at end of file
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/pnasresearcharticle.sty b/inst/rmarkdown/templates/pnas_article/skeleton/pnasresearcharticle.sty
new file mode 100644
index 000000000..a86d288c4
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/pnasresearcharticle.sty
@@ -0,0 +1,50 @@
+%%% PNAS two column research article style file
+%%% For use with pnas-new.cls
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{pnasresearcharticle}[2016/02/28 v1.2 PNAS two column research article style]
+
+%% Set whether the abstract is set into the first column
+\setboolean{shortarticle}{true}
+% true = set into first column
+% false = spans page width
+
+%% Set colors
+\definecolor{color2}{RGB}{130,0,0} % color
+
+%% Set up the first page footnote/fact box here
+\RequirePackage{float}
+\floatstyle{plain}
+\newfloat{sigstatement}{b!}{sst}
+
+\additionalelement{%
+\afterpage{\begin{sigstatement}
+\sffamily
+\mdfdefinestyle{pnassigstyle}{linewidth=0.7pt,backgroundcolor=pnasblueback,linecolor=pnasbluetext,fontcolor=pnasbluetext,innertopmargin=6pt,innerrightmargin=6pt,innerbottommargin=6pt,innerleftmargin=6pt}
+\@ifundefined{@significancestatement}{}{%
+ \begin{mdframed}[style=pnassigstyle]%
+ \section*{Significance Statement}%
+ \@significancestatement
+ \end{mdframed}}
+% \medskip
+\scriptsize
+\@ifundefined{@authorcontributions}{}{\@authorcontributions}
+\vskip5pt%
+\@ifundefined{@authordeclaration}{}{\@authordeclaration}
+\vskip5pt%
+\@ifundefined{@equalauthors}{}{\@equalauthors}
+\vskip5pt%
+\@ifundefined{@correspondingauthor}{}{\@correspondingauthor}
+\end{sigstatement}}
+}
+
+%% Break at end of article (before references)
+% The blank line before the strip command ensures there is nothing placed
+% directly before the break (which can cause formatting issues).
+\newcommand{\pnasbreak}{
+
+\begin{strip}
+\vskip-11pt
+\end{strip}
+}
+
+\endinput
\ No newline at end of file
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/pnas_article/skeleton/skeleton.Rmd
new file mode 100755
index 000000000..13a2290db
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/skeleton.Rmd
@@ -0,0 +1,275 @@
+---
+title: Template for preparing your research report submission to PNAS using RMarkdown
+
+# Use letters for affiliations, numbers to show equal authorship (if applicable) and to indicate the corresponding author
+author:
+ - name: Alice Anonymous
+ affiliation: a,1,2
+ - name: Bob Security
+ affiliation: a,b
+address:
+ - code: a
+ address: Some Institute of Technology, Department, Street, City, State, Zip
+ - code: b
+ address: Another University Department, Street, City, State, Zip
+
+corresponding_author:
+ - code: 2
+ text: "To whom correspondence should be addressed. E-mail: bob@email.com"
+
+## Remove this if not required
+equal_authors:
+ - code: 1
+ text: "A.O.(Author One) and A.T. (Author Two) contributed equally to this work (remove if not applicable)."
+
+
+author_contributions: |
+ Please provide details of author contributions here.
+
+## Remove this if not required
+conflict_of_interest: |
+ Please declare any conflict of interest here.
+
+abstract: |
+ Please provide an abstract of no more than 250 words in a single paragraph. Abstracts should explain to the general reader the major contributions of the article. References in the abstract must be cited in full within the abstract itself and cited in the text.
+
+
+significance: |
+ Authors must submit a 120-word maximum statement about the significance of their research paper written at a level understandable to an undergraduate educated scientist outside their field of speciality. The primary goal of the Significance Statement is to explain the relevance of the work in broad context to a broad readership. The Significance Statement appears in the paper itself and is required for all research papers.
+
+acknowledgements: |
+ Please include your acknowledgments here, set in a single paragraph. Please do not include any acknowledgments in the Supporting Information, or anywhere else in the manuscript.
+
+keywords:
+ - one
+ - two
+ - optional
+ - optional
+ - optional
+
+## must be one of: pnasresearcharticle (usual two-column layout), pnasmathematics (one column layout), or pnasinvited (invited submissions only)
+pnas_type: pnasresearcharticle
+
+bibliography: pnas-sample.bib
+csl: pnas.csl
+
+output: rticles::pnas_article
+---
+
+
+This PNAS journal template is provided to help you write your work in the
+correct journal format. Instructions for use are provided below.
+
+Note: please start your introduction without including the word
+“Introduction” as a section heading (except for math articles in the
+Physical Sciences section); this heading is implied in the first
+paragraphs.
+
+Guide to using this template {.unnumbered}
+========================================
+
+Please note that whilst this template provides a preview of the typeset
+manuscript for submission, to help in this preparation, it will not
+necessarily be the final publication layout. For more detailed
+information please see the [PNAS Information for
+Authors](http://www.pnas.org/site/authors/format.xhtml).
+
+
+Author Affiliations {#author-affiliations .unnumbered}
+-------------------
+
+Include department, institution, and complete address, with the
+ZIP/postal code, for each author. Use lower case letters to match
+authors with institutions, as shown in the example. Authors with an
+ORCID ID may supply this information at submission.
+
+Submitting Manuscripts {#submitting-manuscripts .unnumbered}
+----------------------
+
+All authors must submit their articles at
+[PNAScentral](http://www.pnascentral.org/cgi-bin/main.plex). If you are
+using Overleaf to write your article, you can use the “Submit to PNAS”
+option in the top bar of the editor window.
+
+Format {#format .unnumbered}
+------
+
+Many authors find it useful to organize their manuscripts with the
+following order of sections; Title, Author Affiliation, Keywords,
+Abstract, Significance Statement, Results, Discussion, Materials and
+methods, Acknowledgments, and References. Other orders and headings are
+permitted.
+
+Manuscript Length {#manuscript-length .unnumbered}
+-----------------
+
+PNAS generally uses a two-column format averaging 67 characters,
+including spaces, per line. The maximum length of a Direct Submission
+research article is six pages and a PNAS PLUS research article is ten
+pages including all text, spaces, and the number of characters displaced
+by figures, tables, and equations. When submitting tables, figures,
+and/or equations in addition to text, keep the text for your manuscript
+under 39,000 characters (including spaces) for Direct Submissions and
+72,000 characters (including spaces) for PNAS PLUS.
+
+References {#references .unnumbered}
+----------
+
+References should be cited in numerical order as they appear in text;
+this will be done automatically via bibtex, e.g. @belkin2002using and
+@berard1994embedding [@coifman2005geometric]. All references, including
+for the SI, should be included in the main manuscript file. References
+appearing in both sections should not be duplicated. SI references
+included in tables should be included with the main reference section.
+
+Data Archival {#data-archival .unnumbered}
+-------------
+
+PNAS must be able to archive the data essential to a published article.
+Where such archiving is not possible, deposition of data in public
+databases, such as GenBank, ArrayExpress, Protein Data Bank, Unidata,
+and others outlined in the Information for Authors, is acceptable.
+
+
+
+Language-Editing Services {#language-editing-services .unnumbered}
+-------------------------
+
+Prior to submission, authors who believe their manuscripts would benefit
+from professional editing are encouraged to use a language-editing
+service (see list at www.pnas.org/site/authors/language-editing.xhtml).
+PNAS does not take responsibility for or endorse these services, and
+their use has no bearing on acceptance of a manuscript for publication.
+
+
+
+Digital Figures {#sec:figures .unnumbered}
+---------------
+
+Only TIFF, EPS, and high-resolution PDF for Mac or PC are allowed for
+figures that will appear in the main text, and images must be final
+size. Authors may submit U3D or PRC files for 3D images; these must be
+accompanied by 2D representations in TIFF, EPS, or high-resolution PDF
+format. Color images must be in RGB (red, green, blue) mode. Include the
+font files for any text.
+
+Figures and Tables should be labelled and referenced in the standard way
+using the `\label{}` and `\ref{}` commands.
+
+Figure \[fig:frog\] shows an example of how to insert a column-wide
+figure. To insert a figure wider than one column, please use the
+`\begin{figure*}...\end{figure*}` environment. Figures wider than one
+column should be sized to 11.4 cm or 17.8 cm wide.
+
+Single column equations {#single-column-equations .unnumbered}
+-----------------------
+
+Authors may use 1- or 2-column equations in their article, according to
+their preference.
+
+To allow an equation to span both columns, options are to use the
+`\begin{figure*}...\end{figure*}` environment mentioned above for
+figures, or to use the `\begin{widetext}...\end{widetext}` environment
+as shown in equation \[eqn:example\] below.
+
+Please note that this option may run into problems with floats and
+footnotes, as mentioned in the [cuted package
+documentation](http://texdoc.net/pkg/cuted). In the case of problems
+with footnotes, it may be possible to correct the situation using
+commands `\footnotemark` and `\footnotetext`.
+
+$$\begin{aligned}
+(x+y)^3&=(x+y)(x+y)^2\\
+ &=(x+y)(x^2+2xy+y^2) \label{eqn:example} \\
+ &=x^3+3x^2y+3xy^3+x^3.
+\end{aligned}$$
+
+
+
+
+
+Supporting Information (SI) {#supporting-information-si .unnumbered}
+---------------------------
+
+
+The main text of the paper must stand on its own without the SI. Refer
+to SI in the manuscript at an appropriate point in the text. Number
+supporting figures and tables starting with S1, S2, etc. Authors are
+limited to no more than 10 SI files, not including movie files. Authors
+who place detailed materials and methods in SI must provide sufficient
+detail in the main text methods to enable a reader to follow the logic
+of the procedures and results and also must reference the online
+methods. If a paper is fundamentally a study of a new method or
+technique, then the methods must be described completely in the main
+text. Because PNAS edits SI and composes it into a single PDF, authors
+must provide the following file formats only.
+
+### SI Text {#si-text .unnumbered}
+
+Supply Word, RTF, or LaTeX files (LaTeX files must be accompanied by a
+PDF with the same file name for visual reference).
+
+### SI Figures {#si-figures .unnumbered}
+
+Provide a brief legend for each supporting figure after the supporting
+text. Provide figure images in TIFF, EPS, high-resolution PDF, JPEG, or
+GIF format; figures may not be embedded in manuscript text. When saving
+TIFF files, use only LZW compression; do not use JPEG compression. Do
+not save figure numbers, legends, or author names as part of the image.
+Composite figures must be pre-assembled.
+
+### 3D Figures {#d-figures .unnumbered}
+
+Supply a composable U3D or PRC file so that it may be edited and
+composed. Authors may submit a PDF file but please note it will be
+published in raw format and will not be edited or composed.
+
+### SI Tables {#si-tables .unnumbered}
+
+Supply Word, RTF, or LaTeX files (LaTeX files must be accompanied by a
+PDF with the same file name for visual reference); include only one
+table per file. Do not use tabs or spaces to separate columns in Word
+tables.
+
+### SI Datasets {#si-datasets .unnumbered}
+
+Supply Excel (.xls), RTF, or PDF files. This file type will be published
+in raw format and will not be edited or composed.
+
+### SI Movies {#si-movies .unnumbered}
+
+Supply Audio Video Interleave (avi), Quicktime (mov), Windows Media
+(wmv), animated GIF (gif), or MPEG files and submit a brief legend for
+each movie in a Word or RTF file. All movies should be submitted at the
+desired reproduction size and length. Movies should be no more than 10
+MB in size.
+
+### Still images {#still-images .unnumbered}
+
+Authors must provide a still image from each video file. Supply TIFF,
+EPS, high-resolution PDF, JPEG, or GIF files.
+
+### Appendices {#appendices .unnumbered}
+
+PNAS prefers that authors submit individual source files to ensure
+readability. If this is not possible, supply a single PDF file that
+contains all of the SI associated with the paper. This file type will be
+published in raw format and will not be edited or composed.
+
+
+
+\showmatmethods
+\showacknow
+\pnasbreak
diff --git a/inst/rmarkdown/templates/pnas_article/skeleton/widetext.sty b/inst/rmarkdown/templates/pnas_article/skeleton/widetext.sty
new file mode 100644
index 000000000..a8f805e98
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/skeleton/widetext.sty
@@ -0,0 +1,86 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{widetext}
+
+%% Mimics the widetext environment of revtex4 for any other class package
+%% Eg: article.cls
+%%
+%% Compiled by: Anjishnu Sarkar
+%%
+%% Advantages:
+%% *) Supports float (eg: figure) in two column format (Advantage over
+%% multicol package)
+%% *) One and twocolumn exist on the same page
+%% *) Flow of text shown via rule
+%% *) Equal height of text when in two column format
+%%
+%% Acknowledgment(s):
+%% 1. Instead of re-inventing the wheel, two packages (flushend, cuted) of
+%% the sttools bundle are used. The sttools bundle is available from CTAN.
+%% Lisence of these packages rests with their corresponding author.
+%% Any bug/problem with flushend and cuted should be forwarded to their
+%% corresponding package authors.
+%% 2. The idea of the rule came from the following latex community website
+%% http://www.latex-community.org/forum/viewtopic.php?f=5&t=2770
+%%
+%% This package just defines the widetext environment and the rules.
+%%
+%% Usage:
+%% \documentclass[a4paper,12pt,twocolumn]{article}
+%% \usepackage{widetext}
+%%
+%% \begin{document}
+%%
+%% Some text in twocolumn
+%%
+%% \begin{widetext}
+%% Text in onecolumn format.
+%% \end{widetext}
+%%
+%% Some more text in twocolumn
+%%
+%% \end{document}
+%%%%%%%%%%%%%%%%%%%%
+
+%% Package required for equal height while in 2 columns format
+\IfFileExists{flushend.sty}
+ {\RequirePackage{flushend}}
+ {\typeout{}
+ \typeout{Package widetext error: Install the flushend package which is
+ a part of sttools bundle. Available from CTAN.}
+ \typeout{}
+ \stop
+ }
+
+%% Package required for onecolumn and twocolumn to exist on the same page.
+%% and also required for widetext environment.
+\IfFileExists{cuted.sty}
+ {\RequirePackage{cuted}}
+ {\typeout{}
+ \typeout{Package widetext error: Install the cuted package which is
+ a part of sttools bundle. Available from CTAN.}
+ \typeout{}
+ \stop
+ }
+
+
+\newlength\@parindent
+\setlength\@parindent{\parindent}
+
+\if@twocolumn
+ \newenvironment{widetext}
+ {%
+ \begin{strip}
+ \rule{\dimexpr(0.5\textwidth-0.5\columnsep-0.4pt)}{0.4pt}%
+ \rule{0.4pt}{6pt}
+ \par %\vspace{6pt}
+ \parindent \@parindent
+ }%
+ {%
+ \par
+ \hfill\rule[-6pt]{0.4pt}{6.4pt}%
+ \rule{\dimexpr(0.5\textwidth-0.5\columnsep-1pt)}{0.4pt}
+ \end{strip}
+ }
+\else
+ \newenvironment{widetext}{}{}
+\fi
\ No newline at end of file
diff --git a/inst/rmarkdown/templates/pnas_article/template.yaml b/inst/rmarkdown/templates/pnas_article/template.yaml
new file mode 100644
index 000000000..1775ed17a
--- /dev/null
+++ b/inst/rmarkdown/templates/pnas_article/template.yaml
@@ -0,0 +1,5 @@
+name: PNAS Journal Article
+description: >
+ Template for creating an article for submission to P journal
+create_dir: true
+
diff --git a/man/pnas_article.Rd b/man/pnas_article.Rd
new file mode 100644
index 000000000..7104c25d2
--- /dev/null
+++ b/man/pnas_article.Rd
@@ -0,0 +1,27 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/pnas_article.R
+\name{pnas_article}
+\alias{pnas_article}
+\title{PNAS journal format.}
+\usage{
+pnas_article(...)
+}
+\arguments{
+\item{...}{Additional arguments to \code{rmarkdown::pdf_document}}
+}
+\value{
+R Markdown output format to pass to
+ \code{\link[rmarkdown:render]{render}}
+}
+\description{
+Format for creating submissions to PNAS journals.
+}
+\examples{
+
+\dontrun{
+library(rmarkdown)
+draft("MyArticle.Rmd", template = "pnas_article", package = "rticles")
+}
+
+}
+
diff --git a/tests/testthat/test_formats.R b/tests/testthat/test_formats.R
index 3f11d4317..af57bb934 100644
--- a/tests/testthat/test_formats.R
+++ b/tests/testthat/test_formats.R
@@ -44,7 +44,7 @@ test_format("elsevier_article")
test_format("jss_article")
test_format("rjournal_article", file_check = FALSE)
test_format("acs_article", os_skip = "windows")
-
+test_format("pnas_article")