Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/RMarkdown/rticles/rjournal_article/RJournal.sty
Views: 1199
% Package `RJournal' to use with LaTeX2e1% Copyright (C) 2010 by the R Foundation2% Copyright (C) 2013 by the R Journal3%4% Originally written by Kurt Hornik and Friedrich Leisch with subsequent5% edits by the editorial board67\NeedsTeXFormat{LaTeX2e}[1995/12/01]8\ProvidesPackage{RJournal}[2013/08/27 v0.13 RJournal package]910\RequirePackage{tikz}1112% Overall page layout, fonts etc -----------------------------------------------1314% Issues of of \emph{The R Journal} are created from the standard \LaTeX{}15% document class \pkg{report}.1617\RequirePackage{geometry}18\geometry{a4paper,19textwidth=14cm, top=1cm, bottom=1cm,20includehead,includefoot,centering,21footskip=1.5cm}22\raggedbottom2324\RequirePackage{fancyhdr}25\fancyhead{}26\fancyheadoffset{2cm}27\fancyhead[L]{\textsc{\RJ@sectionhead}}28\fancyhead[R]{\thepage}29\fancyfoot{}30\fancyfoot[L]{The R Journal Vol. \RJ@volume/\RJ@number, \RJ@month}31\fancyfoot[R]{ISSN 2073-4859}32\pagestyle{fancy}3334% We use the following fonts (all with T1 encoding):35%36% rm & palatino37% tt & inconsolata38% sf & helvetica39% math & palatino4041\RequirePackage{microtype}4243\RequirePackage[scaled=0.92]{helvet}44\RequirePackage{palatino,mathpazo}45\RequirePackage[scaled=1.02]{inconsolata}46\RequirePackage[T1]{fontenc}4748\RequirePackage[hyphens]{url}49\RequirePackage[pagebackref]{hyperref}50\renewcommand{\backref}[1]{[p#1]}5152% Dark blue colour for all links53\RequirePackage{color}54\definecolor{link}{rgb}{0.45,0.51,0.67}55\hypersetup{56colorlinks,%57citecolor=link,%58filecolor=link,%59linkcolor=link,%60urlcolor=link61}6263% Give the text a little room to breath64\setlength{\parskip}{3pt}65\RequirePackage{setspace}66\setstretch{1.05}6768% Issue and article metadata ---------------------------------------------------6970% Basic front matter information about the issue: volume, number, and71% date.7273\newcommand{\volume}[1]{\def\RJ@volume{#1}}74\newcommand{\volnumber}[1]{\def\RJ@number{#1}}75\renewcommand{\month}[1]{\def\RJ@month{#1}}76\renewcommand{\year}[1]{\def\RJ@year{#1}}777879% Individual articles correspond to80% chapters, and are contained in |article| environments. This makes it81% easy to have figures counted within articles and hence hyperlinked82% correctly.8384% An article has an author, a title, and optionally a subtitle. We use85% the obvious commands for specifying these. Articles will be put in certain86% journal sections, named by \sectionhead.8788\newcommand {\sectionhead} [1]{\def\RJ@sectionhead{#1}}89\renewcommand{\author} [1]{\def\RJ@author{#1}}90\renewcommand{\title} [1]{\def\RJ@title{#1}}91\newcommand {\subtitle} [1]{\def\RJ@subtitle{#1}}9293% Control appearance of titles: make slightly smaller than usual, and94% suppress section numbering. See http://tex.stackexchange.com/questions/6974995% for why we don't use \setcounter{secnumdepth}{-1}9697\usepackage[medium]{titlesec}98\usepackage{titletoc}99\titleformat{\section} {\normalfont\large\bfseries}{}{0em}{}100\titleformat{\subsection}{\normalfont\normalsize\bfseries}{}{0em}{}101\titlecontents{chapter} [0em]{}{}{}{\titlerule*[1em]{.}\contentspage}102103% Article layout ---------------------------------------------------------------104105% Environment |article| clears the article header information at its beginning.106% We use |\FloatBarrier| from the placeins package to keep floats within107% the article.108\RequirePackage{placeins}109\newenvironment{article}{\author{}\title{}\subtitle{}\FloatBarrier}{\FloatBarrier}110111% Refereed articles should have an abstract, so we redefine |\abstract| to112% give the desired style113114\renewcommand{\abstract}[1]{%115\setstretch{1}%116\noindent%117\small%118\textbf{Abstract} #1119}120121% The real work is done by a redefined version of |\maketitle|. Note122% that even though we do not want chapters (articles) numbered, we123% need to increment the chapter counter, so that figures get correct124% labelling.125126\renewcommand{\maketitle}{%127\noindent128\chapter{\RJ@title}\refstepcounter{chapter}129\ifx\empty\RJ@subtitle130\else131\noindent\textbf{\RJ@subtitle}132\par\nobreak\addvspace{\baselineskip}133\fi134\ifx\empty\RJ@author135\else136\noindent\textit{\RJ@author}137\par\nobreak\addvspace{\baselineskip}138\fi139\@afterindentfalse\@nobreaktrue\@afterheading140}141142% Now for some ugly redefinitions. We do not want articles to start a143% new page. (Actually, we do, but this is handled via explicit144% \newpage145%146% The name@of@eq is a hack to get hyperlinks to equations to work147% within each article, even though there may be multiple eq.(1)148% \begin{macrocode}149\renewcommand\chapter{\secdef\RJ@chapter\@schapter}150\providecommand{\nohyphens}{%151\hyphenpenalty=10000\exhyphenpenalty=10000\relax}152\newcommand{\RJ@chapter}{%153\edef\name@of@eq{equation.\@arabic{\c@chapter}}%154\renewcommand{\@seccntformat}[1]{}%155\@startsection{chapter}{0}{0mm}{%156-2\baselineskip \@plus -\baselineskip \@minus -.2ex}{\p@}{%157\phantomsection\normalfont\huge\bfseries\raggedright}}158159% Book reviews should appear as sections in the text and in the pdf bookmarks,160% however we wish them to appear as chapters in the TOC. Thus we define an161% alternative to |\maketitle| for reviews.162\newcommand{\review}[1]{163\pdfbookmark[1]{#1}{#1}164\section*{#1}165\addtocontents{toc}{\protect\contentsline{chapter}{#1}{\thepage}{#1.1}}166}167168% We want bibliographies as starred sections within articles.169%170\RequirePackage[sectionbib,round]{natbib}171\bibliographystyle{abbrvnat}172173% Equations, figures and tables are counted within articles, but we do174% not show the article number. For equations it becomes a bit messy to avoid175% having hyperref getting it wrong.176177% \numberwithin{equation}{chapter}178\renewcommand{\theequation}{\@arabic\c@equation}179\renewcommand{\thefigure}{\@arabic\c@figure}180\renewcommand{\thetable}{\@arabic\c@table}181182% Issue layout -----------------------------------------------------------------183184% Need to provide our own version of |\tableofcontents|. We use the185% tikz package to get the rounded rectangle. Notice that |\section*|186% is really the same as |\chapter*|.187\renewcommand{\contentsname}{Contents}188\renewcommand\tableofcontents{%189\vspace{1cm}190\section*{\contentsname}191{ \@starttoc{toc} }192}193194\renewcommand{\titlepage}{%195\thispagestyle{empty}196\hypersetup{197pdftitle={The R Journal Volume \RJ@volume/\RJ@number, \RJ@month \RJ@year},%198pdfauthor={R Foundation for Statistical Computing},%199}200\noindent201\begin{center}202\fontsize{50pt}{50pt}\selectfont203The \raisebox{-8pt}{\includegraphics[height=77pt]{Rlogo-4}}\hspace{10pt}204Journal205206\end{center}207{\large \hfill Volume \RJ@volume/\RJ@number, \RJ@month{} \RJ@year \quad}208209\rule{\textwidth}{1pt}210\begin{center}211{\Large A peer-reviewed, open-access publication of the \\212R Foundation for Statistical Computing}213\end{center}214215% And finally, put in the TOC box. Note the way |tocdepth| is adjusted216% before and after producing the TOC: thus, we can ensure that only217% articles show up in the printed TOC, but that in the PDF version,218% bookmarks are created for sections and subsections as well (provided219% that the non-starred forms are used).220\setcounter{tocdepth}{0}221\tableofcontents222\setcounter{tocdepth}{2}223\clearpage224}225226% Text formatting --------------------------------------------------------------227228\newcommand{\R}{R}229\newcommand{\address}[1]{\addvspace{\baselineskip}\noindent\emph{#1}}230\newcommand{\email}[1]{\href{mailto:#1}{\normalfont\texttt{#1}}}231232% Simple font selection is not good enough. For example, |\texttt{--}|233% gives `\texttt{--}', i.e., an endash in typewriter font. Hence, we234% need to turn off ligatures, which currently only happens for commands235% |\code| and |\samp| and the ones derived from them. Hyphenation is236% another issue; it should really be turned off inside |\samp|. And237% most importantly, \LaTeX{} special characters are a nightmare. E.g.,238% one needs |\~{}| to produce a tilde in a file name marked by |\file|.239% Perhaps a few years ago, most users would have agreed that this may be240% unfortunate but should not be changed to ensure consistency. But with241% the advent of the WWW and the need for getting `|~|' and `|#|' into242% URLs, commands which only treat the escape and grouping characters243% specially have gained acceptance244245\DeclareRobustCommand\code{\bgroup\@noligs\@codex}246\def\@codex#1{\texorpdfstring%247{{\normalfont\ttfamily\hyphenchar\font=-1 #1}}%248{#1}\egroup}249\newcommand{\kbd}[1]{{\normalfont\texttt{#1}}}250\newcommand{\key}[1]{{\normalfont\texttt{\uppercase{#1}}}}251\DeclareRobustCommand\samp{`\bgroup\@noligs\@sampx}252\def\@sampx#1{{\normalfont\texttt{#1}}\egroup'}253\newcommand{\var}[1]{{\normalfont\textsl{#1}}}254\let\env=\code255\newcommand{\file}[1]{{`\normalfont\textsf{#1}'}}256\let\command=\code257\let\option=\samp258\newcommand{\dfn}[1]{{\normalfont\textsl{#1}}}259% \acronym is effectively disabled since not used consistently260\newcommand{\acronym}[1]{#1}261\newcommand{\strong}[1]{\texorpdfstring%262{{\normalfont\fontseries{b}\selectfont #1}}%263{#1}}264\let\pkg=\strong265\newcommand{\CRANpkg}[1]{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}%266\let\cpkg=\CRANpkg267\newcommand{\ctv}[1]{\href{http://CRAN.R-project.org/view=#1}{\emph{#1}}}268\newcommand{\BIOpkg}[1]{\href{http://www.bioconductor.org/packages/release/bioc/html/#1.html}{\pkg{#1}}}269270% Example environments ---------------------------------------------------------271\RequirePackage{fancyvrb}272\RequirePackage{alltt}273274\DefineVerbatimEnvironment{example}{Verbatim}{}275\renewenvironment{example*}{\begin{alltt}}{\end{alltt}}276277% Support for output from Sweave, and generic session style code278% These used to have fontshape=sl for Sinput/Scode/Sin, but pslatex279% won't use a condensed font in that case.280281\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontsize=\small}282\DefineVerbatimEnvironment{Soutput}{Verbatim}{fontsize=\small}283\DefineVerbatimEnvironment{Scode}{Verbatim}{fontsize=\small}284\DefineVerbatimEnvironment{Sin}{Verbatim}{fontsize=\small}285\DefineVerbatimEnvironment{Sout}{Verbatim}{fontsize=\small}286\newenvironment{Schunk}{}{}287288% Mathematics ------------------------------------------------------------------289290% The implementation of |\operatorname| is similar to the mechanism291% \LaTeXe{} uses for functions like sin and cos, and simpler than the292% one of \AmSLaTeX{}. We use |\providecommand| for the definition in293% order to keep the one of the \pkg{amstex} if this package has294% already been loaded.295% \begin{macrocode}296\providecommand{\operatorname}[1]{%297\mathop{\operator@font#1}\nolimits}298\RequirePackage{amsfonts}299300\renewcommand{\P}{%301\mathop{\operator@font I\hspace{-1.5pt}P\hspace{.13pt}}}302\newcommand{\E}{%303\mathop{\operator@font I\hspace{-1.5pt}E\hspace{.13pt}}}304\newcommand{\VAR}{\operatorname{var}}305\newcommand{\COV}{\operatorname{cov}}306\newcommand{\COR}{\operatorname{cor}}307308% Figures ----------------------------------------------------------------------309310\RequirePackage[font=small,labelfont=bf]{caption}311312% Wide environments for figures and tables -------------------------------------313\RequirePackage{environ}314315% An easy way to make a figure span the full width of the page316\NewEnviron{widefigure}[1][]{317\begin{figure}[#1]318\advance\leftskip-2cm319\begin{minipage}{\dimexpr\textwidth+4cm\relax}%320\captionsetup{margin=2cm}321\BODY322\end{minipage}%323\end{figure}324}325326\NewEnviron{widetable}[1][]{327\begin{table}[#1]328\advance\leftskip-2cm329\begin{minipage}{\dimexpr\textwidth+4cm\relax}%330\captionsetup{margin=2cm}331\BODY332\end{minipage}%333\end{table}334}335336337