diff --git a/DESCRIPTION b/DESCRIPTION index 742a80e9d..2bb97be6e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -108,5 +108,5 @@ Config/Needs/website: magick, pdftools, gifski, tidyverse/tidytemplate, Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 SystemRequirements: GNU make diff --git a/NAMESPACE b/NAMESPACE index 8929ca591..cffebc18a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -37,7 +37,6 @@ export(peerj_article) export(pihph_article) export(plos_article) export(pnas_article) -export(rjournal_article) export(rsos_article) export(rss_article) export(sage_article) diff --git a/R/rjournal_article.R b/R/rjournal_article.R index be76521aa..e0721c8b9 100644 --- a/R/rjournal_article.R +++ b/R/rjournal_article.R @@ -3,169 +3,12 @@ #' @description #' `r lifecycle::badge('deprecated')` #' -#' This function is now deprecated in favor of the [**rjtools**](https://rjournal.github.io/rjtools/) package -#' which is now officialy recommanded by R Journal . See below for document +#' This function is now defunct in favor of the [**rjtools**](https://rjournal.github.io/rjtools/) package +#' which is now officialy recommanded by R Journal . #' -#' @details # About this format and the R Journal requirements -#' -#' Format for creating R Journal articles. Adapted from -#' . -#' -#' This file is only a basic article template. For full details of _The R -#' Journal_ style and information on how to prepare your article for submission, -#' see the [Instructions for Authors](https://journal.r-project.org/share/author-guide.pdf) -#' - -#' -#' `rticles::rjournal_article` will help you build the correct files requirements: -#' -#' - A R file will be generated automatically using `knitr::purl` - see -#' https://bookdown.org/yihui/rmarkdown-cookbook/purl.html for more information. -#' - A tex file will be generated from this Rmd file and correctly included in -#' `RJwapper.tex` as expected to build `RJwrapper.pdf`. -#' - All figure files will be kept in the default rmarkdown `*_files` folder. This -#' happens because `keep_tex = TRUE` by default in `rticles::rjournal_article` -#' - Only the bib filename is to be modified. An example bib file is included in the -#' template (`RJreferences.bib`) and you will have to name your bib file as the -#' tex, R, and pdf files. -#' -#' # About YAML header fields -#' -#' This section documents some of the YAML fields that can be used with this -#' formats. -#' -#' ## The `author` field in the YAML header -#' -#' | FIELD | TYPE | DESCRIPTION | -#' | ------ | ---- | ----------- | -#' | `name` | *required* | name and surname of the author | -#' | `affiliation` | *required* | name of the author's affiliation | -#' | `address` | *required* | at least one address line for the affiliation | -#' | `url` | *optional* | an additional url for the author or the main affiliation | -#' | `orcid` | *optional* | the authors ORCID if available | -#' | `email` | *required* | the author's e-mail address | -#' | `affiliation2` | *optional* | name of the author's 2nd affiliation | -#' | `address2` | *optional* | address lines belonging to the author's 2nd affiliation | -#' -#' *Please note: Only one `url`, `orcid` and `email` can be provided per author.* -#' -#' ## Other YAML fields -#' -#' | FIELD | TYPE | DESCRIPTION | -#' | ----- | ---- | ----------- | -#' | `bibliography` | *with default* | the BibTeX file with the reference entries | -#' -#' @inheritParams rmarkdown::pdf_document -#' @param ... Arguments to [rmarkdown::pdf_document()]. -#' @export +#' @keywords internal rjournal_article <- function(..., keep_tex = TRUE, citation_package = "natbib") { - lifecycle::deprecate_warn("0.25", "rjournal_article()", "rjtools::rjournal_pdf_article()", details = "See official recommandation at https://rjournal.github.io/submissions.html") - rmarkdown::pandoc_available("2.2", TRUE) - - base <- pdf_document_format( - "rjournal", - highlight = NULL, citation_package = citation_package, - keep_tex = keep_tex, ... - ) - - # Render will generate tex file, post-knit hook gerenates the R file, - # post-process hook generates appropriate RJwrapper.tex and - # use pandoc to build pdf from that - base$pandoc$to <- "latex" - base$pandoc$ext <- ".tex" - - # Generates R file expected by R journal requirement. - # We do that in the post-knit hook do access input file path. - pk <- base$post_knit - output_R <- NULL - base$post_knit <- function(metadata, input_file, runtime, ...) { - # run post_knit it exists - if (is.function(pk)) pk(metadata, input_file, runtime, ...) - - # purl the Rmd file to R code per requirement - temp_R <- tempfile(fileext = ".R") - output_R <<- knitr::purl(input_file, temp_R, documentation = 1, quiet = TRUE) - # Add magic comment about '"do not edit" (rstudio/rstudio#2082) - xfun::write_utf8(c( - "# Generated by `rjournal_article()` using `knitr::purl()`: do not edit by hand", - sprintf("# Please edit %s to modify this file", input_file), - "", - xfun::read_utf8(output_R) - ), output_R) - - NULL - } - - base$post_processor <- function(metadata, utf8_input, output_file, clean, verbose) { - filename <- basename(output_file) - # underscores in the filename will be problematic in \input{filename}; - # pandoc will escape underscores but it should not, i.e., should be - # \input{foo_bar} instead of \input{foo\_bar} - if (filename != (filename2 <- gsub("_", "-", filename))) { - file.rename(filename, filename2) - filename <- filename2 - } - - # Copy purl-ed R file with the correct name - dest_file <- xfun::with_ext(filename, "R") - our_file <- TRUE - if (file.exists(dest_file)) { - # we check this file is generated by us - # otherwise we leave it as is and warn - current_r <- xfun::read_utf8(dest_file) - our_file <- grepl("Generated.*rjournal_article.*do not edit by hand", current_r[1]) - if (!our_file) { - warning( - sprintf("R file with name '%s' already exists.", dest_file), - "\nIt will not be overwritten by the one generated", - " during rendering using `knitr::purl()`.", - "\nRemove the existing file to obtain the generated one.", - call. = FALSE - ) - } - } - if (our_file) { - # we only overwrite if it is our file - file.copy(output_R, xfun::with_ext(filename, "R"), overwrite = TRUE) - } - unlink(output_R) - - # post process TEX file - temp_tex <- xfun::read_utf8(filename) - temp_tex <- post_process_authors(temp_tex) - xfun::write_utf8(temp_tex, filename) - - # check bibliography name - bib_filename <- metadata$bibliography - if (length(bib_filename) == 1 && - xfun::sans_ext(bib_filename) != xfun::sans_ext(filename)) { - msg <- paste0( - "Per R journal requirement, bibliography file and tex file should", - " have the same name. Currently, you have a bib file ", bib_filename, - " and a tex file ", filename, ". Don't forget to rename and change", - " the bibliography field in the YAML header." - ) - warning(msg, call. = FALSE) - } - - # Create RJwrapper.tex per R Journal requirement - m <- list(filename = xfun::sans_ext(filename)) - h <- get_list_element(metadata, c("output", "rticles::rjournal_article", "includes", "in_header")) - h <- c(h, if (length(preamble <- unlist(metadata[c("preamble", "header-includes")]))) { - f <- tempfile(fileext = ".tex") - on.exit(unlink(f), add = TRUE) - xfun::write_utf8(preamble, f) - f - }) - t <- find_resource("rjournal", "RJwrapper.tex") - template_pandoc(m, t, "RJwrapper.tex", h, verbose) - - tinytex::latexmk("RJwrapper.tex", base$pandoc$latex_engine, clean = clean) - } - - # Mostly copied from knitr::render_sweave - base$knitr$opts_chunk$comment <- "#>" + lifecycle::deprecate_stop("0.25", "rjournal_article()", "rjtools::rjournal_pdf_article()", details = "See official recommandation at https://rjournal.github.io/submissions.html") - set_sweave_hooks(base) } diff --git a/R/utils.R b/R/utils.R index 70d6adaa2..5db5f63b8 100644 --- a/R/utils.R +++ b/R/utils.R @@ -5,7 +5,7 @@ #' These names can be useful in two ways: #' #' * You can add `_article` suffix to get the name of the output format (e.g., -#' [rjournal_article()]). +#' [jss_article()]). #' #' * You can use the name directly in the `template` argument of #' [rmarkdown::draft()]. @@ -47,13 +47,6 @@ merge_list <- function(x, y) { #' @param output Path to save output. #' @param in_header Paths to files to include in the header. #' @return (Invisibly) The path of the generate file. -#' @examples -#' x <- rticles:::template_pandoc( -#' list(preamble = "%abc", filename = "wickham"), -#' rticles:::find_resource("rjournal", "RJwrapper.tex"), -#' tempfile() -#' ) -#' if (interactive()) file.show(x) #' @noRd template_pandoc <- function(metadata, template, output, in_header = NULL, verbose = FALSE) { diff --git a/inst/rmarkdown/templates/rjournal/resources/RJwrapper.tex b/inst/rmarkdown/templates/rjournal/resources/RJwrapper.tex deleted file mode 100644 index f96e6bb6b..000000000 --- a/inst/rmarkdown/templates/rjournal/resources/RJwrapper.tex +++ /dev/null @@ -1,170 +0,0 @@ -\documentclass[a4paper]{report} -\usepackage[utf8]{inputenc} -\usepackage[T1]{fontenc} -\usepackage{RJournal} -\usepackage{amsmath,amssymb,array} -\usepackage{booktabs} - -$if(highlighting-macros)$ -% Pandoc syntax highlighting -$highlighting-macros$ -$endif$ - -% tightlist command for lists without linebreak -\providecommand{\tightlist}{% - \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} - -$if(tables)$ -% From pandoc table feature -\usepackage{longtable,booktabs,array} -$if(pandoc3821)$\newcounter{none} % for unnumbered tables -$endif$ -$if(multirow)$ -\usepackage{multirow} -$endif$ -\usepackage{calc} % for calculating minipage widths -% Correct order of tables after \paragraph or \subparagraph -\usepackage{etoolbox} -\makeatletter -\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{} -\makeatother -% Allow footnotes in longtable head/foot -\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}} -\makesavenoteenv{longtable} -$endif$ - -% Add imagehandling -$-- Only needed for pandoc 3.2.1 and above requiring graphics for new command. -$if(graphics)$$if(pandoc321)$ -% Custom command from Pandoc 3.2.1 to scale images if necessary -\usepackage{graphicx} -\makeatletter -\newsavebox\pandoc@box -\newcommand*\pandocbounded[1]{% scales image to fit in text height/width - \sbox\pandoc@box{#1}% - \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}% - \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}% - \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both - \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}% - \else\usebox{\pandoc@box}% - \fi% -} -\makeatother -$endif$$endif$ - -$if(csl-refs)$ -% Pandoc citation processing -$if(pandoc318)$ -%From Pandoc 3.1.8 -% definitions for citeproc citations -\NewDocumentCommand\citeproctext{}{} -\NewDocumentCommand\citeproc{mm}{% - \begingroup\def\citeproctext{#2}\cite{#1}\endgroup} -\makeatletter - % allow citations to break across lines - \let\@cite@ofmt\@firstofone - % avoid brackets around text for \cite: - \def\@biblabel#1{} - \def\@cite#1#2{{#1\if@tempswa , #2\fi}} -\makeatother -\newlength{\cslhangindent} -\setlength{\cslhangindent}{1.5em} -\newlength{\csllabelwidth} -\setlength{\csllabelwidth}{3em} -\newenvironment{CSLReferences}[2] % #1 hanging-indent, #2 entry-spacing - {\begin{list}{}{% - \setlength{\itemindent}{0pt} - \setlength{\leftmargin}{0pt} - \setlength{\parsep}{0pt} - % turn on hanging indent if param 1 is 1 - \ifodd #1 - \setlength{\leftmargin}{\cslhangindent} - \setlength{\itemindent}{-1\cslhangindent} - \fi - % set entry spacing - \setlength{\itemsep}{#2\baselineskip}}} - {\end{list}} -$else$$if(pandoc317)$ -% definitions for citeproc citations -\NewDocumentCommand\citeproctext{}{} -\NewDocumentCommand\citeproc{mm}{% - \begingroup\def\citeproctext{#2}\cite{#1}\endgroup} -% avoid brackets around text for \cite: -\makeatletter - \def\@biblabel#1{} - \def\@cite#1#2{{#1\if@tempswa , #2\fi}} -\makeatother -\newlength{\cslhangindent} -\setlength{\cslhangindent}{1.5em} -\newlength{\csllabelwidth} -\setlength{\csllabelwidth}{3em} -\newlength{\cslentryspacing} -\setlength{\cslentryspacing}{0em} -\usepackage{enumitem} -\newlist{CSLReferences}{itemize}{1} -\setlist[CSLReferences]{label={}, - leftmargin=\cslhangindent, - itemindent=-1\cslhangindent, - parsep=\parskip, - itemsep=\cslentryspacing} -$else$ -\newlength{\cslhangindent} -\setlength{\cslhangindent}{1.5em} -\newlength{\csllabelwidth} -\setlength{\csllabelwidth}{3em} -\newlength{\cslentryspacingunit} % times entry-spacing -\setlength{\cslentryspacingunit}{\parskip} -% for Pandoc 2.8 to 2.10.1 -\newenvironment{cslreferences}% - {$if(csl-hanging-indent)$\setlength{\parindent}{0pt}% - \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces$endif$}% - {\par} -% For Pandoc 2.11+ -\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing - {% don't indent paragraphs - \setlength{\parindent}{0pt} - % turn on hanging indent if param 1 is 1 - \ifodd #1 - \let\oldpar\par - \def\par{\hangindent=\cslhangindent\oldpar} - \fi - % set entry spacing - \setlength{\parskip}{#2\cslentryspacingunit} - }% - {} -$endif$$endif$ -\usepackage{calc} -\newcommand{\CSLBlock}[1]{#1\hfill\break} -\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}} -\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break} -\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1} -$endif$ - -$for(header-includes)$ -$header-includes$ -$endfor$ - -\begin{document} - -$for(include-before)$ -$include-before$ - -$endfor$ - -%% do not edit, for illustration only -\sectionhead{Contributed research article} -\volume{XX} -\volnumber{YY} -\year{20ZZ} -\month{AAAA} - -\begin{article} - \input{$filename$} -\end{article} - -$for(include-after)$ -$include-after$ - -$endfor$ - -\end{document} diff --git a/inst/rmarkdown/templates/rjournal/resources/template.tex b/inst/rmarkdown/templates/rjournal/resources/template.tex deleted file mode 100644 index 49e42eb0a..000000000 --- a/inst/rmarkdown/templates/rjournal/resources/template.tex +++ /dev/null @@ -1,33 +0,0 @@ -% !TeX root = RJwrapper.tex -\title{$title$} -\author{by $for(author)$$author.name$$sep$, $endfor$} - -\maketitle - -$if(abstract)$ -\abstract{% -$abstract$ -} -$endif$ - -$body$ - -$if(bibliography)$ -\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} -$endif$ - -$for(author)$ -\address{% -$author.name$\\ -$author.affiliation$\\% -$for(author.address)$$author.address$$sep$\\ $endfor$\\ -$if(author.affiliation2)$ -$author.affiliation2$\\% -$for(author.address2)$$author.address2$$sep$\\ $endfor$\\ -$endif$% -$if(author.url)$$author.url$\\$endif$% -$if(author.orcid)$\textit{ORCiD: \href{https://orcid.org/$author.orcid$}{$author.orcid$}}\\$endif$% -$if(author.email)$$author.email$$endif$% -} - -$endfor$ diff --git a/inst/rmarkdown/templates/rjournal/skeleton/RJournal.sty b/inst/rmarkdown/templates/rjournal/skeleton/RJournal.sty deleted file mode 100644 index 160054510..000000000 --- a/inst/rmarkdown/templates/rjournal/skeleton/RJournal.sty +++ /dev/null @@ -1,343 +0,0 @@ -% Package `RJournal' to use with LaTeX2e -% Copyright (C) 2010 by the R Foundation -% Copyright (C) 2013 by the R Journal -% -% Originally written by Kurt Hornik and Friedrich Leisch with subsequent -% edits by the editorial board -% -% CAUTION: -% Do not modify this style file. Any changes to this file will be reset when your -% article is submitted. -% If you must modify the style or add LaTeX packages to the article, these -% should be specified in RJwrapper.tex - -\NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesPackage{RJournal}[2022/06/27 v0.14 RJournal package] - -\RequirePackage{tikz} - -% Overall page layout, fonts etc ----------------------------------------------- - -% Issues of of \emph{The R Journal} are created from the standard \LaTeX{} -% document class \pkg{report}. - -\RequirePackage{geometry} -\geometry{a4paper, - textwidth=14cm, top=1cm, bottom=1cm, - includehead,includefoot,centering, - footskip=1.5cm} -\raggedbottom - -\RequirePackage{fancyhdr} -\fancyhead{} -\fancyheadoffset{2cm} -\fancyhead[L]{\textsc{\RJ@sectionhead}} -\fancyhead[R]{\thepage} -\fancyfoot{} -\fancyfoot[L]{The R Journal Vol. \RJ@volume/\RJ@number, \RJ@month~\RJ@year} -\fancyfoot[R]{ISSN 2073-4859} -\pagestyle{fancy} - -% We use the following fonts (all with T1 encoding): -% -% rm & palatino -% tt & inconsolata -% sf & helvetica -% math & palatino - -\RequirePackage{microtype} - -\RequirePackage[scaled=0.92]{helvet} -\RequirePackage{palatino,mathpazo} -\RequirePackage[scaled=1.02]{inconsolata} -\RequirePackage[T1]{fontenc} - -\RequirePackage[hyphens]{url} -\RequirePackage[pagebackref]{hyperref} -\renewcommand{\backref}[1]{[p#1]} - -% Dark blue colour for all links -\RequirePackage{color} -\definecolor{link}{rgb}{0.45,0.51,0.67} -\hypersetup{ - colorlinks,% - citecolor=link,% - filecolor=link,% - linkcolor=link,% - urlcolor=link -} - -% Give the text a little room to breath -\setlength{\parskip}{3pt} -\RequirePackage{setspace} -\setstretch{1.05} - -% Issue and article metadata --------------------------------------------------- - -% Basic front matter information about the issue: volume, number, and -% date. - -\newcommand{\volume}[1]{\def\RJ@volume{#1}} -\newcommand{\volnumber}[1]{\def\RJ@number{#1}} -\renewcommand{\month}[1]{\def\RJ@month{#1}} -\renewcommand{\year}[1]{\def\RJ@year{#1}} - - -% Individual articles correspond to -% chapters, and are contained in |article| environments. This makes it -% easy to have figures counted within articles and hence hyperlinked -% correctly. - -% An article has an author, a title, and optionally a subtitle. We use -% the obvious commands for specifying these. Articles will be put in certain -% journal sections, named by \sectionhead. - -\newcommand {\sectionhead} [1]{\def\RJ@sectionhead{#1}} -\renewcommand{\author} [1]{\def\RJ@author{#1}} -\renewcommand{\title} [1]{\def\RJ@title{#1}} -\newcommand {\subtitle} [1]{\def\RJ@subtitle{#1}} - -% Control appearance of titles: make slightly smaller than usual, and -% suppress section numbering. See http://tex.stackexchange.com/questions/69749 -% for why we don't use \setcounter{secnumdepth}{-1} - -\usepackage[medium]{titlesec} -\usepackage{titletoc} -\titleformat{\section} {\normalfont\large\bfseries}{\arabic{section}}{1em}{} -\titleformat{\subsection}{\normalfont\normalsize\bfseries}{}{0em}{} -\titlecontents{chapter} [0em]{}{}{}{\titlerule*[1em]{.}\contentspage} - -% Article layout --------------------------------------------------------------- - -% Environment |article| clears the article header information at its beginning. -% We use |\FloatBarrier| from the placeins package to keep floats within -% the article. -\RequirePackage{placeins} -\newenvironment{article}{\author{}\title{}\subtitle{}\FloatBarrier}{\FloatBarrier} - -% Refereed articles should have an abstract, so we redefine |\abstract| to -% give the desired style - -\renewcommand{\abstract}[1]{% -\setstretch{1}% -\noindent% -\small% -\textbf{Abstract} #1 -} - -% The real work is done by a redefined version of |\maketitle|. Note -% that even though we do not want chapters (articles) numbered, we -% need to increment the chapter counter, so that figures get correct -% labelling. - -\renewcommand{\maketitle}{% -\noindent - \chapter{\RJ@title}\refstepcounter{chapter} - \ifx\empty\RJ@subtitle - \else - \noindent\textbf{\RJ@subtitle} - \par\nobreak\addvspace{\baselineskip} - \fi - \ifx\empty\RJ@author - \else - \noindent\textit{\RJ@author} - \par\nobreak\addvspace{\baselineskip} - \fi - \@afterindentfalse\@nobreaktrue\@afterheading -} - -% Now for some ugly redefinitions. We do not want articles to start a -% new page. (Actually, we do, but this is handled via explicit -% \newpage -% -% The name@of@eq is a hack to get hyperlinks to equations to work -% within each article, even though there may be multiple eq.(1) -% \begin{macrocode} -\renewcommand\chapter{\secdef\RJ@chapter\@schapter} -\providecommand{\nohyphens}{% - \hyphenpenalty=10000\exhyphenpenalty=10000\relax} -\newcommand{\RJ@chapter}{% - \edef\name@of@eq{equation.\@arabic{\c@chapter}}% - \renewcommand{\@seccntformat}[1]{}% - \@startsection{chapter}{0}{0mm}{% - -2\baselineskip \@plus -\baselineskip \@minus -.2ex}{\p@}{% - \phantomsection\normalfont\huge\bfseries\raggedright}} - -% Book reviews should appear as sections in the text and in the pdf bookmarks, -% however we wish them to appear as chapters in the TOC. Thus we define an -% alternative to |\maketitle| for reviews. -\newcommand{\review}[1]{ - \pdfbookmark[1]{#1}{#1} - \section*{#1} - \addtocontents{toc}{\protect\contentsline{chapter}{#1}{\thepage}{#1.1}} -} - -% We want bibliographies as starred sections within articles. -% -\RequirePackage[sectionbib,round]{natbib} -\bibliographystyle{abbrvnat} - -% Equations, figures and tables are counted within articles, but we do -% not show the article number. For equations it becomes a bit messy to avoid -% having hyperref getting it wrong. - -% \numberwithin{equation}{chapter} -\renewcommand{\theequation}{\@arabic\c@equation} -\renewcommand{\thefigure}{\@arabic\c@figure} -\renewcommand{\thetable}{\@arabic\c@table} - -% Issue layout ----------------------------------------------------------------- - -% Need to provide our own version of |\tableofcontents|. We use the -% tikz package to get the rounded rectangle. Notice that |\section*| -% is really the same as |\chapter*|. -\renewcommand{\contentsname}{Contents} -\renewcommand\tableofcontents{% - \vspace{1cm} - \section*{\contentsname} - { \@starttoc{toc} } -} - -\renewcommand{\titlepage}{% - \thispagestyle{empty} - \hypersetup{ - pdftitle={The R Journal Volume \RJ@volume/\RJ@number, \RJ@month \RJ@year},% - pdfauthor={R Foundation for Statistical Computing},% - } - \noindent - \begin{center} - \fontsize{50pt}{50pt}\selectfont - The \raisebox{-8pt}{\includegraphics[height=77pt]{Rlogo-5}}\hspace{10pt} - Journal - - \end{center} - {\large \hfill Volume \RJ@volume/\RJ@number, \RJ@month{} \RJ@year \quad} - - \rule{\textwidth}{1pt} - \begin{center} - {\Large A peer-reviewed, open-access publication of the \\ - R Foundation for Statistical Computing} - \end{center} - - % And finally, put in the TOC box. Note the way |tocdepth| is adjusted - % before and after producing the TOC: thus, we can ensure that only - % articles show up in the printed TOC, but that in the PDF version, - % bookmarks are created for sections and subsections as well (provided - % that the non-starred forms are used). - \setcounter{tocdepth}{0} - \tableofcontents - \setcounter{tocdepth}{2} - \clearpage -} - -% Text formatting -------------------------------------------------------------- - -\newcommand{\R}{R} -\newcommand{\address}[1]{\addvspace{\baselineskip}\noindent\emph{#1}} -\newcommand{\email}[1]{\href{mailto:#1}{\normalfont\texttt{#1}}} - -% Simple font selection is not good enough. For example, |\texttt{--}| -% gives `\texttt{--}', i.e., an endash in typewriter font. Hence, we -% need to turn off ligatures, which currently only happens for commands -% |\code| and |\samp| and the ones derived from them. Hyphenation is -% another issue; it should really be turned off inside |\samp|. And -% most importantly, \LaTeX{} special characters are a nightmare. E.g., -% one needs |\~{}| to produce a tilde in a file name marked by |\file|. -% Perhaps a few years ago, most users would have agreed that this may be -% unfortunate but should not be changed to ensure consistency. But with -% the advent of the WWW and the need for getting `|~|' and `|#|' into -% URLs, commands which only treat the escape and grouping characters -% specially have gained acceptance - -\DeclareRobustCommand\code{\bgroup\@noligs\@codex} -\def\@codex#1{\texorpdfstring% -{{\normalfont\ttfamily\hyphenchar\font=-1 #1}}% -{#1}\egroup} -\newcommand{\kbd}[1]{{\normalfont\texttt{#1}}} -\newcommand{\key}[1]{{\normalfont\texttt{\uppercase{#1}}}} -\DeclareRobustCommand\samp{`\bgroup\@noligs\@sampx} -\def\@sampx#1{{\normalfont\texttt{#1}}\egroup'} -\newcommand{\var}[1]{{\normalfont\textsl{#1}}} -\let\env=\code -\newcommand{\file}[1]{{`\normalfont\textsf{#1}'}} -\let\command=\code -\let\option=\samp -\newcommand{\dfn}[1]{{\normalfont\textsl{#1}}} -% \acronym is effectively disabled since not used consistently -\newcommand{\acronym}[1]{#1} -\newcommand{\strong}[1]{\texorpdfstring% -{{\normalfont\fontseries{b}\selectfont #1}}% -{#1}} -\let\pkg=\strong -\newcommand{\CRANpkg}[1]{\href{https://CRAN.R-project.org/package=#1}{\pkg{#1}}}% -\let\cpkg=\CRANpkg -\newcommand{\ctv}[1]{\href{https://CRAN.R-project.org/view=#1}{\emph{#1}}} -\newcommand{\BIOpkg}[1]{\href{https://www.bioconductor.org/packages/release/bioc/html/#1.html}{\pkg{#1}}} - -% Example environments --------------------------------------------------------- -\RequirePackage{fancyvrb} -\RequirePackage{alltt} - -\DefineVerbatimEnvironment{example}{Verbatim}{} -\renewenvironment{example*}{\begin{alltt}}{\end{alltt}} - -% Support for output from Sweave, and generic session style code -% These used to have fontshape=sl for Sinput/Scode/Sin, but pslatex -% won't use a condensed font in that case. - -% Update (2015-05-28 by DS): remove fontsize=\small to match example environment - -\DefineVerbatimEnvironment{Sinput}{Verbatim}{} -\DefineVerbatimEnvironment{Soutput}{Verbatim}{} -\DefineVerbatimEnvironment{Scode}{Verbatim}{} -\DefineVerbatimEnvironment{Sin}{Verbatim}{} -\DefineVerbatimEnvironment{Sout}{Verbatim}{} -\newenvironment{Schunk}{}{} - -% Mathematics ------------------------------------------------------------------ - -% The implementation of |\operatorname| is similar to the mechanism -% \LaTeXe{} uses for functions like sin and cos, and simpler than the -% one of \AmSLaTeX{}. We use |\providecommand| for the definition in -% order to keep the one of the \pkg{amstex} if this package has -% already been loaded. -% \begin{macrocode} -\providecommand{\operatorname}[1]{% - \mathop{\operator@font#1}\nolimits} -\RequirePackage{amsfonts} - -\renewcommand{\P}{% - \mathop{\operator@font I\hspace{-1.5pt}P\hspace{.13pt}}} -\newcommand{\E}{% - \mathop{\operator@font I\hspace{-1.5pt}E\hspace{.13pt}}} -\newcommand{\VAR}{\operatorname{var}} -\newcommand{\COV}{\operatorname{cov}} -\newcommand{\COR}{\operatorname{cor}} - -% Figures ---------------------------------------------------------------------- - -\RequirePackage[font=small,labelfont=bf]{caption} - -% Wide environments for figures and tables ------------------------------------- -\RequirePackage{environ} - -% An easy way to make a figure span the full width of the page -\NewEnviron{widefigure}[1][]{ -\begin{figure}[#1] -\advance\leftskip-2cm -\begin{minipage}{\dimexpr\textwidth+4cm\relax}% - \captionsetup{margin=2cm} - \BODY -\end{minipage}% -\end{figure} -} - -\NewEnviron{widetable}[1][]{ -\begin{table}[#1] -\advance\leftskip-2cm -\begin{minipage}{\dimexpr\textwidth+4cm\relax}% - \captionsetup{margin=2cm} - \BODY -\end{minipage}% -\end{table} -} diff --git a/inst/rmarkdown/templates/rjournal/skeleton/RJreferences.bib b/inst/rmarkdown/templates/rjournal/skeleton/RJreferences.bib deleted file mode 100644 index f5d901444..000000000 --- a/inst/rmarkdown/templates/rjournal/skeleton/RJreferences.bib +++ /dev/null @@ -1,18 +0,0 @@ -@Manual{R, - title = {R: A Language and Environment for Statistical Computing}, - author = {{R Core Team}}, - organization = {R Foundation for Statistical Computing}, - address = {Vienna, Austria}, - year = {2012}, - note = {{ISBN} 3-900051-07-0}, - url = {http://www.R-project.org/}, -} - -@article{ihaka:1996, - Author = {Ihaka, Ross and Gentleman, Robert}, - Journal = {Journal of Computational and Graphical Statistics}, - Number = 3, - Pages = {299--314}, - Title = {R: A Language for Data Analysis and Graphics}, - Volume = 5, - Year = 1996} diff --git a/inst/rmarkdown/templates/rjournal/skeleton/Rlogo-5.png b/inst/rmarkdown/templates/rjournal/skeleton/Rlogo-5.png deleted file mode 100644 index 077505788..000000000 Binary files a/inst/rmarkdown/templates/rjournal/skeleton/Rlogo-5.png and /dev/null differ diff --git a/inst/rmarkdown/templates/rjournal/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/rjournal/skeleton/skeleton.Rmd deleted file mode 100644 index 55258e638..000000000 --- a/inst/rmarkdown/templates/rjournal/skeleton/skeleton.Rmd +++ /dev/null @@ -1,82 +0,0 @@ ---- -title: Capitalized Title Here -author: - # see ?rjournal_article for more information - - name: Author One - affiliation: Affiliation - address: - - line 1 - - line 2 - url: https://journal.r-project.org - orcid: 0000-0002-9079-593X - email: author1@work - - name: Author Two - url: https://journal.r-project.org - email: author2@work - orcid: 0000-0002-9079-593X - affiliation: Affiliation 1 - address: - - line 1 affiliation 1 - - line 2 affiliation 1 - affiliation2: Affiliation 2 - address2: - - line 1 affiliation 2 - - line 2 affiliation 2 - - name: Author Three - url: https://journal.r-project.org - email: author3@work - affiliation: Affiliation - address: - - line 1 affiliation - - line 2 affiliation -abstract: > - An abstract of less than 150 words. -preamble: | - % Any extra LaTeX you need in the preamble - -# per R journal requirement, the bib filename should be the same as the output -# tex file. Don't forget to rename the bib file and change this example value. -bibliography: RJreferences.bib - -output: rticles::rjournal_article ---- - -## Introduction - -Introductory section which may include references in parentheses -[@R], or cite a reference such as @R in the text. - -## Section title in sentence case - -This section may contain a figure such as Figure \ref{fig:Rlogo}. - -```{r, Rlogo, echo=FALSE, fig.cap='The logo of R.', out.width='2in', fig.align='center', fig.pos='htbp'} -knitr::include_graphics('Rlogo-5.png') -``` - -## Another section - -There will likely be several sections, perhaps including code snippets, such as: - -```{r} -x <- 1:10 -plot(x) -``` - -## Summary - -This file is only a basic article template. For full details of _The R Journal_ style and information on how to prepare your article for submission, see the [Instructions for Authors](https://journal.r-project.org/share/author-guide.pdf). - -### About this format and the R Journal requirements - -`rticles::rjournal_article` will help you build the correct files requirements: - -* A R file will be generated automatically using `knitr::purl` - see -https://bookdown.org/yihui/rmarkdown-cookbook/purl.html for more information. -* A tex file will be generated from this Rmd file and correctly included in -`RJwapper.tex` as expected to build `RJwrapper.pdf`. -* All figure files will be kept in the default rmarkdown `*_files` folder. This -happens because `keep_tex = TRUE` by default in `rticles::rjournal_article` -* Only the bib filename is to modifed. An example bib file is included in the -template (`RJreferences.bib`) and you will have to name your bib file as the -tex, R, and pdf files. diff --git a/inst/rmarkdown/templates/rjournal/template.yaml b/inst/rmarkdown/templates/rjournal/template.yaml deleted file mode 100644 index 570a3c351..000000000 --- a/inst/rmarkdown/templates/rjournal/template.yaml +++ /dev/null @@ -1,5 +0,0 @@ -name: R Journal Submission -description: > - Template for creating articles for the R journal. -create_dir: true - diff --git a/man/journals.Rd b/man/journals.Rd index 3e3649cd0..b769bf3dd 100644 --- a/man/journals.Rd +++ b/man/journals.Rd @@ -16,7 +16,7 @@ List available journal names in this package. These names can be useful in two ways: \itemize{ \item You can add \verb{_article} suffix to get the name of the output format (e.g., -\code{\link[=rjournal_article]{rjournal_article()}}). +\code{\link[=jss_article]{jss_article()}}). \item You can use the name directly in the \code{template} argument of \code{\link[rmarkdown:draft]{rmarkdown::draft()}}. } diff --git a/man/rjournal_article.Rd b/man/rjournal_article.Rd index d509cab28..edbb01541 100644 --- a/man/rjournal_article.Rd +++ b/man/rjournal_article.Rd @@ -6,72 +6,10 @@ \usage{ rjournal_article(..., keep_tex = TRUE, citation_package = "natbib") } -\arguments{ -\item{...}{Arguments to \code{\link[rmarkdown:pdf_document]{rmarkdown::pdf_document()}}.} - -\item{keep_tex}{Keep the intermediate tex file used in the conversion to PDF. -Note that this argument does not control whether to keep the auxiliary -files (e.g., \file{.aux}) generated by LaTeX when compiling \file{.tex} to -\file{.pdf}. To keep these files, you may set \code{options(tinytex.clean = -FALSE)}.} - -\item{citation_package}{The LaTeX package to process citations, \code{natbib} -or \code{biblatex}. Use \code{default} if neither package is to be used, -which means citations will be processed via the command -\command{pandoc-citeproc}.} -} \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} -This function is now deprecated in favor of the \href{https://rjournal.github.io/rjtools/}{\strong{rjtools}} package -which is now officialy recommanded by R Journal \url{https://rjournal.github.io/submissions.html}. See below for document -} -\section{About this format and the R Journal requirements}{ -Format for creating R Journal articles. Adapted from -\url{https://journal.r-project.org/submissions.html}. - -This file is only a basic article template. For full details of \emph{The R -Journal} style and information on how to prepare your article for submission, -see the \href{https://journal.r-project.org/share/author-guide.pdf}{Instructions for Authors} - -\code{rticles::rjournal_article} will help you build the correct files requirements: -\itemize{ -\item A R file will be generated automatically using \code{knitr::purl} - see -https://bookdown.org/yihui/rmarkdown-cookbook/purl.html for more information. -\item A tex file will be generated from this Rmd file and correctly included in -\code{RJwapper.tex} as expected to build \code{RJwrapper.pdf}. -\item All figure files will be kept in the default rmarkdown \verb{*_files} folder. This -happens because \code{keep_tex = TRUE} by default in \code{rticles::rjournal_article} -\item Only the bib filename is to be modified. An example bib file is included in the -template (\code{RJreferences.bib}) and you will have to name your bib file as the -tex, R, and pdf files. -} -} - -\section{About YAML header fields}{ -This section documents some of the YAML fields that can be used with this -formats. -\subsection{The \code{author} field in the YAML header}{\tabular{lll}{ - FIELD \tab TYPE \tab DESCRIPTION \cr - \code{name} \tab \emph{required} \tab name and surname of the author \cr - \code{affiliation} \tab \emph{required} \tab name of the author's affiliation \cr - \code{address} \tab \emph{required} \tab at least one address line for the affiliation \cr - \code{url} \tab \emph{optional} \tab an additional url for the author or the main affiliation \cr - \code{orcid} \tab \emph{optional} \tab the authors ORCID if available \cr - \code{email} \tab \emph{required} \tab the author's e-mail address \cr - \code{affiliation2} \tab \emph{optional} \tab name of the author's 2nd affiliation \cr - \code{address2} \tab \emph{optional} \tab address lines belonging to the author's 2nd affiliation \cr +This function is now defunct in favor of the \href{https://rjournal.github.io/rjtools/}{\strong{rjtools}} package +which is now officialy recommanded by R Journal \url{https://rjournal.github.io/submissions.html}. } - - -\emph{Please note: Only one \code{url}, \code{orcid} and \code{email} can be provided per author.} -} - -\subsection{Other YAML fields}{\tabular{lll}{ - FIELD \tab TYPE \tab DESCRIPTION \cr - \code{bibliography} \tab \emph{with default} \tab the BibTeX file with the reference entries \cr -} - -} -} - +\keyword{internal} diff --git a/tests/testit/test-formats.R b/tests/testit/test-formats.R index 073b476a3..0b5e3f5c5 100644 --- a/tests/testit/test-formats.R +++ b/tests/testit/test-formats.R @@ -72,7 +72,6 @@ test_format("peerj") test_format("pihph") test_format("plos") test_format("pnas") -test_format("rjournal") test_format("rsos") test_format("rss") test_format("sage") diff --git a/tests/testthat/_snaps/rjournal_article.md b/tests/testthat/_snaps/rjournal_article.md index cd17d812f..994522821 100644 --- a/tests/testthat/_snaps/rjournal_article.md +++ b/tests/testthat/_snaps/rjournal_article.md @@ -1,10 +1,10 @@ -# rjournal_article() is deprecated +# rjournal_article() is defunct Code x <- rjournal_article() Condition - Warning: - `rjournal_article()` was deprecated in rticles 0.25. + Error: + ! `rjournal_article()` was deprecated in rticles 0.25 and is now defunct. i Please use `rjtools::rjournal_pdf_article()` instead. i See official recommandation at https://rjournal.github.io/submissions.html diff --git a/tests/testthat/test-check-template.R b/tests/testthat/test-check-template.R index f576f7b88..b802a4ff4 100644 --- a/tests/testthat/test-check-template.R +++ b/tests/testthat/test-check-template.R @@ -3,9 +3,6 @@ skip_on_cran() temp_file <- list.files(pkg_file_template(), recursive = TRUE, pattern = "template.tex$", full.names = TRUE) -# Rjournal template has another name -temp_file[grep("rjournal", temp_file)] <- pkg_file_template("rjournal", "resources", "RJwrapper.tex") - expect_contains <- function(file, pattern, nb = 1, at_least = NULL, ...) { content <- xfun::read_utf8(file) matched <- grepl(pattern, content, ...) diff --git a/tests/testthat/test-rjournal_article.R b/tests/testthat/test-rjournal_article.R index 9f7d2ed6e..c1fb151cb 100644 --- a/tests/testthat/test-rjournal_article.R +++ b/tests/testthat/test-rjournal_article.R @@ -1,5 +1,5 @@ -test_that("rjournal_article() is deprecated", { +test_that("rjournal_article() is defunct", { expect_snapshot({ x <- rjournal_article() - }) + }, error = TRUE) }) diff --git a/vignettes/articles/_child_examples.Rmd b/vignettes/articles/_child_examples.Rmd index 94e6b0ab0..c861f1d4d 100644 --- a/vignettes/articles/_child_examples.Rmd +++ b/vignettes/articles/_child_examples.Rmd @@ -64,11 +64,6 @@ for (journal in journals()) { path = xfun::with_ext(out_pdf, "gif"), delay = 1) message("Retrieving built files.") - # specific treatment for rjournal name - if (journal == "rjournal") { - file.rename(out_pdf, out_pdf <- file.path(dirname(out_pdf), "rjournal_article.pdf")) - file.rename(out_gif, out_gif <- file.path(dirname(out_gif), "rjournal_article.gif")) - } file.copy(out_pdf, out_dir) file.copy(out_gif, out_dir) # clean temp dir diff --git a/vignettes/usage.md b/vignettes/usage.md index b339e11fd..dabdf3ac7 100644 --- a/vignettes/usage.md +++ b/vignettes/usage.md @@ -11,9 +11,6 @@ If you are not using RStudio, you'll also need to install [Pandoc](https://pando rmarkdown::draft( "MyJSSArticle.Rmd", template = "jss", package = "rticles" ) -rmarkdown::draft( - "MyRJournalArticle", template = "rjournal", package = "rticles" -) ``` This will create a folder containing a Rmd file using the corresponding output format and all the assets required by this format.