|
| 1 | +% Package `RJournal' to use with LaTeX2e |
| 2 | +% Copyright (C) 2010 by the R Foundation |
| 3 | +% Copyright (C) 2013 by the R Journal |
| 4 | +% |
| 5 | +% Originally written by Kurt Hornik and Friedrich Leisch with subsequent |
| 6 | +% edits by the editorial board |
| 7 | +% |
| 8 | +% CAUTION: |
| 9 | +% Do not modify this style file. Any changes to this file will be reset when your |
| 10 | +% article is submitted. |
| 11 | +% If you must modify the style or add LaTeX packages to the article, these |
| 12 | +% should be specified in RJwrapper.tex |
| 13 | + |
| 14 | +\NeedsTeXFormat{LaTeX2e}[1995/12/01] |
| 15 | +\ProvidesPackage{RJournal}[2022/06/27 v0.14 RJournal package] |
| 16 | + |
| 17 | +\RequirePackage{tikz} |
| 18 | + |
| 19 | +% Overall page layout, fonts etc ----------------------------------------------- |
| 20 | + |
| 21 | +% Issues of of \emph{The R Journal} are created from the standard \LaTeX{} |
| 22 | +% document class \pkg{report}. |
| 23 | + |
| 24 | +\RequirePackage{geometry} |
| 25 | +\geometry{a4paper, |
| 26 | + textwidth=14cm, top=1cm, bottom=1cm, |
| 27 | + includehead,includefoot,centering, |
| 28 | + footskip=1.5cm} |
| 29 | +\raggedbottom |
| 30 | + |
| 31 | +\RequirePackage{fancyhdr} |
| 32 | +\fancyhead{} |
| 33 | +\fancyheadoffset{2cm} |
| 34 | +\fancyhead[L]{\textsc{\RJ@sectionhead}} |
| 35 | +\fancyhead[R]{\thepage} |
| 36 | +\fancyfoot{} |
| 37 | +\fancyfoot[L]{The R Journal Vol. \RJ@volume/\RJ@number, \RJ@month~\RJ@year} |
| 38 | +\fancyfoot[R]{ISSN 2073-4859} |
| 39 | +\pagestyle{fancy} |
| 40 | + |
| 41 | +% We use the following fonts (all with T1 encoding): |
| 42 | +% |
| 43 | +% rm & palatino |
| 44 | +% tt & inconsolata |
| 45 | +% sf & helvetica |
| 46 | +% math & palatino |
| 47 | + |
| 48 | +\RequirePackage{microtype} |
| 49 | + |
| 50 | +\RequirePackage[scaled=0.92]{helvet} |
| 51 | +\RequirePackage{palatino,mathpazo} |
| 52 | +\RequirePackage[scaled=1.02]{inconsolata} |
| 53 | +\RequirePackage[T1]{fontenc} |
| 54 | + |
| 55 | +\RequirePackage[hyphens]{url} |
| 56 | +\RequirePackage[pagebackref]{hyperref} |
| 57 | +\renewcommand{\backref}[1]{[p#1]} |
| 58 | + |
| 59 | +% Dark blue colour for all links |
| 60 | +\RequirePackage{color} |
| 61 | +\definecolor{link}{rgb}{0.45,0.51,0.67} |
| 62 | +\hypersetup{ |
| 63 | + colorlinks,% |
| 64 | + citecolor=link,% |
| 65 | + filecolor=link,% |
| 66 | + linkcolor=link,% |
| 67 | + urlcolor=link |
| 68 | +} |
| 69 | + |
| 70 | +% Give the text a little room to breath |
| 71 | +\setlength{\parskip}{3pt} |
| 72 | +\RequirePackage{setspace} |
| 73 | +\setstretch{1.05} |
| 74 | + |
| 75 | +% Issue and article metadata --------------------------------------------------- |
| 76 | + |
| 77 | +% Basic front matter information about the issue: volume, number, and |
| 78 | +% date. |
| 79 | + |
| 80 | +\newcommand{\volume}[1]{\def\RJ@volume{#1}} |
| 81 | +\newcommand{\volnumber}[1]{\def\RJ@number{#1}} |
| 82 | +\renewcommand{\month}[1]{\def\RJ@month{#1}} |
| 83 | +\renewcommand{\year}[1]{\def\RJ@year{#1}} |
| 84 | + |
| 85 | + |
| 86 | +% Individual articles correspond to |
| 87 | +% chapters, and are contained in |article| environments. This makes it |
| 88 | +% easy to have figures counted within articles and hence hyperlinked |
| 89 | +% correctly. |
| 90 | + |
| 91 | +% An article has an author, a title, and optionally a subtitle. We use |
| 92 | +% the obvious commands for specifying these. Articles will be put in certain |
| 93 | +% journal sections, named by \sectionhead. |
| 94 | + |
| 95 | +\newcommand {\sectionhead} [1]{\def\RJ@sectionhead{#1}} |
| 96 | +\renewcommand{\author} [1]{\def\RJ@author{#1}} |
| 97 | +\renewcommand{\title} [1]{\def\RJ@title{#1}} |
| 98 | +\newcommand {\subtitle} [1]{\def\RJ@subtitle{#1}} |
| 99 | + |
| 100 | +% Control appearance of titles: make slightly smaller than usual, and |
| 101 | +% suppress section numbering. See http://tex.stackexchange.com/questions/69749 |
| 102 | +% for why we don't use \setcounter{secnumdepth}{-1} |
| 103 | + |
| 104 | +\usepackage[medium]{titlesec} |
| 105 | +\usepackage{titletoc} |
| 106 | +\titleformat{\section} {\normalfont\large\bfseries}{\arabic{section}}{1em}{} |
| 107 | +\titleformat{\subsection}{\normalfont\normalsize\bfseries}{\arabic{section}.\arabic{subsection}}{0.5em}{} |
| 108 | +\titlecontents{chapter} [0em]{}{}{}{\titlerule*[1em]{.}\contentspage} |
| 109 | + |
| 110 | +% Article layout --------------------------------------------------------------- |
| 111 | + |
| 112 | +% Environment |article| clears the article header information at its beginning. |
| 113 | +% We use |\FloatBarrier| from the placeins package to keep floats within |
| 114 | +% the article. |
| 115 | +\RequirePackage{placeins} |
| 116 | +\newenvironment{article}{\author{}\title{}\subtitle{}\FloatBarrier}{\FloatBarrier} |
| 117 | + |
| 118 | +% Refereed articles should have an abstract, so we redefine |\abstract| to |
| 119 | +% give the desired style |
| 120 | + |
| 121 | +\renewcommand{\abstract}[1]{% |
| 122 | +\setstretch{1}% |
| 123 | +\noindent% |
| 124 | +\small% |
| 125 | +\textbf{Abstract} #1 |
| 126 | +} |
| 127 | + |
| 128 | +% The real work is done by a redefined version of |\maketitle|. Note |
| 129 | +% that even though we do not want chapters (articles) numbered, we |
| 130 | +% need to increment the chapter counter, so that figures get correct |
| 131 | +% labelling. |
| 132 | + |
| 133 | +\renewcommand{\maketitle}{% |
| 134 | +\noindent |
| 135 | + \chapter{\RJ@title}\refstepcounter{chapter} |
| 136 | + \ifx\empty\RJ@subtitle |
| 137 | + \else |
| 138 | + \noindent\textbf{\RJ@subtitle} |
| 139 | + \par\nobreak\addvspace{\baselineskip} |
| 140 | + \fi |
| 141 | + \ifx\empty\RJ@author |
| 142 | + \else |
| 143 | + \noindent\textit{\RJ@author} |
| 144 | + \par\nobreak\addvspace{\baselineskip} |
| 145 | + \fi |
| 146 | + \@afterindentfalse\@nobreaktrue\@afterheading |
| 147 | +} |
| 148 | + |
| 149 | +% Now for some ugly redefinitions. We do not want articles to start a |
| 150 | +% new page. (Actually, we do, but this is handled via explicit |
| 151 | +% \newpage |
| 152 | +% |
| 153 | +% The name@of@eq is a hack to get hyperlinks to equations to work |
| 154 | +% within each article, even though there may be multiple eq.(1) |
| 155 | +% \begin{macrocode} |
| 156 | +\renewcommand\chapter{\secdef\RJ@chapter\@schapter} |
| 157 | +\providecommand{\nohyphens}{% |
| 158 | + \hyphenpenalty=10000\exhyphenpenalty=10000\relax} |
| 159 | +\newcommand{\RJ@chapter}{% |
| 160 | + \edef\name@of@eq{equation.\@arabic{\c@chapter}}% |
| 161 | + \renewcommand{\@seccntformat}[1]{}% |
| 162 | + \@startsection{chapter}{0}{0mm}{% |
| 163 | + -2\baselineskip \@plus -\baselineskip \@minus -.2ex}{\p@}{% |
| 164 | + \phantomsection\normalfont\huge\bfseries\raggedright}} |
| 165 | + |
| 166 | +% Book reviews should appear as sections in the text and in the pdf bookmarks, |
| 167 | +% however we wish them to appear as chapters in the TOC. Thus we define an |
| 168 | +% alternative to |\maketitle| for reviews. |
| 169 | +\newcommand{\review}[1]{ |
| 170 | + \pdfbookmark[1]{#1}{#1} |
| 171 | + \section*{#1} |
| 172 | + \addtocontents{toc}{\protect\contentsline{chapter}{#1}{\thepage}{#1.1}} |
| 173 | +} |
| 174 | + |
| 175 | +% We want bibliographies as starred sections within articles. |
| 176 | +% |
| 177 | +\RequirePackage[sectionbib,round]{natbib} |
| 178 | +\bibliographystyle{abbrvnat} |
| 179 | +\renewcommand{\bibsection}{\section*{References}} |
| 180 | + |
| 181 | +% Equations, figures and tables are counted within articles, but we do |
| 182 | +% not show the article number. For equations it becomes a bit messy to avoid |
| 183 | +% having hyperref getting it wrong. |
| 184 | + |
| 185 | +% \numberwithin{equation}{chapter} |
| 186 | +\renewcommand{\theequation}{\@arabic\c@equation} |
| 187 | +\renewcommand{\thefigure}{\@arabic\c@figure} |
| 188 | +\renewcommand{\thetable}{\@arabic\c@table} |
| 189 | + |
| 190 | +% Issue layout ----------------------------------------------------------------- |
| 191 | + |
| 192 | +% Need to provide our own version of |\tableofcontents|. We use the |
| 193 | +% tikz package to get the rounded rectangle. Notice that |\section*| |
| 194 | +% is really the same as |\chapter*|. |
| 195 | +\renewcommand{\contentsname}{Contents} |
| 196 | +\renewcommand\tableofcontents{% |
| 197 | + \vspace{1cm} |
| 198 | + \section*{\contentsname} |
| 199 | + { \@starttoc{toc} } |
| 200 | +} |
| 201 | + |
| 202 | +\renewcommand{\titlepage}{% |
| 203 | + \thispagestyle{empty} |
| 204 | + \hypersetup{ |
| 205 | + pdftitle={The R Journal Volume \RJ@volume/\RJ@number, \RJ@month \RJ@year},% |
| 206 | + pdfauthor={R Foundation for Statistical Computing},% |
| 207 | + } |
| 208 | + \noindent |
| 209 | + \begin{center} |
| 210 | + \fontsize{50pt}{50pt}\selectfont |
| 211 | + The \raisebox{-8pt}{\includegraphics[height=77pt]{Rlogo-5}}\hspace{10pt} |
| 212 | + Journal |
| 213 | + |
| 214 | + \end{center} |
| 215 | + {\large \hfill Volume \RJ@volume/\RJ@number, \RJ@month{} \RJ@year \quad} |
| 216 | + |
| 217 | + \rule{\textwidth}{1pt} |
| 218 | + \begin{center} |
| 219 | + {\Large A peer-reviewed, open-access publication of the \\ |
| 220 | + R Foundation for Statistical Computing} |
| 221 | + \end{center} |
| 222 | + |
| 223 | + % And finally, put in the TOC box. Note the way |tocdepth| is adjusted |
| 224 | + % before and after producing the TOC: thus, we can ensure that only |
| 225 | + % articles show up in the printed TOC, but that in the PDF version, |
| 226 | + % bookmarks are created for sections and subsections as well (provided |
| 227 | + % that the non-starred forms are used). |
| 228 | + \setcounter{tocdepth}{0} |
| 229 | + \tableofcontents |
| 230 | + \setcounter{tocdepth}{2} |
| 231 | + \clearpage |
| 232 | +} |
| 233 | + |
| 234 | +% Text formatting -------------------------------------------------------------- |
| 235 | + |
| 236 | +\newcommand{\R}{R} |
| 237 | +\newcommand{\address}[1]{\addvspace{\baselineskip}\noindent\emph{#1}} |
| 238 | +\newcommand{\email}[1]{\href{mailto:#1}{\normalfont\texttt{#1}}} |
| 239 | + |
| 240 | +% Simple font selection is not good enough. For example, |\texttt{--}| |
| 241 | +% gives `\texttt{--}', i.e., an endash in typewriter font. Hence, we |
| 242 | +% need to turn off ligatures, which currently only happens for commands |
| 243 | +% |\code| and |\samp| and the ones derived from them. Hyphenation is |
| 244 | +% another issue; it should really be turned off inside |\samp|. And |
| 245 | +% most importantly, \LaTeX{} special characters are a nightmare. E.g., |
| 246 | +% one needs |\~{}| to produce a tilde in a file name marked by |\file|. |
| 247 | +% Perhaps a few years ago, most users would have agreed that this may be |
| 248 | +% unfortunate but should not be changed to ensure consistency. But with |
| 249 | +% the advent of the WWW and the need for getting `|~|' and `|#|' into |
| 250 | +% URLs, commands which only treat the escape and grouping characters |
| 251 | +% specially have gained acceptance |
| 252 | + |
| 253 | +\DeclareRobustCommand\code{\bgroup\@noligs\@codex} |
| 254 | +\def\@codex#1{\texorpdfstring% |
| 255 | +{{\normalfont\ttfamily\hyphenchar\font=-1 #1}}% |
| 256 | +{#1}\egroup} |
| 257 | +\newcommand{\kbd}[1]{{\normalfont\texttt{#1}}} |
| 258 | +\newcommand{\key}[1]{{\normalfont\texttt{\uppercase{#1}}}} |
| 259 | +\DeclareRobustCommand\samp{`\bgroup\@noligs\@sampx} |
| 260 | +\def\@sampx#1{{\normalfont\texttt{#1}}\egroup'} |
| 261 | +\newcommand{\var}[1]{{\normalfont\textsl{#1}}} |
| 262 | +\let\env=\code |
| 263 | +\newcommand{\file}[1]{{`\normalfont\textsf{#1}'}} |
| 264 | +\let\command=\code |
| 265 | +\let\option=\samp |
| 266 | +\newcommand{\dfn}[1]{{\normalfont\textsl{#1}}} |
| 267 | +% \acronym is effectively disabled since not used consistently |
| 268 | +\newcommand{\acronym}[1]{#1} |
| 269 | +\newcommand{\strong}[1]{\texorpdfstring% |
| 270 | +{{\normalfont\fontseries{b}\selectfont #1}}% |
| 271 | +{#1}} |
| 272 | +\let\pkg=\strong |
| 273 | +\newcommand{\CRANpkg}[1]{\href{https://CRAN.R-project.org/package=#1}{\pkg{#1}}}% |
| 274 | +\let\cpkg=\CRANpkg |
| 275 | +\newcommand{\ctv}[1]{\href{https://CRAN.R-project.org/view=#1}{\emph{#1}}} |
| 276 | +\newcommand{\BIOpkg}[1]{\href{https://www.bioconductor.org/packages/release/bioc/html/#1.html}{\pkg{#1}}} |
| 277 | + |
| 278 | +% Example environments --------------------------------------------------------- |
| 279 | +\RequirePackage{fancyvrb} |
| 280 | +\RequirePackage{alltt} |
| 281 | + |
| 282 | +\DefineVerbatimEnvironment{example}{Verbatim}{} |
| 283 | +\renewenvironment{example*}{\begin{alltt}}{\end{alltt}} |
| 284 | + |
| 285 | +% Support for output from Sweave, and generic session style code |
| 286 | +% These used to have fontshape=sl for Sinput/Scode/Sin, but pslatex |
| 287 | +% won't use a condensed font in that case. |
| 288 | + |
| 289 | +% Update (2015-05-28 by DS): remove fontsize=\small to match example environment |
| 290 | + |
| 291 | +\DefineVerbatimEnvironment{Sinput}{Verbatim}{} |
| 292 | +\DefineVerbatimEnvironment{Soutput}{Verbatim}{} |
| 293 | +\DefineVerbatimEnvironment{Scode}{Verbatim}{} |
| 294 | +\DefineVerbatimEnvironment{Sin}{Verbatim}{} |
| 295 | +\DefineVerbatimEnvironment{Sout}{Verbatim}{} |
| 296 | +\newenvironment{Schunk}{}{} |
| 297 | + |
| 298 | +% Mathematics ------------------------------------------------------------------ |
| 299 | + |
| 300 | +% The implementation of |\operatorname| is similar to the mechanism |
| 301 | +% \LaTeXe{} uses for functions like sin and cos, and simpler than the |
| 302 | +% one of \AmSLaTeX{}. We use |\providecommand| for the definition in |
| 303 | +% order to keep the one of the \pkg{amstex} if this package has |
| 304 | +% already been loaded. |
| 305 | +% \begin{macrocode} |
| 306 | +\providecommand{\operatorname}[1]{% |
| 307 | + \mathop{\operator@font#1}\nolimits} |
| 308 | +\RequirePackage{amsfonts} |
| 309 | + |
| 310 | +\renewcommand{\P}{% |
| 311 | + \mathop{\operator@font I\hspace{-1.5pt}P\hspace{.13pt}}} |
| 312 | +\newcommand{\E}{% |
| 313 | + \mathop{\operator@font I\hspace{-1.5pt}E\hspace{.13pt}}} |
| 314 | +\newcommand{\VAR}{\operatorname{var}} |
| 315 | +\newcommand{\COV}{\operatorname{cov}} |
| 316 | +\newcommand{\COR}{\operatorname{cor}} |
| 317 | + |
| 318 | +% Figures ---------------------------------------------------------------------- |
| 319 | + |
| 320 | +\RequirePackage[font=small,labelfont=bf]{caption} |
| 321 | + |
| 322 | +% Wide environments for figures and tables ------------------------------------- |
| 323 | +\RequirePackage{environ} |
| 324 | + |
| 325 | +% An easy way to make a figure span the full width of the page |
| 326 | +\NewEnviron{widefigure}[1][]{ |
| 327 | +\begin{figure}[#1] |
| 328 | +\advance\leftskip-2cm |
| 329 | +\begin{minipage}{\dimexpr\textwidth+4cm\relax}% |
| 330 | + \captionsetup{margin=2cm} |
| 331 | + \BODY |
| 332 | +\end{minipage}% |
| 333 | +\end{figure} |
| 334 | +} |
| 335 | + |
| 336 | +\NewEnviron{widetable}[1][]{ |
| 337 | +\begin{table}[#1] |
| 338 | +\advance\leftskip-2cm |
| 339 | +\begin{minipage}{\dimexpr\textwidth+4cm\relax}% |
| 340 | + \captionsetup{margin=2cm} |
| 341 | + \BODY |
| 342 | +\end{minipage}% |
| 343 | +\end{table} |
| 344 | +} |
0 commit comments