Template for Oxford University Press papers

knitr::opts_chunk$set(
  echo = FALSE, # By default, hide code; set to TRUE to see code
  fig.pos = 'th', # Places figures at top or here
  out.width = '100%', dpi = 300, # Figure resolution and size
  fig.env="figure"
) # Latex figure environment

options(knitr.table.format = "latex") # For kable tables to write LaTeX table directly

Introduction

This template is based on the generic OUP authoring template available on CTAN under oup-authoring-template. The CTAN template includes LaTeX documentation and a sample LaTeX document that provide far more details regarding the full functionality of the format. Here, only the basic functioning of the Rmarkdown adaptation of the format is demonstrated.

A subsection

A numbered list:

1) First point 2) Second point - Subpoint

A bullet list:

Notes

Literature citations

By default, citations are handled by natbib using a numeric citation format. To use name-date citations, sets namedate: TRUE in the YAML header.

Here are two sample references:

The bibliography will appear at the end of the document.

Though not normally available in the OUP LaTeX format, CSL style files can also be used with the Rmarkdown adaptation by setting in the YAML header citation_package: "default" and defining the csl element to be the path towards the style file.

Equations

An equation without a label for cross-referencing:

$$ E=mc^2 $$

An inline equation: $y=ax+b$

An equation with a label for cross-referencing:

\begin{equation}\label{eq:eq1} \int^{r_2}_0 F(r,\varphi){\rm d}r\,{\rm d}\varphi = 1 \end{equation}

This equation can be referenced as follows: Eq. \ref{eq:eq1}

Inserting R figures

The code below creates a figure. The code is included in the output because echo=TRUE.

plot(1:10,main="Some data",xlab="Distance (cm)",
     ylab="Time (hours)")

You can reference this figure as follows: Fig. \ref{fig:fig1}.

Figures spanning two-columns

Figures can span two columns be setting fig.env="figure*".

plot(1:5,pch=19,main="Some wide data",
     xlab="Distance (cm)",ylab="Time (hours)")

Reference to second figure: Fig. \ref{fig:fig2}

Tables

Generate a table using xtable

df = data.frame(ID=1:3,code=letters[1:3])

# Creates tables that follow OUP guidelines 
# using xtable
library(xtable) 
print(xtable(df,caption="This is a xtable table.",
             label="tab:tab1"),
      comment=FALSE,caption.placement="top")

You can reference this table as follows: Table \ref{tab:tab1}.

Generate a table using kable

df = data.frame(ID=1:3,code=letters[1:3])

# kable can alse be used for creating tables
knitr::kable(df,caption="This is a kable table.",
             booktabs=TRUE,label="tab2")

You can reference this table as follows: Table \ref{tab:tab2}.

Table spanning two columns

Tables can span two columns be setting table.envir = "table*" in knitr::kable.

df = data.frame(ID=1:3,code1=letters[1:3],
                code2=letters[4:6],
                code3=letters[7:9],
                code4=letters[10:12],
                code5=letters[13:15])

# kable can alse be used for creating tables
knitr::kable(df,caption="This is a wide kable table.",
             #format="latex",
             table.envir="table*",
             booktabs=TRUE,label="tab3")

Cross-referencing sections

You can cross-reference sections and subsections as follows: Section \ref{literature-citations} and Section \ref{a-subsection}.

Note: the last section in the document will be used as the section title for the bibliography.

For more portable and flexible referencing of sections, equations, figures and tables, use bookdown::pdf_document2 with YAML header option base_format: rticles::oup_article.

Appendices {-}

::: {.appendices latex=true}

Section title of first appendix

blabla

Subsection title of first appendix

and so on.... :::

References



Try the rticles package in your browser

Any scripts or data that you put into this service are public.

rticles documentation built on May 31, 2023, 6:12 p.m.