\def\fileversion{v0.3.1}
\def\filename{Rnews}
\def\filedate{2001/09/04}
\def\docdate {2001/09/04}
%
% \iffalse
%
%%
%% Package `Rnews' to use with LaTeX2e
%% Copyright (C) 2001 by the R Core Development Team
%% Please report errors to KH or FL
%%
%% -*- LaTeX -*-
%
% \fi
%
% \iffalse
% \changes{v0.1}{2001/01/05}{First draft.}
% \changes{v0.2}{2001/07/01}
%   {Added macros \cmd\P, \cmd\E, \cmd\VAR, \cmd\COV, \cmd\COR, and
%    \cmd\operatorname.  Require \pkg{amsfonts} to produce symbols for
%    sets of positive integers etc.}
% \changes{v0.3}{2001/08/02}
%   {Add package option `driver' for typesetting the driver.
%    Change article environment to use chapters.
%    Ensure unique figure labels.}
% \changes{v0.3.1}{2001/09/04}
%   {Remove redefinition of |\caption|, which had figures hard-wired.
%    Instead, have our |figure| environment set |\@captype|.}
% \fi
%
% \MakeShortVerb{\|}
%
% \newcommand{\AmS}{$${\protect\the\textfont2 A}\kern-.1667em\lower
%   .5ex\hbox{\protect\the\textfont2 M}\kern
%   -.125em{\protect\the\textfont2 S}}
% \newcommand{\AmSLaTeX}{\mbox{\AmS-\LaTeX}}
%
% \title{The package \pkg{\filename}}
% \author{Kurt Hornik \and Friedrich Leisch}
%
% \maketitle
%
% \section{Introduction}
%
% The \LaTeXe{} package \pkg{\filename} provides commands for formatting
% the R Newsletter.
%
% \section{Documentation}
%
% \subsection{Marking Words and Phrases}
%
% The \pkg{Rnews} package provides roughly the same commands for marking
% words and phrases as does Texinfo (but note that the \LaTeX special
% characters still need special treatment).  These commands are
% \begin{description}
%  \item[\code{\cmd{\code}\{\var{sample-code}\}}]
%   Indicate text that is a literal example of a piece of a program.
%  \item[\code{\cmd{\kbd}\{\var{keyboard-characters}\}}]
%   Indicate keyboard input.
%  \item[\code{\cmd{\key}\{\var{key-name}\}}]
%   Indicate the conventional name for a key on a keyboard.
%  \item[\code{\cmd{\samp}\{\var{text}\}}]
%   Indicate text that is a literal example of a sequence of
%   characters.
%  \item[\code{\cmd{\var}\{\var{metasyntactic-variable}\}}]
%   Indicate a metasyntactic variable.
%  \item[\code{\cmd{\env}\{\var{environment-variable}\}}]
%   Indicate an environment variable.
%  \item[\code{\cmd{\file}\{\var{file-name}\}}]
%   Indicate the name of a file.
%  \item[\code{\cmd{\command}\{\var{command-name}\}}]
%   Indicate a command name (such as \samp{ls}).
%  \item[\code{\cmd{\option}\{\var{option-name}\}}]
%   Indicate a command line option.
%  \item[\code{\cmd{\dfn}\{\var{term}\}}]
%   Indicate the introductory or defining use of a term.
%  \item[\code{\cmd{\acronym}\{\var{acronym}\}}]
%   Use for abbreviattions written in all capital letters, such as
%   \samp{NASA}.
% \end{description}
% If this sounds rather confusing, please see the Texinfo documentation
% for more details.
%
% \DescribeMacro{\strong}
% There is also a |\strong| command for emphasizing text more strongly
% than with |\emph|.  For example, |\strong{Note:}| gives \strong{Note:}.
%
% \DescribeMacro{\pkg}
% Finally, use |\pkg| for indicating R packages.
%
% \subsection{Quotations and Examples}
%
% In addition to the standard \LaTeX{} for quotations and examples (such
% as |quote|, |quotation|, |flushleft|, |center| and |flushright|), the
% \pkg{\filename} package provides the following environments.
% \begin{description}
%  \item[\code{example}]
%    Illustrate code, commands, and the like.  The text is printed in a
%    fixed-width font, and indented but not filled.
%  \item[\code{smallexample}]
%    Similar to \code{example}, except that text is typeset in a smaller
%    font.
% \end{description}
%
% \subsection{Mathematics}
%
% \DescribeMacro{\P}
% \DescribeMacro{\E}
% \DescribeMacro{\VAR}
% \DescribeMacro{\COV}
% \DescribeMacro{\COR}
% The commands |\P|, |\E|, |\VAR|, |\COV|, and |\COR| produce symbols
% for probability, expectation, variance, covariance and correlation.
% For example, Chebyshev's inequality
% \DeleteShortVerb{\|}
% \begin{displaymath}
%   \P(|\xi-\E\xi|>\lambda) \le \frac{\VAR(\xi)}{\lambda^2}.
% \end{displaymath}
% can be coded as
% \MakeShortVerb{\|}
% \begin{quote}
%   \verb+\P(|\xi-\E\xi|>\lambda) \le \frac{\VAR(\xi)}{\lambda^2}+.
% \end{quote}
%
% \DescribeMacro{\mathbb}
% The symbols
% \begin{displaymath}
%   \mathbb{N}\quad\mathbb{Z}\quad\mathbb{Q}\quad\mathbb{R}\quad\mathbb{C}
% \end{displaymath}
% for the positive integers, the integers, and the rational, real and
% complex numbers, respectively, can be obtained using |\mathbb| from
% package \pkg{amsfonts} as
% \begin{quote}
%   |\mathbb{N}| |\mathbb{Z}| |\mathbb{Q}| |\mathbb{R}| |\mathbb{C}|
% \end{quote}
%
% \section{The Code}
%
% \subsection{The Batch File}
%
% First comes the code for creating the batch file \file{\filename.ins}
% which in turn can be used for producing the package and driver files.
%
%    \begin{macrocode}
%<*install>
\begin{filecontents}{\filename.ins}
% Simply TeX or LaTeX this file to extract various files from the source
% file `Rnews.dtx'.
  \def\filedate{2001/01/05} \def\batchfile{Rnews.ins} \input
  docstrip.tex \preamble
\endpreamble
\generateFile{Rnews.drv}{t}{\from{Rnews.dtx}{driver}}
\generateFile{Rnews.sty}{t}{\from{Rnews.dtx}{package}}
\Msg{***********************************************************}
\Msg{* For documentation, run LaTeX on Rnews.dtx or Rnews.drv. *}
\Msg{***********************************************************}
\end{filecontents}
%</install>
%    \end{macrocode}
%
% \subsection{The Driver}
%
% Next comes the documentation driver file for \TeX{}, i.e., the file
% that will produce the documentation you are currently reading.  It
% will be extracted from this file by the \texttt{docstrip} program.
% Since it is the first code in the file one can alternatively process
% this file directly with \LaTeXe{} to obtain the documentation.
%
%    \begin{macrocode}
%<*driver>
\documentclass[fleqn]{ltxdoc}
\usepackage[driver]{\filename}
\renewcommand{\pkg}[1]{\textsf{#1}}
\begin{document}
  \DocInput{\filename.dtx}
\end{document}
%</driver>
%    \end{macrocode}
%
% \subsection{The Code}
%
% Now comes the code for the package.
%
% It the current format is not \LaTeXe{}, we abort immediately.
% Otherwise, we provide ourselves and show the current version of the
% package on the screen and in the transscript file.
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{\filename}[\filedate\space\fileversion\space
                        Rnews package]
\typeout{Package: `\filename\space\fileversion \@spaces <\filedate>'}
\typeout{English documentation as of <\docdate>}
%    \end{macrocode}
%
% Next, we set up a more or less trivial option handler.  We use option
% `driver' for conditionalizing package code we do not want executed
% when typesetting the driver file.
%    \begin{macrocode}
\RequirePackage{ifthen}
\newboolean{Rnews@driver}
\DeclareOption{driver}{\setboolean{Rnews@driver}{true}}
\DeclareOption*{\PackageWarning{\filename}{Unknown option
    `\CurrentOption'}}
