From c20ddfee580c8a0f890bd3cc4b9710d55257cbef Mon Sep 17 00:00:00 2001 From: "David M. Kaplan" Date: Thu, 23 Jan 2020 00:22:44 +0100 Subject: [PATCH 01/12] Adding initial stab at OUP template. Citations not working and strange things happen with a final section, but most other things seem to be working. Template needs further work to do equations and cross-referencing correctly. --- DESCRIPTION | 3 +- NAMESPACE | 1 + R/article.R | 16 ++ README.md | 2 + .../oup_article/resources/template.tex | 42 +++ .../oup_article/skeleton/mybibfile.bib | 20 ++ .../oup_article/skeleton/ouparticle.cls | 251 ++++++++++++++++++ .../oup_article/skeleton/skeleton.Rmd | 56 ++++ .../templates/oup_article/template.yaml | 5 + man/article.Rd | 15 ++ tests/testit/test-formats.R | 1 + 11 files changed, 411 insertions(+), 1 deletion(-) create mode 100644 inst/rmarkdown/templates/oup_article/resources/template.tex create mode 100644 inst/rmarkdown/templates/oup_article/skeleton/mybibfile.bib create mode 100644 inst/rmarkdown/templates/oup_article/skeleton/ouparticle.cls create mode 100644 inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd create mode 100644 inst/rmarkdown/templates/oup_article/template.yaml diff --git a/DESCRIPTION b/DESCRIPTION index b037d05e7..dd89f2c68 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,7 +37,8 @@ Authors@R: c( person("Zhian N.", "Kamvar", role = c("aut", "cph"), email = "zkamvar@gmail.com", comment = c(ORCID = "0000-0003-1458-7108")), person("Noam", "Ross", role = c("aut", "cph"), email = "noam.ross@gmail.com", comment = c(ORCID = "0000-0002-2136-0000")), person("Robrecht", "Cannoodt", role = c("aut", "cph"), email = "rcannood@gmail.com", comment = c(ORCID = "0000-0003-3641-729X", github = "rcannood")), - person("Duncan", "Luguern", role = c("aut"), email = "duncan.luguern@gmail.com") + person("Duncan", "Luguern", role = c("aut"), email = "duncan.luguern@gmail.com"), + person("David M.", "Kaplan", role = c("aut", "ctb"), email = "dmkaplan2000@gmail.com", comment = c(ORCID = "0000-0001-6087-359X", github = "dmkaplan2000")) ) Description: A suite of custom R Markdown formats and templates for authoring journal articles and conference submissions. diff --git a/NAMESPACE b/NAMESPACE index d67e6b920..1a89fd193 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,7 @@ export(joss_article) export(jss_article) export(mdpi_article) export(mnras_article) +export(oup_article) export(peerj_article) export(plos_article) export(pnas_article) diff --git a/R/article.R b/R/article.R index 7cc9b6406..0590922f7 100644 --- a/R/article.R +++ b/R/article.R @@ -168,6 +168,22 @@ mnras_article <- function(..., keep_tex = TRUE, fig_caption = TRUE) { ) } +#' @section \code{oup_article}: Format for creating submissions to many Oxford University Press +#' journals. Adapted from +#' \url{https://academic.oup.com/journals/pages/authors/preparing_your_manuscript} +#' and \url{https://academic.oup.com/icesjms/pages/General_Instructions}. +#' @export +#' @rdname article +oup_article <- function( + ..., citation_package = 'natbib', keep_tex = TRUE, + md_extensions = c("-autolink_bare_uris") +) { + pdf_document_format( + "oup_article", citation_package = citation_package, + keep_tex = keep_tex, md_extensions = md_extensions, ... + ) +} + #' @section \code{peerj_article}: Format for creating submissions to The PeerJ #' Journal. This was adapted from the #' \href{https://www.overleaf.com/latex/templates/latex-template-for-peerj-journal-and-pre-print-submissions/ptdwfrqxqzbn}{PeerJ diff --git a/README.md b/README.md index 7cacc3cce..c7a321e1b 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ The **rticles** package provides a suite of custom [R Markdown](http://rmarkdown - [NNRAS](https://www.ras.org.uk/news-and-press/2641-new-version-of-the-mnras-latex-package) journal submissions +- [OUP](https://academic.oup.com/journals/pages/authors/preparing_your_manuscript) articles + - [PeerJ](https://peerj.com) articles - [Royal Society Open Science](http://rsos.royalsocietypublishing.org/) journal submissions diff --git a/inst/rmarkdown/templates/oup_article/resources/template.tex b/inst/rmarkdown/templates/oup_article/resources/template.tex new file mode 100644 index 000000000..813cf43b7 --- /dev/null +++ b/inst/rmarkdown/templates/oup_article/resources/template.tex @@ -0,0 +1,42 @@ +\documentclass[$if(fontsize)$$fontsize$,$else$12pt,$endif$$if(spacing)$$spacing$,$else$halfline,$endif$$if(papersize)$$papersize$,$else$a4paper,$endif$$for(classoptions)$$classoptions$$sep$,$endfor$]{ouparticle} + +\usepackage{hyperref} + +\begin{document} + +\title{$title$} + +\author{% +$for(authors)$ +\name{$authors.name$}$if(authors.address)$\address{$authors.address$}$endif$$if(authors.email)$\email{$authors.email$}$endif$$if(authors.corresponding_author)$\thanks{Corresponding author: $authors.email$}$endif$ +$sep$\and +$endfor$ +} + +\abstract{$abstract$} + +\date{$if(date)$$date$$else$\today$endif$} + +\keywords{$for(keywords)$$keywords$$sep$; $endfor$} + +\maketitle + +$body$ + +$if(notes)$ +\begin{notes} +$notes$ +\end{notes} +$endif$ + +$if(acknowledgements)$ +\begin{notes}[Acknowledgements] +$acknowledgements$ +\end{notes} +$endif$ + +$if(bibliography)$ +\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} +$endif$ + +\end{document} diff --git a/inst/rmarkdown/templates/oup_article/skeleton/mybibfile.bib b/inst/rmarkdown/templates/oup_article/skeleton/mybibfile.bib new file mode 100644 index 000000000..32ccbc79c --- /dev/null +++ b/inst/rmarkdown/templates/oup_article/skeleton/mybibfile.bib @@ -0,0 +1,20 @@ +@article{Dirac1953888, + title = "The lorentz transformation and absolute time", + journal = "Physica ", + volume = "19", + number = "1-–12", + pages = "888--896", + year = "1953", + doi = "10.1016/S0031-8914(53)80099-6", + author = "P.A.M. Dirac" +} + +@article{Feynman1963118, + title = "The theory of a general quantum system interacting with a linear dissipative system", + journal = "Annals of Physics ", + volume = "24", + pages = "118--173", + year = "1963", + doi = "10.1016/0003-4916(63)90068-X", + author = "R.P Feynman and F.L {Vernon Jr.}" +} diff --git a/inst/rmarkdown/templates/oup_article/skeleton/ouparticle.cls b/inst/rmarkdown/templates/oup_article/skeleton/ouparticle.cls new file mode 100644 index 000000000..cc295a0bf --- /dev/null +++ b/inst/rmarkdown/templates/oup_article/skeleton/ouparticle.cls @@ -0,0 +1,251 @@ +\ProvidesClass{ouparticle}[2009/12/09 v1.0] + +\NeedsTeXFormat{LaTeX2e}[1995/12/01] + +\newif\ifnum@bib\num@bibtrue +\newif\ifnote@end\note@endfalse + +\DeclareOption{oneline}{\PassOptionsToPackage{doublespacing}{setspace}} +\DeclareOption{halfline}{\PassOptionsToPackage{onehalfspacing}{setspace}} +\DeclareOption{endnotes}{\ProvidesPackage{endnotes}\note@endtrue} +\DeclareOption{numbib}{\num@bibtrue} +\DeclareOption{nonumbib}{\num@bibfalse} + +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} +\ProcessOptions + +\LoadClass{article} + +\RequirePackage{amsmath,amssymb,amsfonts,verbatim,graphicx,setspace,endnotes}%% +\RequirePackage[left=1in,right=1in,top=1in,bottom=1in]{geometry} +\usepackage{xspace,amscd,rotating,latexsym,multicol,array,algorithm,subfigure} +\usepackage[hyphens,obeyspaces]{url} + +\let\@abstract\relax +\long\gdef\abstract#1{{\gdef\@abstract{% + \small% + \begin{center}% + {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}% + \end{center}% + {\quotation% + \noindent#1% + \endquotation}% +\par}}} + +\newcommand\keywordsname{Keywords} +\def\author#1{\def\and{\\}\gdef\@author{#1}} +\def\keywords#1{\gdef\@keywords{\textbf{\keywordsname:} #1}}\gdef\@keywords{} + +\long\def\name#1{#1\\} +\long\def\address#1{#1\\} +\long\def\email#1{#1\\} + +\if@twoside + \def\ps@headings{% + \let\@oddfoot\@empty\let\@evenfoot\@empty + \def\@evenhead{\thepage\hfil\slshape\leftmark}% + \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% + \let\@mkboth\markboth + \def\sectionmark##1{% + \markboth {\MakeUppercase{% + \ifnum \c@secnumdepth >\z@ + \thesection\quad + \fi + ##1}}{}}% + \def\subsectionmark##1{% + \markright {% + \ifnum \c@secnumdepth >\@ne + \thesubsection\quad + \fi + ##1}}} +\else + \def\ps@headings{% + \let\@oddfoot\@empty + \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% + \let\@mkboth\markboth + \def\sectionmark##1{% + \markright {\MakeUppercase{% + \ifnum \c@secnumdepth >\m@ne + \thesection\quad + \fi + ##1}}}} +\fi +\def\ps@myheadings{% + \let\@oddfoot\@empty\let\@evenfoot\@empty + \def\@evenhead{\thepage\hfil\slshape\leftmark}% + \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% + \let\@mkboth\@gobbletwo + \let\sectionmark\@gobble + \let\subsectionmark\@gobble + } + \if@titlepage + \newcommand\maketitle{\begin{titlepage}% + \let\footnotesize\small + \let\footnoterule\relax + \let \footnote \thanks + \null\vfil + \vskip 60\p@ + \begin{center}% + {\LARGE \@title \par}% + \vskip 3em% + {\large + \lineskip .75em% + \begin{tabular}[t]{c}% + \@author + \end{tabular}\par}% + \vskip 1.5em% + {\large \@date \par}% + \end{center}\par + \@thanks + \vfil\null + \end{titlepage}% + \setcounter{footnote}{0}% + \global\let\thanks\relax + \global\let\maketitle\relax + \global\let\@thanks\@empty + \global\let\@author\@empty + \global\let\@date\@empty + \global\let\@title\@empty + \global\let\title\relax + \global\let\author\relax + \global\let\date\relax + \global\let\and\relax +} +\else +\renewcommand\maketitle{\par + \begingroup + \renewcommand\thefootnote{\@fnsymbol\c@footnote}% + \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}% + \long\def\@makefntext##1{\parindent 1em\noindent + \hb@xt@1.8em{% + \hss\@textsuperscript{\normalfont\@thefnmark}}##1}% + \if@twocolumn + \ifnum \col@number=\@ne + \@maketitle + \else + \twocolumn[\@maketitle]% + \fi + \else + \newpage + \global\@topnum\z@ % Prevents figures from going at top of page. + \@maketitle + \fi + \thispagestyle{plain}\@thanks + \endgroup + \setcounter{footnote}{0}% + \global\let\thanks\relax + \global\let\maketitle\relax + \global\let\@maketitle\relax + \global\let\@thanks\@empty + \global\let\@author\@empty + \global\let\@date\@empty + \global\let\@title\@empty + \global\let\title\relax + \global\let\author\relax + \global\let\date\relax + \global\let\and\relax +} +\def\@maketitle{% + \newpage + \null + \vskip 2em% + {\leftskip\z@ plus 1fill\rightskip\leftskip + \let \footnote \thanks + {\LARGE \noindent\@title \par}% + \vskip 1.5em% + {\large\lineskip .5em\noindent\@author\par}% + \vskip 1em% + {\large \noindent\@date}% + \vskip 2em% + \@abstract% + \vskip0em% + \noindent\@keywords + \par} + \vskip 1.5em} +\fi + +\renewcommand\section{\@startsection {section}{1}{\z@}% + {-3.5ex \@plus -1ex \@minus -.2ex}% + {2.3ex}% + {\normalfont\Large\bfseries\raggedright}} +\renewcommand\subsection{\@startsection{subsection}{2}{\z@}% + {-3.25ex\@plus -1ex \@minus -.2ex}% + {1.5ex}% + {\normalfont\large\bfseries\raggedright}} +\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% + {-3.25ex\@plus -1ex \@minus -.2ex}% + {1.5ex}% + {\normalfont\normalsize\bfseries\raggedright}} +\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% + {3.25ex \@plus1ex \@minus.2ex}% + {-1em}% + {\normalfont\normalsize\bfseries}} +\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}% + {3.25ex \@plus1ex \@minus .2ex}% + {-1em}% + {\normalfont\normalsize\bfseries}} + + + +\renewcommand\appendix{\@ifstar\@starappendix\@appendix} + +\newcommand\@starappendix{\par + \setcounter{section}{0}% + \setcounter{subsection}{0}% + \setcounter{secnumdepth}{0} + \gdef\thesection{\@Alph\c@section}} +\newcommand\@appendix{\par + \setcounter{section}{0}% + \setcounter{subsection}{0}% + \gdef\thesection{\@Alph\c@section}} + +\ifnote@end\let\footnote\endnote\fi% + +\newenvironment{notes}[1][Notes]{\par +\section*{#1}% +}{\par} + +\renewenvironment{thebibliography}[1] + {\section*{\refname}% + \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}% + \list{\ifnum@bib\@biblabel{\@arabic\c@enumiv}\fi}% + {\settowidth\labelwidth{\@biblabel{#1}}% + \ifnum@bib + \leftmargin\labelwidth + \advance\leftmargin\labelsep + \else + \leftmargin\bibindent + \advance\itemindent-\bibindent + \fi + \@openbib@code + \usecounter{enumiv}% + \let\p@enumiv\@empty + \renewcommand\theenumiv{\@arabic\c@enumiv}}% + \sloppy + \clubpenalty4000 + \@clubpenalty \clubpenalty + \widowpenalty4000% + \sfcode`\.\@m} + {\def\@noitemerr + {\@latex@warning{Empty `thebibliography' environment}}% + \endlist} + + + +\setlength\parskip{0\p@} +\setlength\columnsep{12\p@} +\setlength\columnseprule{0\p@} +\pagestyle{plain} +\pagenumbering{arabic} +\if@twoside +\else + \raggedbottom +\fi +\if@twocolumn + \twocolumn + \sloppy + \flushbottom +\else + \onecolumn +\fi +\endinput diff --git a/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd new file mode 100644 index 000000000..dd5af879b --- /dev/null +++ b/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd @@ -0,0 +1,56 @@ +--- +title: Short Paper +#date: "`r Sys.Date()`" +authors: + - name: Alice Anonymous + email: alice@example.com + address: Some Institute of Technology + - name: Bob Security + email: bob@example.com + address: Another University + corresponding_author: yes + - name: Cat Memes + email: cat@example.com + address: Another University + - name: Derek Zoolander + email: derek@example.com + address: Some Institute of Technology +abstract: | + This is the abstract. + + It consists of two paragraphs. +acknowledgements: | + This is an acknowledgement. + + It consists of two paragraphs. +keywords: + - key + - dictionary + - word +#fontsize: 12pt +#spacing: halfline # could also be oneline +#classoptions: +# - endnotes +bibliography: mybibfile.bib +output: rticles::oup_article +--- + +# Introduction + +This template is based on the generic OUP template available [here](https://academic.oup.com/icesjms/pages/General_Instructions). + +Here are two sample references: @Feynman1963118 [@Dirac1953888]. They will appear in Section \ref{references} + +# Materials and methods + +An equation: + +$$ +E = mc^2 +$$ + +# Results + +# Discussion + +# References diff --git a/inst/rmarkdown/templates/oup_article/template.yaml b/inst/rmarkdown/templates/oup_article/template.yaml new file mode 100644 index 000000000..06794c5f7 --- /dev/null +++ b/inst/rmarkdown/templates/oup_article/template.yaml @@ -0,0 +1,5 @@ +name: Oxford University Press (OUP) Template +description: > + Template for creating an article for submission to Oxford University Press Journals. +create_dir: true + diff --git a/man/article.Rd b/man/article.Rd index 975b88d86..9e1af6021 100644 --- a/man/article.Rd +++ b/man/article.Rd @@ -14,6 +14,7 @@ \alias{frontiers_article} \alias{mdpi_article} \alias{mnras_article} +\alias{oup_article} \alias{peerj_article} \alias{plos_article} \alias{pnas_article} @@ -70,6 +71,13 @@ mdpi_article(..., keep_tex = TRUE) mnras_article(..., keep_tex = TRUE, fig_caption = TRUE) +oup_article( + ..., + citation_package = "natbib", + keep_tex = TRUE, + md_extensions = c("-autolink_bare_uris") +) + peerj_article(..., keep_tex = TRUE) plos_article(..., keep_tex = TRUE, md_extensions = c("-autolink_bare_uris")) @@ -175,6 +183,13 @@ custom Pandoc LaTeX template and different default values for other arguments \url{https://www.ras.org.uk/news-and-press/2641-new-version-of-the-mnras-latex-package}. } +\section{\code{oup_article}}{ + Format for creating submissions to many Oxford University Press + journals. Adapted from + \url{https://academic.oup.com/journals/pages/authors/preparing_your_manuscript} + and \url{https://academic.oup.com/icesjms/pages/General_Instructions}. +} + \section{\code{peerj_article}}{ Format for creating submissions to The PeerJ Journal. This was adapted from the diff --git a/tests/testit/test-formats.R b/tests/testit/test-formats.R index 7e112a721..73d511c1f 100644 --- a/tests/testit/test-formats.R +++ b/tests/testit/test-formats.R @@ -49,3 +49,4 @@ test_format("mnras_article") test_format("copernicus_article") test_format("frontiers_article") test_format("tf_article") +test_format("oup_article") From b174bafcba0a489fa5ced7fc40027d0ce9069362 Mon Sep 17 00:00:00 2001 From: "David M. Kaplan" Date: Thu, 23 Jan 2020 20:33:14 +0100 Subject: [PATCH 02/12] Seem to have fixed almost all of the issues, but still need a bit more testing --- .../skeleton/ouparticle_sample.tex | 462 ++++++++++++++++++ 1 file changed, 462 insertions(+) create mode 100644 inst/rmarkdown/templates/oup_article/skeleton/ouparticle_sample.tex diff --git a/inst/rmarkdown/templates/oup_article/skeleton/ouparticle_sample.tex b/inst/rmarkdown/templates/oup_article/skeleton/ouparticle_sample.tex new file mode 100644 index 000000000..e2488a965 --- /dev/null +++ b/inst/rmarkdown/templates/oup_article/skeleton/ouparticle_sample.tex @@ -0,0 +1,462 @@ +\documentclass[12pt,halfline,a4paper]{ouparticle} + +\begin{document} + +\title{Sample Article for\break {Oxford University Press~Journals}} + +\author{% +\name{First Author} +\address{Institute or Organization, Department, City, State,\\ +Zip Code, Country} +\email{e-mail address} +\and +\name{Second Author} +\address{Institute or Organization, Department, City, State,\\ +Zip Code, Country} +\email{e-mail address}} + +\abstract{This sample is a guideline for preparing technical papers using \LaTeX\ +for manuscript submission. It contains the documentation for your \LaTeX\ +Class file, which implements the layout for your manuscript for all Journals of OUP. +This sample article uses a class file named \texttt{ouparticle.cls} that all authors +need to use for their manuscript preparation. It is similar in use to the \texttt{article} +class file of \LaTeX, but has some extra fields in the preamble and some extended commands for +other parts of the article.} + +\date{\today} + +\keywords{word1; word2; word3; and word4} + +\maketitle + + +\section{Introduction} +\label{sec1} + +It is assumed that the author is familiar with either plain +\TeX, \AmS-\TeX{} or a standard \LaTeX\ setup and, hence, +only the essential points are described in this document. +Nevertheless, we hope that this document is generally sufficient +for describing the requirements for preparation of +manuscripts. For more details, please see the \textit{\LaTeX{} User's Guide} or +\textit{The not so short introduction to \LaTeXe}. + + +\section{Installation} +\label{sec2} + +Provided with \verb+ouparticle.cls+ are the files +\verb+sample.tex+ (this document explains the various +features of \verb+ouparticle.cls+) and \verb+sample.pdf+ +(how the output using \verb+sample.tex+ should be). Your +paper can be compiled with standard \LaTeX, +preferably with the current \LaTeXe\ version. It will probably work +with older versions of \LaTeXe; however, this has not been +tested. The file \verb+ouparticle.cls+ needs to be copied +into a directory where \TeX\ looks for input files. The other files +need to be kept as a reference while preparing +your manuscript. Please use the predefined commands from \verb+sample.tex+ for title, +authors, abstract, body, etc. + + +\section{Preparing your manuscript} +\label{sec3} + +\subsection{General guidelines} +\label{sec3.1} + +\begin{enumerate} +\item +\LaTeX\ and \AmS-\LaTeX\ provide a rich set of commands for all common, important +features of your paper. Use them; avoid definitions and use of custom commands. + +\item +There is no need to redefine any \TeX, \LaTeX\ or \AmS-\LaTeX\ commands. + +\item +Avoid direct formatting for headings cleanly set as section headings. + +\item +Use \LaTeX\ commands for font changes. For example: use \verb+\textbf{phrase}+, +not \verb+{\bf phrase}+; use \verb+\mathcal{C}+, not \verb+{\cal C}+; etc. +\end{enumerate} + + +\subsection{How to start with \texttt{ouparticle.cls}} +\label{sec3.2} + +Before you type anything that actually appears in the paper, you need to +include a \verb+\documentclass{ouparticle}+ command at the very beginning, +and then the two commands that have to be part of any \LaTeX\ document, +\verb+\begin{document}+ at the start and \verb+\end{document}+ at the +end of your paper. + + +\subsection{Document structure} +\label{sec3.3} + +The main structure of your paper is as follows: + +\begin{verbatim} +\documentclass[12pt,...]{ouparticle} +\usepackage[...]{packages} + +\title{...} +\author{ + \name{...} + \address{...} + \email{...} + \and + \name{...} + \address{...} + \email{...} + \and + \name{...} + \address{...} + \email{...} +} +\abstract{...} +\keywords{...} + +\maketitle + +\begin{document} + +\section{....} +... +\subsection{....} +.... +\end{document} +\end{verbatim} + + +\subsection{Options} +\label{sec3.4} + +By default, all of the options within \verb+article.cls+ are available +with this class file. This class file provides the following additional options. + +\begin{description} +\item \textbf{oneline:} +This option will set your entire manuscript in one line spacing. +It will not affect the footnote, figure and table environments. + +\item \textbf{halfline:} +This is to set your entire manuscript in half line spacing. + +\item \textbf{endnotes:} +To make all footnotes to endnotes. You may follow the same +coding \verb+\footnote{text}+ for both footnotes and endnotes. Once you use this option +you have to use the \verb+\theendnotes+ command at the place where all the endnotes +have to be set in your paper. + +\item \textbf{numbib:} +This is the default option that numbers the bibliography items; +this option does nothing with natbib and other packages. + +\item \textbf{nonumbib:} For unnumbered bibliography. +\end{description} + + +\subsection{Front matter} +\label{sec3.5} + +The title of the manuscript is simply specified by using the \verb+\title{text}+ command in +the same manner as in this sample. Author's information consists of the name of the author +and the corresponding institutions with addresses, as given in this example. Include an +electronic mail address if available, inserting it into the \verb+\email{text}+ commands. +You may follow the same coding if there are more than one author; separate authors with +\verb+\and+. Please identify the corresponding author with his/her electronic +mail address by \verb+\thanks{text}+. An abstract for your paper is specified by using +\verb+\abstract{text}+. A \verb+\keywords{text}+ macro may also be used to indicate keywords for the +article. Use \verb+\maketitle+ after the abstract and keywords to make the header of your article. + +\subsection{Sections and subsections} +\label{sec3.6} + +To begin a new section, give the heading of that section in the \verb+\section{text}+ command. +A section number is supplied automatically. Use the starred form (\verb+\section*{text}+) of the +command to suppress the automatic numbering. If you want to be able to make reference to that section, +then you need to \texttt{label} it (see Section \ref{sec3.14}). You can have sections up to +five levels. The sectioning commands are \verb|\section|, \verb|\subsection|, \verb|\subsubsection|, +\verb|\paragraph| and \verb|\subparagraph|. + +\subsection{Ordinary text} +\label{sec3.7} + +The ends of words and sentences are marked by spaces. It does not matter how many +spaces you type. The end of a line counts as a space. One +or more blank lines denote the end of a paragraph. + +There are a number of things for which you need to follow different +methods. As you know, quotation marks, quotes within quotes, +dashes, ellipsis, etc. should be as per the \LaTeX\ standard input. \LaTeX\ interprets some +common characters as commands, and therefore you must instead type those common characters as +specific \LaTeX\ commands to generate them. Those characters are \$, \&, \%, \#, \{, and \}. + +\subsection{Formatting} +\label{sec3.8} + +One should always use \LaTeX\ macros rather than the lower-level +\TeX\ macros like \verb+\it+, \verb+\bf+ and \verb+\tt+. The +\LaTeX\ macros offer much improved features. The following table summarizes the font +selection commands in \LaTeX. + + +\subsubsection*{\LaTeX\ text formatting commands} +\begin{tabular}{ll@{\hskip60pt}ll} +\verb+\textit+ & Italics &\verb+\textsf+ & Sans Serif\\ +\verb+\textbf+ & Boldface &\verb+\textsc+ & Small Caps\\ +\verb+\texttt+ & Typewriter &\verb+\textmd+ & Medium Series\\ +\verb+\textrm+ & Roman &\verb+\textnormal+ & Normal Series\\ +\verb+\textsl+ & Slanted &\verb+\textup+ & Upright Series +\end{tabular} + + +\subsubsection*{\LaTeX\ math formatting commands} +\begin{tabular}{ll@{\qquad}ll} +\verb+\mathit+ & Math Italics &\verb+\mathfrak+ & Fraktur\\ +\verb+\mathbf+ & Math Boldface &\verb+\mathbb+ & Blackboard Bold\\ +\verb+\mathtt+ & Math Typewriter &\verb+\mathnormal+ & Math Normal\\ +\verb+\mathsf+ & Math Sans Serif &\verb+\boldsymbol+ & Bold math for Greek letters\\ +\verb+\mathcal+ & Calligraphic & & and other symbols +\end{tabular} + + +\subsection{Figures and tables} +\label{sec3.9} + +Use normal \LaTeX\ coding for figures and tables. +Figure and table environments should be inserted after (not in) the paragraph in which +the figure is first mentioned or grouped all +together at the end of the file. They will be numbered automatically. +The following is an example of typesetting a table. + +\begin{verbatim} +\begin{table} +\caption{Table caption text.} +\label{key} +The table matter goes here. +\end{table} +\end{verbatim} + +As always with \LaTeX, the \verb+\label+ must be after the +\verb+\caption+, and inside the figure or table environment. The reference for +figures and tables inside text can be made using the \verb|\ref{key}| command. + + +\subsection{Equations}\label{sec3.10} + +Equations are used in the same way as described in the \LaTeX\ manual. +Do not start a paragraph with a displayed equation. Equations are numbered consecutively, with equation numbers +in parentheses flush right. + For example, if you type +\begin{verbatim} +\begin{equation}\label{eq1} +\int^{r_2}_0 F(r,\varphi){\rm d}r\,{\rm d}\varphi = [\sigma r_2/(2\mu_0)] +\int^{\infty}_0\exp(-\lambda|z_j-z_i|)\lambda^{-1}J_1 (\lambda r_2)J_0 +(\lambda r_i\,\lambda {\rm d}\lambda) +\end{equation} +\end{verbatim} +then you will get the following output: +\begin{equation}\label{eq1} +\int^{r_2}_0 F(r,\varphi){\rm d}r\,{\rm d}\varphi = [\sigma r_2/(2\mu_0)]\int^{\infty}_0 +\exp(-\lambda|z_j-z_i|)\lambda^{-1}J_1 (\lambda r_2)J_0 (\lambda r_i\,\lambda {\rm d}\lambda) +\end{equation} +It inserts space both above and below the equation. \AmS-\LaTeX{} has several environments that +make it easier to typeset complicated multiline displayed equations. These are explained in the +\AmS-\LaTeX{} User Guide. A \verb+subequation+ environment is available to create equations with +sub-numbering of the equation counter. It takes one (optional) +argument to specify the way that the sub-counter should appear. + + +\subsection{Displayed text} +\label{sec3.11} + +Text is displayed by indenting it from the left and right margins. +Quotations are commonly displayed. There are short +quotations: +\begin{quote} + This is a short quotation. It consists of a + single paragraph of text. See how it is formatted. +\end{quote} +and longer ones: +\begin{quotation} + This is a longer quotation. It consists of two + paragraphs of text, neither of which are + particularly interesting. + + This is the second paragraph of the quotation. It + is just as dull as the first paragraph. +\end{quotation} +You can even display poetry. +\begin{verse} + There is an environment + for verse \\ % The \\ command separates lines + Whose features some poets % within a stanza. + will curse. + + % One or more blank lines separate stanzas. + + For instead of making\\ + Them do \emph{all} line breaking, \\ + It allows them to put too many words on a line when they'd rather be + forced to be terse. +\end{verse} + + +\subsection{Listings} +\label{sec3.12} + +Another frequently displayed structure is a list. The +following is an example of an \emph{itemized} list. +\begin{itemize} + \item This is the first item of an itemized list. + Each item in the list is marked with a + `$\bullet$'. + + \item This is the second item of the list. It + contains another list nested inside it. The + inner list is an \emph{enumerated} list. + \begin{enumerate} + \item This is the first item of an enumerated + list that is nested within the + itemized list. + + \item This is the second item of the inner list. + \LaTeX\ allows you to nest lists + deeper than you really should. + \end{enumerate} + This is the rest of the second item of the + outer list. It is no more interesting than + any other part of the item. + \item This is the third item of the list. +\end{itemize} + + +\subsection{Displayed sentences: theorems and such} +\label{sec3.13} + +These environments have to be defined with the help of \LaTeX's \verb+\newtheorem+ command, and +also with the \AmS-\LaTeX\ package for theorems that is already with your class file. +For example, \verb+\newtheorem{thm}{Theorem}+. Predefined theorem styles can be used in your article +to differentiate the theorem-like environments. You can have an extra command, \verb+\newproof+, +that can be used for displayed text. The following is an example of using the above-defined +\verb+thm+ environment. +\begin{verbatim} +\begin{thm} +This is body matter for this environment. +\end{thm} +\end{verbatim} + +\subsection{Cross-referencing} +\label{sec3.14} + +\LaTeX\ possesses features for labelling and cross-referencing +section headings, equations, tables, figures and theorems. +Their proper usage in the context of section headings, equations, +tables and figures are discussed in the appropriate sections. + +Cross-referencing depends upon the use of `keys' that are defined by the user. +The \verb+\label{key}+ command is used to identify the links. Keys are strings of +characters that serve to label section headings, equations, tables and figures +that replace explicit, by-hand numbering. The \verb+\ref{key}+ command is used for +cross-referencing. + +Files that use cross-referencing (and almost all manuscripts do) +need to be processed through \LaTeX\ at least twice to +ensure that the keys have been properly linked to the appropriate numbers. + +\subsection{Footnotes and endnotes} +\label{sec3.15} + +The footnote text can either appear at the bottom of a page or at the end of your paper. +The \verb+\footnote+ macro \emph{should not} be used in the front matter to provide additional +information about authors (such as corresponding addresses); instead, use \verb+\thanks{text}+ commands. +The document option `\texttt{endnotes}' is used to make endnotes. The command \verb+\theendnotes+ should +be used to place the endnotes at the required location in the text. They will be put in a separate +`Notes' section. + + +\subsection{Appendix} +\label{sec3.16} + +The \verb+\appendix+ command signals that all following sections are +appendices, and therefore the headings after \verb+\appendix+ will be set +as appendix headings. For a single appendix, use \verb+\appendix*+ followed by the \verb+\section{text}+ +command to suppress the appendix letter in the section heading. + + +\subsection{Special sections for notes and acknowledgements} +\label{sec3.17} + +If you wish to include a `Notes' or `Acknowledgements' section in your paper, +use the \verb+\begin{notes}...\end{notes}+ macro. We use the same environment for both +`Notes' and `Acknowledgements'. The following examples show to how to use this macro. +\begin{verbatim} +\begin{notes} +Please note that this class file is provided as it is, and +copyright by Oxford University Press. You are free to use this +class file, provided that you do not make changes in this class file. +If you do make changes, you are requested to rename the class file. +\end{notes} + +\begin{notes}[Acknowledgements] +The authors would like to thank... +\end{notes} + +\end{verbatim} + + +\subsection{References} +\label{sec3.18} + +The reference entries can be \LaTeX\ typed bibliographies or generated through a BIB\TeX\ database. +BIB\TeX\ is an adjunct to \LaTeX\ that aids in the preparation of bibliographies. BIB\TeX\ +allows authors to build up a database or collection of bibliography entries that may be used for many +manuscripts. They also save us the trouble of having to specify formatting. More details can be found +in the \textit{BIB\TeX\ Guide}. For \LaTeX\ reference entries use the +\verb+\begin{thebibliography}....\end{thebibliography}+ environment (see below) to make references in your paper. +We have provided the class file option to distinguish two styles of references. Those options are \verb+numbib+ and \verb+nonumbib+. +You can select one of these options with the \verb+\documentclass+ command. By default the class file will take the +\verb+numbib+ option. The following is an example of \LaTeX\ bibliography. + +\begin{verbatim} +\begin{thebibliography}{0} +\bibitem{bib1} +Goossens, M., F. Mittelbach, and A. Samarin: {\em The {\LaTeX} Companion}. +Addison-Wesley, Reading, MA, USA, 1994. +\bibitem{bib2} +Knuth, D.E: {\em The {\TeX}book}. Addison-Wesley, Reading, MA, USA, 1984. +\bibitem{bib3} +Lamport, L.: {\em {\LaTeX} -- A Document Preparation System -- User's +Guide and Reference Manual}. Addison-Wesley, Reading, MA, USA, 1985. +\bibitem{bib4} +Smith, I.N., R.S. Johnes, and W.P. Hines: 1992, `Title of the Article', +\textit{Journal Title in Italics} \textbf{Vol. no. X}, pp. 00--00 +\end{thebibliography} +\end{verbatim} + + +\section{Macro packages} +\label{sec4} + +The following packages are compulsorily needed by the class file: +\begin{verbatim} +amsmath graphicx +amssymb endnotes +amsfonts setspace +verbatim geometry +\end{verbatim} + +The commonly used packages already used by this class file that authors can use whenever required are: +\begin{verbatim} +xspace latexsym url +amscd multicol algorithm +rotating array subfigure +\end{verbatim} + +Additionally, you can use other packages and these should be loaded +using the \verb+\usepackage+ command. + +\end{document} From e2ebfd30a28649ac8ce6ca55d6c29ab4b723f8b9 Mon Sep 17 00:00:00 2001 From: "David M. Kaplan" Date: Thu, 23 Jan 2020 20:33:28 +0100 Subject: [PATCH 03/12] Seem to have fixed almost all of the issues, but still need a bit more testing --- .../oup_article/resources/template.tex | 95 +++++++++++++++++++ .../oup_article/skeleton/skeleton.Rmd | 67 +++++++++++-- 2 files changed, 155 insertions(+), 7 deletions(-) diff --git a/inst/rmarkdown/templates/oup_article/resources/template.tex b/inst/rmarkdown/templates/oup_article/resources/template.tex index 813cf43b7..cac3e6ad4 100644 --- a/inst/rmarkdown/templates/oup_article/resources/template.tex +++ b/inst/rmarkdown/templates/oup_article/resources/template.tex @@ -1,6 +1,77 @@ \documentclass[$if(fontsize)$$fontsize$,$else$12pt,$endif$$if(spacing)$$spacing$,$else$halfline,$endif$$if(papersize)$$papersize$,$else$a4paper,$endif$$for(classoptions)$$classoptions$$sep$,$endfor$]{ouparticle} +% Packages I think are necessary for basic Rmarkdown functionality \usepackage{hyperref} +\usepackage{graphicx} +\usepackage{listings} +\usepackage{color} +\usepackage{fancyvrb} +\usepackage{framed} + +% Packages that are supposedly required by OUP sty file +\usepackage{amssymb, amsmath, geometry, amsfonts, verbatim, endnotes, setspace} + +% For code highlighting I think +\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} +\definecolor{shadecolor}{RGB}{248,248,248} +\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}} +\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.94,0.16,0.16}{#1}} +\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} +\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.77,0.63,0.00}{#1}} +\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}} +\newcommand{\BuiltInTok}[1]{#1} +\newcommand{\CharTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}} +\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}} +\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} +\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}} +\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}} +\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{#1}} +\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}} +\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} +\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.64,0.00,0.00}{\textbf{#1}}} +\newcommand{\ExtensionTok}[1]{#1} +\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.00,0.00,0.81}{#1}} +\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}} +\newcommand{\ImportTok}[1]{#1} +\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} +\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.13,0.29,0.53}{\textbf{#1}}} +\newcommand{\NormalTok}[1]{#1} +\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.81,0.36,0.00}{\textbf{#1}}} +\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}} +\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textit{#1}}} +\newcommand{\RegionMarkerTok}[1]{#1} +\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}} +\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}} +\newcommand{\StringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}} +\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.00,0.00,0.00}{#1}} +\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.31,0.60,0.02}{#1}} +\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{\textbf{\textit{#1}}}} + +% For making Rmarkdown lists +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} + + +% Part for setting citation format package: natbib +$if(natbib)$ +\usepackage{natbib} +\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} +$endif$ + +% Part for setting citation format package: biblatex +$if(biblatex)$ +\usepackage[$if(biblio-citestyle)$citestyle=$biblio-citestyle$$else$citestyle=ieee$endif$$if(biblio-style)$,style=$biblio-style$$else$,style=numeric$endif$$if(citation_sorting)$,sorting=$citation_sorting$$endif$]{biblatex} +$if(bibliography)$ +$for(bibliography)$ +\addbibresource{$bibliography$} +$endfor$ +$endif$ +$endif$ + +% Pandoc header +$for(header-includes)$ +$header-includes$ +$endfor$ \begin{document} @@ -21,6 +92,11 @@ \maketitle + +$for(include-before)$ +$include-before$ +$endfor$ + $body$ $if(notes)$ @@ -35,8 +111,27 @@ \end{notes} $endif$ +$if(natbib)$ $if(bibliography)$ + +$if(biblio-title)$ +$if(book-class)$ +\renewcommand\bibname{$biblio-title$} +$else$ +\renewcommand\refname{$biblio-title$} +$endif$ +$endif$ + \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} $endif$ +$endif$ + +$if(biblatex)$ +\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$ +$endif$ + +$for(include-after)$ +$include-after$ +$endfor$ \end{document} diff --git a/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd index dd5af879b..53297e7b0 100644 --- a/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd @@ -1,5 +1,5 @@ --- -title: Short Paper +title: Template for Oxford University Press papers #date: "`r Sys.Date()`" authors: - name: Alice Anonymous @@ -35,22 +35,75 @@ bibliography: mybibfile.bib output: rticles::oup_article --- +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = FALSE) # By default, hide code; set to TRUE to see code +knitr::opts_chunk$set(fig.pos = 'p') # Places figures on their own pages +knitr::opts_chunk$set(out.width = '100%', dpi=300) # Figure resolution and size + +library(xtable) # Creates tables that follow OUP guidelines; other options, such as kable, may also be workable +``` + # Introduction -This template is based on the generic OUP template available [here](https://academic.oup.com/icesjms/pages/General_Instructions). +This template is based on the generic OUP template available [here](https://academic.oup.com/icesjms/pages/General_Instructions). See the accompanying document [ouparticle_sample.tex](./ouparticle_sample.tex) for more details. -Here are two sample references: @Feynman1963118 [@Dirac1953888]. They will appear in Section \ref{references} +Here are two sample references: @Feynman1963118 [@Dirac1953888]. Bibliography will appear at the end of the document. # Materials and methods -An equation: +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 = [\sigma r_2/(2\mu_0)] +\int^{\infty}_0\exp(-\lambda|z_j-z_i|)\lambda^{-1}J_1 (\lambda r_2)J_0 +(\lambda r_i\,\lambda {\rm d}\lambda) +\end{equation} + +This equation can be referenced as follows: Eq. \ref{eq:eq1} + +## A subsection -$$ -E = mc^2 -$$ +A numbered list: + +1) First point +2) Second point + - Subpoint + +A bullet list: + +* First point +* Second point # Results +Generate a figure. + +```{r fig1, fig.cap="This is the first figure.",echo=TRUE} +plot(1:10,main="Some data",xlab="Distance (cm)",ylab="Time (hours)") +``` + +With this figure caption, you can reference this figure as follows: Fig. \ref{fig:fig1}. + +```{r fig2, fig.cap="This is the second figure.",echo=TRUE} +plot(1:5,pch=19,main="Some data",xlab="Distance (cm)",ylab="Time (hours)") +``` + +Reference to second figure: Fig. \ref{fig:fig2} + +Generate a table. + +```{r tab1, results="asis", echo=TRUE} +df = data.frame(ID=1:3,code=letters[1:3]) +print(xtable(df,caption="This is the table caption",label="tab:tab1"), + comment=FALSE) +``` + +You can reference this table as follows: Table \ref{tab:tab1}. + # Discussion +You can cross-reference sections and subsections as follows: Section \ref{materials-and-methods} and Section \ref{a-subsection}. + +***Note:*** the last section in the document will be used as the section title for the bibliography. + # References From 817416da427c4233cd8ba3624a49437f013fca02 Mon Sep 17 00:00:00 2001 From: "David M. Kaplan" Date: Thu, 23 Jan 2020 21:27:53 +0100 Subject: [PATCH 04/12] Small improvements and clarifications --- inst/rmarkdown/templates/oup_article/resources/template.tex | 5 ++++- inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/inst/rmarkdown/templates/oup_article/resources/template.tex b/inst/rmarkdown/templates/oup_article/resources/template.tex index cac3e6ad4..6ee215b94 100644 --- a/inst/rmarkdown/templates/oup_article/resources/template.tex +++ b/inst/rmarkdown/templates/oup_article/resources/template.tex @@ -8,6 +8,9 @@ \usepackage{fancyvrb} \usepackage{framed} +%% To allow better options for figure placement +%\usepackage{float} + % Packages that are supposedly required by OUP sty file \usepackage{amssymb, amsmath, geometry, amsfonts, verbatim, endnotes, setspace} @@ -79,7 +82,7 @@ \author{% $for(authors)$ -\name{$authors.name$}$if(authors.address)$\address{$authors.address$}$endif$$if(authors.email)$\email{$authors.email$}$endif$$if(authors.corresponding_author)$\thanks{Corresponding author: $authors.email$}$endif$ +\name{$authors.name$}$if(authors.address)$\address{$authors.address$}$endif$$if(authors.email)$\email{$authors.email$}$endif$$if(authors.corresponding_author)$\thanks{Corresponding author; Email: $authors.email$}$endif$ $sep$\and $endfor$ } diff --git a/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd index 53297e7b0..1c88405e4 100644 --- a/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd @@ -39,13 +39,14 @@ output: rticles::oup_article knitr::opts_chunk$set(echo = FALSE) # By default, hide code; set to TRUE to see code knitr::opts_chunk$set(fig.pos = 'p') # Places figures on their own pages knitr::opts_chunk$set(out.width = '100%', dpi=300) # Figure resolution and size +knitr::opts_chunk$set(fig.env="figure") # Latex figure environment library(xtable) # Creates tables that follow OUP guidelines; other options, such as kable, may also be workable ``` # Introduction -This template is based on the generic OUP template available [here](https://academic.oup.com/icesjms/pages/General_Instructions). See the accompanying document [ouparticle_sample.tex](./ouparticle_sample.tex) for more details. +This template is based on the generic OUP template available [here](https://academic.oup.com/icesjms/pages/General_Instructions). The original OUP sample tex document, providing more details on prefered formatting for LaTeX documents, is included with the template in the file `ouparticle_sample.tex`. Here are two sample references: @Feynman1963118 [@Dirac1953888]. Bibliography will appear at the end of the document. @@ -82,7 +83,7 @@ Generate a figure. plot(1:10,main="Some data",xlab="Distance (cm)",ylab="Time (hours)") ``` -With this figure caption, you can reference this figure as follows: Fig. \ref{fig:fig1}. +You can reference this figure as follows: Fig. \ref{fig:fig1}. ```{r fig2, fig.cap="This is the second figure.",echo=TRUE} plot(1:5,pch=19,main="Some data",xlab="Distance (cm)",ylab="Time (hours)") From 80f69b6dd6f4e12307be2c9600abf367919dc7f8 Mon Sep 17 00:00:00 2001 From: "David M. Kaplan" Date: Thu, 23 Jan 2020 21:39:28 +0100 Subject: [PATCH 05/12] Small improvement to corresponding author flexibility. --- inst/rmarkdown/templates/oup_article/resources/template.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/rmarkdown/templates/oup_article/resources/template.tex b/inst/rmarkdown/templates/oup_article/resources/template.tex index 6ee215b94..7f840d567 100644 --- a/inst/rmarkdown/templates/oup_article/resources/template.tex +++ b/inst/rmarkdown/templates/oup_article/resources/template.tex @@ -82,7 +82,7 @@ \author{% $for(authors)$ -\name{$authors.name$}$if(authors.address)$\address{$authors.address$}$endif$$if(authors.email)$\email{$authors.email$}$endif$$if(authors.corresponding_author)$\thanks{Corresponding author; Email: $authors.email$}$endif$ +\name{$authors.name$}$if(authors.address)$\address{$authors.address$}$endif$$if(authors.email)$\email{\href{mailto:$authors.email$}{$authors.email$}}$endif$$if(authors.thanks)$\thanks{$authors.thanks$}$else$$if(authors.corresponding_author)$\thanks{Corresponding author; Email: \href{mailto:$authors.email$}{$authors.email$}}$endif$$endif$ $sep$\and $endfor$ } From 84577c7c9fc9d33099fa71d673da9004510ded5b Mon Sep 17 00:00:00 2001 From: "David M. Kaplan" Date: Thu, 23 Jan 2020 22:03:18 +0100 Subject: [PATCH 06/12] Updating news --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 886382aef..fb4b70c7c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,8 @@ rticles 0.14 - `mnras.cls` was removed from this package because it exists on CTAN. +- Added Oxford University Press (OUP) template (thanks, @dmkaplan2000, #266). + rticles 0.13 --------------------------------------------------------------------- From b9e0e02429b2060d06330c62d61ce8d7a86a1b09 Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Tue, 4 Feb 2020 13:11:50 -0600 Subject: [PATCH 07/12] correct PR number --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index fb4b70c7c..b94b8b979 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,7 +9,7 @@ rticles 0.14 - `mnras.cls` was removed from this package because it exists on CTAN. -- Added Oxford University Press (OUP) template (thanks, @dmkaplan2000, #266). +- Added Oxford University Press (OUP) template (thanks, @dmkaplan2000, #271). rticles 0.13 --------------------------------------------------------------------- From 946213f3bafc912abb19a9982e6609a363f73a51 Mon Sep 17 00:00:00 2001 From: "David M. Kaplan" Date: Fri, 27 Mar 2020 22:09:20 +0100 Subject: [PATCH 08/12] Modifying skeleton so knitr::kable table generation works out of the box. Modifying template to show how to use knitr::kable for generating tables and how to use place floats at end and number lines using header-includes. --- .../oup_article/resources/template.tex | 4 +++ .../oup_article/skeleton/skeleton.Rmd | 27 +++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/inst/rmarkdown/templates/oup_article/resources/template.tex b/inst/rmarkdown/templates/oup_article/resources/template.tex index 7f840d567..5a3f3c878 100644 --- a/inst/rmarkdown/templates/oup_article/resources/template.tex +++ b/inst/rmarkdown/templates/oup_article/resources/template.tex @@ -8,6 +8,10 @@ \usepackage{fancyvrb} \usepackage{framed} +% For knitr::kable functionality +\usepackage{booktabs} +\usepackage{longtable} + %% To allow better options for figure placement %\usepackage{float} diff --git a/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd index 1c88405e4..7385a7ca7 100644 --- a/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/oup_article/skeleton/skeleton.Rmd @@ -33,15 +33,17 @@ keywords: # - endnotes bibliography: mybibfile.bib output: rticles::oup_article +#header-includes: +# - \usepackage[nomarkers,tablesfirst]{endfloat} # For figures and tables at end +# - \usepackage{lineno} # For line numbering +# - \linenumbers # For line numbering --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) # By default, hide code; set to TRUE to see code -knitr::opts_chunk$set(fig.pos = 'p') # Places figures on their own pages +knitr::opts_chunk$set(fig.pos = 'p') # Places figures on pages separate from text knitr::opts_chunk$set(out.width = '100%', dpi=300) # Figure resolution and size knitr::opts_chunk$set(fig.env="figure") # Latex figure environment - -library(xtable) # Creates tables that follow OUP guidelines; other options, such as kable, may also be workable ``` # Introduction @@ -77,7 +79,7 @@ A bullet list: # Results -Generate a figure. +## Generate a figure. ```{r fig1, fig.cap="This is the first figure.",echo=TRUE} plot(1:10,main="Some data",xlab="Distance (cm)",ylab="Time (hours)") @@ -91,16 +93,31 @@ plot(1:5,pch=19,main="Some data",xlab="Distance (cm)",ylab="Time (hours)") Reference to second figure: Fig. \ref{fig:fig2} -Generate a table. +## Generate a table using `xtable` ```{r tab1, results="asis", echo=TRUE} 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 the table caption",label="tab:tab1"), comment=FALSE) ``` You can reference this table as follows: Table \ref{tab:tab1}. +## Generate a table using `kable` + +```{r anothertable, echo=TRUE} +df = data.frame(ID=1:3,code=letters[1:3]) + +# kable can alse be used for creating tables +knitr::kable(df,caption="This is the table caption",format="latex", + booktabs=TRUE,label="tab2") +``` + +You can reference this table as follows: Table \ref{tab:tab2}. + # Discussion You can cross-reference sections and subsections as follows: Section \ref{materials-and-methods} and Section \ref{a-subsection}. From b9bb9482eeb3c8f63d841378314747258c987a46 Mon Sep 17 00:00:00 2001 From: "David M. Kaplan" Date: Fri, 27 Mar 2020 22:23:27 +0100 Subject: [PATCH 09/12] Update to news. --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index a3d8f0e71..9222a3ece 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ rticles 0.15 --------------------------------------------------------------------- - +- Update to OUP format for knitr::kable table generation and optionally placing floats at end of document (thanks, @dmkaplan2000, #279) rticles 0.14 --------------------------------------------------------------------- From e13e107614033adbf4d16b0156b5f24012841dce Mon Sep 17 00:00:00 2001 From: dmkaplan2000 Date: Fri, 8 May 2020 01:09:45 +0200 Subject: [PATCH 10/12] Modifying so that OUP format uses pandoc-citeproc for references by default. --- R/article.R | 4 ++-- .../templates/oup_article/resources/template.tex | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/R/article.R b/R/article.R index c7f3db4bc..62fdbc4b6 100644 --- a/R/article.R +++ b/R/article.R @@ -175,11 +175,11 @@ mnras_article <- function(..., keep_tex = TRUE, fig_caption = TRUE) { #' @export #' @rdname article oup_article <- function( - ..., citation_package = 'natbib', keep_tex = TRUE, + ..., keep_tex = TRUE, md_extensions = c("-autolink_bare_uris") ) { pdf_document_format( - "oup_article", citation_package = citation_package, + "oup_article", keep_tex = keep_tex, md_extensions = md_extensions, ... ) } diff --git a/inst/rmarkdown/templates/oup_article/resources/template.tex b/inst/rmarkdown/templates/oup_article/resources/template.tex index 5a3f3c878..529a15731 100644 --- a/inst/rmarkdown/templates/oup_article/resources/template.tex +++ b/inst/rmarkdown/templates/oup_article/resources/template.tex @@ -58,7 +58,6 @@ \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} - % Part for setting citation format package: natbib $if(natbib)$ \usepackage{natbib} @@ -75,6 +74,16 @@ $endif$ $endif$ +% Part for indenting CSL refs +$if(csl-refs)$ +\newlength{\cslhangindent} +\setlength{\cslhangindent}{1.5em} +\newenvironment{cslreferences}% + {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}% + \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}% + {\par} +$endif$ + % Pandoc header $for(header-includes)$ $header-includes$ From 3056e226a10e21e8238977e1e3207a8e04b6940e Mon Sep 17 00:00:00 2001 From: dmkaplan2000 Date: Fri, 8 May 2020 01:11:28 +0200 Subject: [PATCH 11/12] Updating news --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 9222a3ece..1913fa7fe 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ rticles 0.15 --------------------------------------------------------------------- - Update to OUP format for knitr::kable table generation and optionally placing floats at end of document (thanks, @dmkaplan2000, #279) +- Update to OUP format to use pandoc-citeproc by default for citations (thanks, @dmkaplan2000, #289) rticles 0.14 --------------------------------------------------------------------- From aef73fe0edd6dfce3d87730cdadfb4f7050fb6bf Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Mon, 3 Aug 2020 15:36:00 -0500 Subject: [PATCH 12/12] Update article.Rd --- man/article.Rd | 1 - 1 file changed, 1 deletion(-) diff --git a/man/article.Rd b/man/article.Rd index 63cee91e0..1fb9fea66 100644 --- a/man/article.Rd +++ b/man/article.Rd @@ -76,7 +76,6 @@ mnras_article(..., keep_tex = TRUE, fig_caption = TRUE) oup_article( ..., - citation_package = "natbib", keep_tex = TRUE, md_extensions = c("-autolink_bare_uris") )