Skip to content

Royal Society of Statistics #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export(jss_article)
export(plos_article)
export(pnas_article)
export(rjournal_article)
export(rss_article)
48 changes: 48 additions & 0 deletions R/rss_article.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#' Royal Statistical Society Journal Format
#'
#' Format for creating articles for Royal Statistical Society
#' Adapted from \url{http://www.rss.org.uk/RSS/Publications/Journals/Journals_get_involved/RSS/Publications/Journals_sub/Get_Involved.aspx}
#' @inheritParams rmarkdown::pdf_document
#' @param ... Arguments to \code{rmarkdown::pdf_document}
#'
#' @return R Markdown output format to pass to
#' \code{\link[rmarkdown:render]{render}}
#' @export
#'

rss_article <- function(...,
keep_tex = TRUE) {
fmt <- rmarkdown::pdf_document(
...,
highlight = NULL,
citation_package = "natbib",
template =
system.file("rmarkdown",
"templates",
"rss_article",
"resources",
"template.tex",
package = "rticles"),
keep_tex = keep_tex
)

fmt$inherits <- "pdf_document"
fmt$knitr$knit_hooks$source <- function(x, options) {
if (options$prompt && length(x)) {
x <- gsub("\\n", paste0("\n", getOption("continue")), x)
x <- paste0(getOption("prompt"), x)
}
paste0(
c(
'\n\\begin{lstlisting}[language=',
options$engine,
"]",
x,
'\\end{lstlisting}',
''
),
collapse = '\n'
)
}
fmt
}
51 changes: 51 additions & 0 deletions inst/rmarkdown/templates/rss_article/resources/template.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

\documentclass{statsoc}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{color}
\usepackage{amssymb, amsmath, geometry}
\usepackage{natbib}

\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}

\title[$short_title$]{$title$}

\author[$short_author$]{$author$}
\address{$affiliation$,
$city$,
$country$}
\email{$email$}

$if(author2)$
\author[$short_author$]{$author2$}
\address{$affiliation2$,
$city2$,
$country2$}
\email{$email2$}
$endif$

% BIBLIOGRAPHY
\usepackage[authoryear]{natbib}
\bibpunct{(}{)}{;}{a}{}{,}

\begin{document}

\begin{abstract}
$abstract$
\end{abstract}
$if(keywords)$
\keywords{$keywords$}
$endif$

$body$

\bibliographystyle{rss}
\bibliography{$bibliography$}
\end{document}
118 changes: 118 additions & 0 deletions inst/rmarkdown/templates/rss_article/skeleton/amssym.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@

