---
title: A Template for Two or One-Column Vignettes

# Use letters for affiliations
author:
  - name: First Author
    affiliation: a
  - name: Second Author
    affiliation: a,b
address:
  - code: a
    address: Institute of Smoke and Magic, University of Sometown, Sometown, XY, 12345
  - code: b
    address: Department of Neat Tricks, Whereever State University, Someplace, MC, 67890
    
# Optional: line of arbitrary text with additional information.
# Could be used, for example, to mention the bibliographic info in a post-print.
# If not specified, defaults to "This version was compiled on \today"
#date_subtitle: Published in *Journal of Statistical Software*, 2018

# For footer text  TODO(fold into template, allow free form two-authors)
lead_author_surname: Author and Author

# Place eg a DOI URL or CRAN Package URL here
doi_footer: "https://cran.r-project.org/package=YourPackage"

# Abstract
abstract: |
  Your abstract will be typeset here, and used by default a visually distinctive font.
  An abstract should explain to the general reader the major contributions of the article. 

# Optional: Acknowledgements
acknowledgements: |
  This template package builds upon, and extends, the work of the excellent
  [rticles](https://cran.r-project.org/package=rticles) package, and both packages rely on the
  [PNAS LaTeX](http://www.pnas.org/site/authors/latex.xhtml) macros. Both these sources are
  gratefully acknowledged as this work would not have been possible without them.  Our extensions
  are under the same respective licensing term
  ([GPL-3](https://www.gnu.org/licenses/gpl-3.0.en.html) and
  [LPPL (>= 1.3)](https://www.latex-project.org/lppl/)).

# Optional: One or more keywords
keywords:
  - one
  - two
  - optional
  - keywords
  - here

# Paper size for the document, values of letter and a4
papersize: letter

# Font size of the document, values of 9pt (default), 10pt, 11pt and 12pt
fontsize: 9pt

# Optional: Force one-column layout, default is two-column
#one_column: true

# Optional: Enables lineno mode, but only if one_column mode is also true
#lineno: true

# Optional: Enable one-sided layout, default is two-sided
#one_sided: true

# Optional: Enable section numbering, default is unnumbered
#numbersections: true

# Optional: Specify the depth of section number, default is 5
#secnumdepth: 5

# Optional: Skip inserting final break between acknowledgements, default is false
skip_final_break: true

# Optional: Bibliography 
bibliography: pinp

# Optional: Enable a 'Draft' watermark on the document
#watermark: true

# Customize footer, eg by referencing the vignette
footer_contents: "YourPackage Vignette"

# Produce a pinp document
output: pinp::pinp

# Required: Vignette metadata for inclusion in a package.
vignette: >
  %\VignetteIndexEntry{YourPackage-vignetteentry}
  %\VignetteKeywords{YourPackage, r, anotherkeyword}
  %\VignettePackage{YourPackage}
  %\VignetteEngine{knitr::rmarkdown}
---

## Introduction 

This *pinp is not PNAS* template started when the introduction to
[Rcpp](http://dirk.eddelbuettel.com/code/rcpp.html) by \cite{PeerJ:Rcpp} 
was converted into this updated
[Rcpp Introduction](https://eddelbuettel.github.io/pinp/Rcpp-introduction.pdf)
vignette.  It is based on the
[pnas_article](https://github.com/rstudio/rticles/tree/master/inst/rmarkdown/templates/pnas_article)
template of the wonderful [rticles](https://cran.r-project.org/package=rticles) package by
\cite{CRAN:rticles}. The conversion from markdown to latex is facilitated by
[rmarkdown](https://cran.r-project.org/package=rmarkdown)
\citep{CRAN:rmarkdown} and [knitr](https://cran.r-project.org/package=knitr)
\citep{CRAN:knitr}. The underlying LaTeX macros are from
[pnas.org](http://www.pnas.org/site/authors/latex.xhtml).

The remainder of the document carries over from the corresponding
[pnas_article](https://github.com/rstudio/rticles/tree/master/inst/rmarkdown/templates/pnas_article)
template document. but has been edited and updated to our use case.  A
few specific tips follow.  In general, for fine-tuning some knowledge
of LaTeX is helpful.



## Author Affiliations 

Per common academic best practice, you can include your 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.

## Document Options

We support several options via the YAML header

- Setting a DOI or URL footer, for example for the CRAN package URL,
  which is placed in the bottom-left footer of the title page and even pages;
- Setting a footer label, for example _YourPackage Vignette_ stating
  your package, which is placed in the bottom-right footer on odd
  pages;
- Setting a free-form author field used on the inside footer;
- Optional _Draft_ watermark to be added to each page;
- Line of custom text in subtitle (`date_subtitle`) suitable to give publication
info of the draft, e.g. journal name in a post-print;
- Document date that appears in the footer can be specified manually using
`document_date`.



## References 

Here we differ from PNAS and suggest natbib. References will appear in
author-year form. Use `\citet{}`, `\citep{}`, etc as usual.

We default to the `jss.bst` style. To switch to a different bibliography
style, please use `biblio-style: style` in the YAML header.


## Inline R Code 

The PNAS sample included a fixed PNG image here, but this document prefers
to show the results and embedding of _R_ code. 

```{r figex, fig.width=3, fig.height=3, cache=TRUE, echo=TRUE, fig.cap="Narrow ggplot2 figure"}
library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
    geom_point(size=3, aes(colour=factor(cyl))) +
    theme(legend.position="none")
```

Here we use a standard knitr bloc with explicit options for

- figure width and height (`fig.width`, `fig.height`), both set to three inches;
- whether the code is shown (`echo=TRUE`); and
- the caption (`fig.cap`) as shown above.


## Digital Figures 

Markdown, Pandoc and LaTeX support `.eps` and `.pdf` files.

Figures and Tables should be labelled and referenced in the standard way
using the `\label{}` and `\ref{}` commands.

The R examples above show how to insert a column-wide
figure. To insert a figure wider than one column, please use the
`\begin{figure*}...\end{figure*}` environment. 

One (roundabout) way of doing this is to _not_ actually plot a figure, but to
save it in a file as the following segment shows:

```{r densityPlot, echo=TRUE}
library(ggplot2)
p <- ggplot(data = midwest,
            mapping = aes(x = area,
                          fill = state,
                          color = state)) +
    geom_density(alpha = 0.3)
## save to file
suppressMessages(ggsave("densities.pdf", p))
```

This file is then included via standard LaTeX commands.

\begin{figure*}
  \begin{center}
    \includegraphics[width=0.66\textwidth, height=3.5in]{densities} 
  \end{center}
  \caption{Wide ggplot2 figure}\label{fig}
\end{figure*}


## Typeset Code (But Do Not Run It) 

We can also just show code.

```r
xx <- faithful[,"eruptions"]
fit <- density(xx)
plot(fit)
```

This simply used a pandoc bloc started and ended by three backticks,
with `r` as the language choice.  Similarly, _many_ other languages
can be typeset directly simply by relying on pandoc.


## Single column equations 

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. The `\begin{widetext}...\end{widetext}` environment as shown
in equation \ref{eqn:example} below is deprecated, but \LaTeX commands
`\onecolumn` and `\twocolumn` work fine.

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{equation}
  \begin{aligned}
(x+y)^3&=(x+y)(x+y)^2\\
       &=(x+y)(x^2+2xy+y^2) \\
       &=x^3+3x^2y+3xy^3+x^3. 
       \label{eqn:example} 
  \end{aligned}
\end{equation}


<!-- pandoc writes all tables using longtable, which fails in 2-column mode

  Species                    CBS     CV     G3
  ----------------------- ------ ------ ------
  1\. Acetaldehyde           0.0    0.0    0.0
  2\. Vinyl alcohol          9.1    9.6   13.5
  3\. Hydroxyethylidene     50.8   51.2   54.0

  : Comparison of the fitted potential energy surfaces and ab initio
  benchmark electronic energy calculations

-->

