Skip to content

Commit

Permalink
Add template for the MNRAS (Monthly Notices of the Royal Astronomical…
Browse files Browse the repository at this point in the history
… Society) article. (#175)

* Add MNRAS templates and skeleton.

* Add a CSL file.

I couldn't find official MNRAS CSL file so just this one for now.

* Add combinations of authors and affiliations

* Add MNRAS entry to NAMESPACE and README.md

* Add test for MNRAS template

* Reference template files paths

* Change PDF function to include CSL in Pandoc

inherit_pdf_document was changed to pdf_document_format

* Fix missing figure extensions

LaTeX in the testing environment appears to be looking for .tex figure
before finding the .png one.

* Add appendices

Appendices need to be positioned below references, hence the slightly
hacky div positioning.  See: https://stackoverflow.com/q/16427637

* Add example figure

* Generate documentation with Roxygen
  • Loading branch information
oleskiewicz authored and yihui committed Jul 5, 2018
1 parent 76a83cc commit 629b074
Show file tree
Hide file tree
Showing 14 changed files with 2,165 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export(elsevier_article)
export(ieee_article)
export(jss_article)
export(mdpi_article)
export(mnras_article)
export(peerj_article)
export(plos_article)
export(pnas_article)
Expand Down
29 changes: 29 additions & 0 deletions R/mnras_article.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#' Monthly Notices of the Royal Astronomical Society (MNRAS) Journal format.
#'
#' Format for creating an Monthly Notices of Royal Astronomical Society (MNRAS) Journal articles.
#' Adapted from
#' \href{https://www.ras.org.uk/news-and-press/2641-new-version-of-the-mnras-latex-package}{https://www.ras.org.uk/news-and-press/2641-new-version-of-the-mnras-latex-package}.
#'
#' @inheritParams rmarkdown::pdf_document
#' @param ... 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 = "mnras_article", package = "rticles")
#' }
#'
#' @export
mnras_article <- function(...,
keep_tex = TRUE,
md_extensions = c(),
fig_caption = TRUE) {
pdf_document_format(...,
keep_tex = keep_tex,
md_extensions = md_extensions,
format = "mnras_article",
template = "template.tex",
csl = "mnras.csl")
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ The **rticles** package provides a suite of custom [R Markdown](http://rmarkdown

- [Springer](https://www.springer.com/gp/livingreviews/latex-templates) journal submissions

- [NNRAS](https://www.ras.org.uk/news-and-press/2641-new-version-of-the-mnras-latex-package) journal submissions

Under the hood, LaTeX templates are used to ensure that documents conform precisely to submission standards. At the same time, composition and formatting can be done using lightweight [markdown](http://rmarkdown.rstudio.com/authoring_basics.html) syntax, and R code and its output can be seamlessly included using [knitr](http://yihui.name/knitr/).

Using **rticles** requires the prerequisites described below. You can get most of these automatically by installing the latest release of RStudio (instructions for using **rticles** without RStudio are also provided).
Expand Down
2 changes: 2 additions & 0 deletions inst/rmarkdown/templates/mnras_article/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pdf
*.tex
13 changes: 13 additions & 0 deletions inst/rmarkdown/templates/mnras_article/resources/mnras.csl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0">
<info>
<title>Harvard reference format 1 (deprecated)</title>
<id>http://www.zotero.org/styles/harvard1</id>
<link href="http://www.zotero.org/styles/harvard1" rel="self"/>
<link href="http://www.zotero.org/styles/harvard-cite-them-right" rel="independent-parent"/>
<category citation-format="author-date"/>
<summary>The original "harvard1.csl" independent CSL style was not based on any style guide, but it nevertheless remained popular because it was included by default in Mendeley Desktop. We have now taken one step to remove this style from the central CSL repository by turning it into a dependent style that uses the Harvard author-date format specified by the popular "Cite Them Right" guide. This dependent style will likely be removed from the CSL repository entirely at some point in the future.</summary>
<updated>2017-04-03T00:20:53+00:00</updated>
<rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
</info>
</style>
131 changes: 131 additions & 0 deletions inst/rmarkdown/templates/mnras_article/resources/template.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
% mnras_template.tex
%
% LaTeX template for creating an MNRAS paper
%
% v3.0 released 14 May 2015
% (version numbers match those of mnras.cls)
%
% Copyright (C) Royal Astronomical Society 2015
% Authors:
% Keith T. Smith (Royal Astronomical Society)

% Change log
%
% v3.0 May 2015
% Renamed to match the new package name
% Version number matches mnras.cls
% A few minor tweaks to wording
% v1.0 September 2013
% Beta testing only - never publicly released
% First version: a simple (ish) template for creating an MNRAS paper

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Basic setup. Most papers should leave these options alone.
\documentclass[a4paper,fleqn,usenatbib]{mnras}

% MNRAS is set in Times font. If you don't have this installed (most LaTeX
% installations will be fine) or prefer the old Computer Modern fonts, comment
% out the following line
\usepackage{newtxtext,newtxmath}
% Depending on your LaTeX fonts installation, you might get better results with one of these:
%\usepackage{mathptmx}
%\usepackage{txfonts}

% Use vector fonts, so it zooms properly in on-screen viewing software
% Don't change these lines unless you know what you are doing
\usepackage[T1]{fontenc}
\usepackage{ae,aecompl}


%%%%% AUTHORS - PLACE YOUR OWN PACKAGES HERE %%%%%

% Only include extra packages if you really need them. Common packages are:
\usepackage{graphicx} % Including figure files
\usepackage{amsmath} % Advanced maths commands
\usepackage{amssymb} % Extra maths symbols
\usepackage{hyperref}
\usepackage{url}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%% AUTHORS - PLACE YOUR OWN COMMANDS HERE %%%%%

% Please keep new commands to a minimum, and use \newcommand not \def to avoid
% overwriting existing commands. Example:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%% TITLE PAGE %%%%%%%%%%%%%%%%%%%

% Title of the paper, and the short title which is used in the headers.
% Keep the title short and informative.
$if(title)$
\title$if(shorttitle)$[$shorttitle$]$endif${$title$}
$endif$

% The list of authors, and the short list which is used in the headers.
% If you need two or more lines of authors, add an extra line using \newauthor

$if(authors)$
\author$if(shortauthor)$[$shortauthor$]$endif${
$for(authors)$
$authors.name$
$if(authors.email)$
\thanks{$authors.email$}
$endif$
$if(authors.affiliations)$
$$^{$for(authors.affiliations)$$authors.affiliations$$sep$,$endfor$}$$
$endif$
$endfor$\\
$if(affiliations)$
$for(affiliations)$
$$^{$affiliations.number$}$$$affiliations.name$$sep$\\
$endfor$
$endif$
}
$endif$

% These dates will be filled out by the publisher
\date{Accepted XXX. Received YYY; in original form ZZZ}

% Enter the current year, for the copyright statements etc.
\pubyear{2018}

% Don't change these lines
\begin{document}
\label{firstpage}
\pagerange{\pageref{firstpage}--\pageref{lastpage}}
$if(title)$
\maketitle
$endif$

% Abstract of the paper
$if(abstract)$
\begin{abstract}
$abstract$
\end{abstract}
$endif$

% Select between one and six entries from the list of approved keywords.
% Don't make up new ones.
$if(keywords)$
\begin{keywords}
$for(keywords)$$keywords$$sep$ -- $endfor$
\end{keywords}
$endif$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%% BODY OF PAPER %%%%%%%%%%%%%%%%%%

$body$

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Don't change these lines
\bsp % typesetting comment
\label{lastpage}
\end{document}

% End of mnras_template.tex
3 changes: 3 additions & 0 deletions inst/rmarkdown/templates/mnras_article/skeleton/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# pandoc-mnras

A template for building MNRAS Journal articles in pandoc.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 629b074

Please sign in to comment.