\ProcessOptions\relax
%    \end{macrocode}
%
% Now comes the real code.
%
%    \begin{macrocode}
\ifthenelse{\boolean{Rnews@driver}}{}{
%    \end{macrocode}
%
% First we load some utility packages.
%    \begin{macrocode}
\RequirePackage{multicol,graphicx,color,fancyhdr,hyperref}
%    \end{macrocode}
%
% \subsubsection{Basic Structure}
%
% Issues of of \emph{R News} are created from the standard \LaTeX{}
% document class \pkg{report}.  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.
%
% Basic front matter information about the issue: volume, number, and
% date.
%    \begin{macrocode}
\newcommand{\volume}[1]{\def\Rnews@volume{#1}}
\newcommand{\volnumber}[1]{\def\Rnews@number{#1}}
\renewcommand{\date}[1]{\def\Rnews@date{#1}}
%    \end{macrocode}
%
% We do not want numbered sections.
%    \begin{macrocode}
\setcounter{secnumdepth}{-1}
%    \end{macrocode}
%
% \begin{macro}{\author}
% \begin{macro}{\title}
% \begin{macro}{\subtitle}
% An article has an author, a title, and optionally a subtitle.  We use
% the obvious commands for specifying these.
%    \begin{macrocode}
\renewcommand{\author}[1]{\def\Rnews@author{#1}}
\renewcommand{\title}[1]{\def\Rnews@title{#1}}
\newcommand{\subtitle}[1]{\def\Rnews@subtitle{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{environment}{article}
% Environment |article| clears the article header information its begin
% and restores single column mode at its end.
%    \begin{macrocode}
\newenvironment{article}{%
  \author{}\title{}\subtitle{}}{\end{multicols}}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\maketitle}
% The real work is done by a redefined version of |\maketitle|, which
% also switches to double column mode.  Note that even though we do not
% want chapters (articles) numbered, we need to increment the chapter
% counter, so that figures get correct labelling.
%    \begin{macrocode}
\renewcommand{\maketitle}{
  \chapter{\Rnews@title}
  \refstepcounter{chapter}
  \begin{multicols}{2}
    \ifx\empty\Rnews@subtitle\else\par\addvspace{\baselineskip}
    \noindent\textbf{\Rnews@subtitle}\fi
    \ifx\empty\Rnews@author\else\par\addvspace{\baselineskip}
    \noindent\textit{\Rnews@author}\fi}
%    \end{macrocode}
% \end{macro}
%
% Now for some ugly redefinitions.  We do not want articles to start a
% new page.
%    \begin{macrocode}
\renewcommand\chapter{\secdef\@chapter\@schapter}
%    \end{macrocode}
% TOC entries for articles (chapters) should really look like sections.
%    \begin{macrocode}
\renewcommand*\l@chapter{\@dottedtocline{0}{0pt}{1em}}
%    \end{macrocode}
% We need to adjust vertical spacing in |\@makechapterhead|: extra space
% before the title only if not at the beginning, no extra space after
% it.
%    \begin{macrocode}
\def\@makechapterhead#1{%
  \addvspace{2\baselineskip}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak}}
%    \end{macrocode}
% We want bibliographies as starred sections within articles.  As the
% standard |thebibliography| environment uses |chapter*|, we simply
% redefine the latter according to our needs.
%    \begin{macrocode}
\def\@schapter#1{\section*#1}
%    \end{macrocode}
%
% Package \pkg{multicol}, which is used for producing two-column output,
% only allows for starred (single-column) floats (figures and tables).
% Therefore, we provide a simple non-floating |figure| environment
% ourselves.
%    \begin{macrocode}
\renewenvironment{figure}[1][]{%
  \def\@captype{figure}
  \begin{minipage}{0.9\columnwidth}}{
  \end{minipage}\par\addvspace{\baselineskip}}
%    \end{macrocode}
% Equations, figures and tables are counted within articles, but we do
% not show the article number.
%    \begin{macrocode}
\renewcommand{\theequation}{\@arabic\c@equation}
\renewcommand{\thefigure}{\@arabic\c@figure}
\renewcommand{\thetable}{\@arabic\c@table}
%    \end{macrocode}
%
% \begin{macro}{\tableofcontents}
% Need to provide our own version of |\tableofcontents| (no fiddling
% with the number of columns).  Note that |\section*| is really the same
% as |\chapter*|).
%    \begin{macrocode}
\renewcommand{\contentsname}{Contents of this issue:}
\renewcommand\tableofcontents{%
  \section*{\contentsname
    \@mkboth{%
      \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
  \@starttoc{toc}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\titlepage}
% The title page of each issue features logo et al at the top and the
% TOC.  We start with the top.
%    \begin{macrocode}
\renewcommand{\titlepage}{%
  \noindent
  \rule{\textwidth}{1pt}\\[-.8\baselineskip]
  \rule{\textwidth}{.5pt}
  \begin{center}
    \includegraphics[height=2cm]{Rlogo}\hspace{7mm}
    \fontsize{2cm}{2cm}\selectfont
    News
  \end{center}
  The Newsletter of the R Project\hfill
  Volume \Rnews@volume/\Rnews@number, \Rnews@date\\[-.5\baselineskip]
  \rule{\textwidth}{.5pt}\\[-.8\baselineskip]
  \rule{\textwidth}{1pt}
  \vspace{1cm}
%    \end{macrocode}
% Now set up the header and footer information for the rest of the
% document.
%    \begin{macrocode}  
  \fancyhf{}
  \fancyhead[L]{Vol.~\Rnews@volume/\Rnews@number, \Rnews@date}
  \fancyhead[R]{\thepage}
  \fancyfoot[L]{R News}
  \fancyfoot[R]{ISSN 1609-3631}
  \thispagestyle{empty}
%    \end{macrocode}
% And finally, put the TOC at the bottom in a framed 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).
%    \begin{macrocode}  
  \begin{bottombox}
    \begin{multicols}{2}
      \setcounter{tocdepth}{0}
      \tableofcontents
      \setcounter{tocdepth}{2}
    \end{multicols}
  \end{bottombox}}
%    \end{macrocode}
% \end{macro}
%
% \subsubsection{Layout, Fonts and Color}
%
% \paragraph{Layout.}
% We set the basic layout parameters in a way that printouts should be
% fine for both A4 and Letter paper.
%    \begin{macrocode}
\setlength{\textheight}{250mm}
\setlength{\topmargin}{-10mm}
\setlength{\textwidth}{17cm}
\setlength{\oddsidemargin}{-6mm}
\setlength{\columnseprule}{.1pt}
\setlength{\columnsep}{20pt}
%    \end{macrocode}
%
% \paragraph{Fonts.}
% We use the following fonts (all with T1 encoding):
% \begin{center}
% \begin{tabular}{lp{0.8\textwidth}}
%   rm &  palatino \\
%   tt &  almost european (computer modern working with T1) \\
%      &  Reason for aett: uses less horizontal space than courier,
%      which is better for example code \\
%   sf &  almost european \\
%   math & palatino
% \end{tabular}
% \end{center}
%
%    \begin{macrocode}
\RequirePackage{ae,mathpple}
\RequirePackage[T1]{fontenc}
\renewcommand{\rmdefault}{ppl}
\renewcommand{\sfdefault}{aess}
\renewcommand{\ttdefault}{aett}
%    \end{macrocode}
%
% \paragraph{Colors.}  These are actually used for |\hypersetup| but we
% do not call this here, although we should.
% \marginpar{FIXME}
%    \begin{macrocode}
\definecolor{Red}{rgb}{0.7,0,0}
\definecolor{Blue}{rgb}{0,0,0.8}
\definecolor{hellgrau}{rgb}{0.55,0.55,0.55}
%    \end{macrocode}
%
% \subsubsection{Miscellania}
%
%    \begin{macrocode}
\newcommand{\R}{R}
\newcommand{\address}[1]{\addvspace{\baselineskip}\noindent\emph{#1}}
\newcommand{\email}[1]{\href{mailto:#1}{\normalfont\texttt{#1}}}
%    \end{macrocode}
%
% \begin{environment}{bottombox}
% Used for creating the TOC and the back matter editorial information.
%    \begin{macrocode}
\newsavebox{\Rnews@box}
\newlength{\Rnews@len}
\newenvironment{bottombox}{%
  \begin{figure*}[b]
    \begin{center}
      \noindent
      \begin{lrbox}{\Rnews@box}
        \begin{minipage}{0.99\textwidth}}{%
        \end{minipage}
      \end{lrbox}
      \addtolength{\Rnews@len}{\fboxsep}
      \addtolength{\Rnews@len}{\fboxrule}
      \hspace*{-\Rnews@len}\fbox{\usebox{\Rnews@box}}
    \end{center}
  \end{figure*}}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{boxedverbatim}
% This does not seem to be used any more.
% \marginpar{FIXME}
%    \begin{macrocode}
\newenvironment{boxedverbatim}{%
  \begin{lrbox}{\Rnews@box}
    \begin{smallverbatim}}{%
    \end{smallverbatim}
  \end{lrbox}
  \hspace*{-\fboxsep}\fbox{\usebox{\Rnews@box}}}
%    \end{macrocode}
% \end{environment}
%
% Finally, we turn on fancy page style.
%    \begin{macrocode}
\pagestyle{fancy}
} % \ifthenelse{\boolean{Rnews@driver}}
%    \end{macrocode}
%
% \subsubsection{Marking Words and Phrases}
%
% 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 (in fact, this is also what
% \pkg{alltt} does, and hence environments based on it such as our
% |smallexample|).  Hence, in the long run we should implement the same
% for |\code|, |\kbd|, |\samp|, |\var|, and |\file|.  (The other
% Texinfo-style commands do not need this.)
%
%    \begin{macrocode}
%\newcommand\code{\bgroup\@noligs\@codex}
\newcommand\code{\bgroup\@codex}
\def\@codex#1{{\normalfont\ttfamily\hyphenchar\font=-1 #1}\egroup}
\newcommand{\kbd}[1]{{\normalfont\texttt{#1}}}
\newcommand{\key}[1]{{\normalfont\texttt{\uppercase{#1}}}}
\newcommand\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}}}
\newcommand{\acronym}[1]{{\normalfont\textsc{\lowercase{#1}}}}
\newcommand{\strong}[1]{{\normalfont\fontseries{b}\selectfont #1}}
\let\pkg=\strong
%    \end{macrocode}
%
% \subsubsection{Quotations and Examples}
%
%    \begin{macrocode}
\RequirePackage{alltt}
\newenvironment{example}{\begin{alltt}}{\end{alltt}}
\newenvironment{smallexample}{\begin{alltt}\small}{\end{alltt}}
\newenvironment{display}{\list{}{}\item\relax}{\endlist}
%    \end{macrocode}
%
% \subsubsection{Mathematics}
%
% \begin{macro}{\operatorname}
% 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}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\P}
% \begin{macro}{\E}
% \begin{macro}{\VAR}
% \begin{macro}{\COV}
% \begin{macro}{\COR}
% Next, we provide commands for probability, expectation, variance,
% covariance and correlation which are obviously useful in probability
% theory and statistics.
% (Of course, originally |\P| gives \mathhexbox27B.)
%    \begin{macrocode}
\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}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Finally, we load package \pkg{amsfonts} so that |\mathbb| is available
% for producing the symbols for positive integers etc.
%    \begin{macrocode}
\RequirePackage{amsfonts}
%    \end{macrocode}
%
% This ends the implementation of the \pkg{\filename} package.
%    \begin{macrocode}
%</package>
%    \end{macrocode}
