Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

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