%%% ====================================================================
%%% @TeX-file{
%%% filename = "amssym.def",
%%% version = "2.2",
%%% date = "22-Dec-1994",
%%% time = "10:14:01 EST",
%%% checksum = "28096 117 438 4924",
%%% author = "American Mathematical Society",
%%% copyright = "Copyright (C) 1994 American Mathematical Society,
%%% all rights reserved. Copying of this file is
%%% authorized only if either:
%%% (1) you make absolutely no changes to your copy,
%%% including name; OR
%%% (2) if you do make changes, you first rename it
%%% to some other name.",
%%% address = "American Mathematical Society,
%%% Technical Support,
%%% Electronic Products and Services,
%%% P. O. Box 6248,
%%% Providence, RI 02940,
%%% USA",
%%% telephone = "401-455-4080 or (in the USA and Canada)
%%% 800-321-4AMS (321-4267)",
%%% FAX = "401-331-3842",
%%% email = "[email protected] (Internet)",
%%% codetable = "ISO/ASCII",
%%% keywords = "amsfonts, msam, msbm, math symbols",
%%% supported = "yes",
%%% abstract = "This is part of the AMSFonts distribution,
%%% It is the plain TeX source file for the
%%% AMSFonts user's guide.",
%%% docstring = "The checksum field above contains a CRC-16
%%% checksum as the first value, followed by the
%%% equivalent of the standard UNIX wc (word
%%% count) utility output of lines, words, and
%%% characters. This is produced by Robert
%%% Solovay's checksum utility.",
%%% }
%%% ====================================================================
\expandafter\ifx\csname amssym.def\endcsname\relax \else\endinput\fi
%
% Store the catcode of the @ in the csname so that it can be restored later.
\expandafter\edef\csname amssym.def\endcsname{%
\catcode`\noexpand\@=\the\catcode`\@\space}
% Set the catcode to 11 for use in private control sequence names.
\catcode`\@=11
%
% Include all definitions related to the fonts msam, msbm and eufm, so that
% when this file is used by itself, the results with respect to those fonts
% are equivalent to what they would have been using AMS-TeX.
% Most symbols in fonts msam and msbm are defined using \newsymbol;
% however, a few symbols that replace composites defined in plain must be
% defined with \mathchardef.

\def\undefine#1{\let#1\undefined}
\def\newsymbol#1#2#3#4#5{\let\next@\relax
\ifnum#2=\@ne\let\next@\msafam@\else
\ifnum#2=\tw@\let\next@\msbfam@\fi\fi
\mathchardef#1="#3\next@#4#5}
\def\mathhexbox@#1#2#3{\relax
\ifmmode\mathpalette{}{\m@th\mathchar"#1#2#3}%
\else\leavevmode\hbox{$\m@th\mathchar"#1#2#3$}\fi}
\def\hexnumber@#1{\ifcase#1 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or
9\or A\or B\or C\or D\or E\or F\fi}

\font\tenmsa=msam10
\font\sevenmsa=msam7
\font\fivemsa=msam5
\newfam\msafam
\textfont\msafam=\tenmsa
\scriptfont\msafam=\sevenmsa
\scriptscriptfont\msafam=\fivemsa
\edef\msafam@{\hexnumber@\msafam}
\mathchardef\dabar@"0\msafam@39
\def\dashrightarrow{\mathrel{\dabar@\dabar@\mathchar"0\msafam@4B}}
\def\dashleftarrow{\mathrel{\mathchar"0\msafam@4C\dabar@\dabar@}}
\let\dasharrow\dashrightarrow
\def\ulcorner{\delimiter"4\msafam@70\msafam@70 }
\def\urcorner{\delimiter"5\msafam@71\msafam@71 }
\def\llcorner{\delimiter"4\msafam@78\msafam@78 }
\def\lrcorner{\delimiter"5\msafam@79\msafam@79 }
% Note that there should not be a final space after the digits for a
% \mathhexbox@.
\def\yen{{\mathhexbox@\msafam@55}}
\def\checkmark{{\mathhexbox@\msafam@58}}
\def\circledR{{\mathhexbox@\msafam@72}}
\def\maltese{{\mathhexbox@\msafam@7A}}

\font\tenmsb=msbm10
\font\sevenmsb=msbm7
\font\fivemsb=msbm5
\newfam\msbfam
\textfont\msbfam=\tenmsb
\scriptfont\msbfam=\sevenmsb
\scriptscriptfont\msbfam=\fivemsb
\edef\msbfam@{\hexnumber@\msbfam}
\def\Bbb#1{{\fam\msbfam\relax#1}}
\def\widehat#1{\setbox\z@\hbox{$\m@th#1$}%
\ifdim\wd\z@>\tw@ em\mathaccent"0\msbfam@5B{#1}%
\else\mathaccent"0362{#1}\fi}
\def\widetilde#1{\setbox\z@\hbox{$\m@th#1$}%
\ifdim\wd\z@>\tw@ em\mathaccent"0\msbfam@5D{#1}%
\else\mathaccent"0365{#1}\fi}
\font\teneufm=eufm10
\font\seveneufm=eufm7
\font\fiveeufm=eufm5
\newfam\eufmfam
\textfont\eufmfam=\teneufm
\scriptfont\eufmfam=\seveneufm
\scriptscriptfont\eufmfam=\fiveeufm
\def\frak#1{{\fam\eufmfam\relax#1}}
\let\goth\frak

% Restore the catcode value for @ that was previously saved.
\csname amssym.def\endcsname

\endinput
Loading