%%% AAT.CLS -- A LaTeX class to produce Al Amarja Today newspapers for
%%%            the Over The Edge Roleplaying game
%%%
%%% Copyright © Jonas Steverud (steverud@bredband.net)
%%%
%%% Version 1.0
%%%
%%% Distributed according to the LaTeX Project Public Licence, LPPL.
%%%
%%% (The LPPL is a free software licence which among other things
%%% requires that the derived work doesn't use the same name as the
%%% original work. I.e. if you want to change this, you are free to do
%%% so but don't call i AAT.CLS. See the licence for details.)

%%% IMPORTANT! This class requires the memoir class, which can be
%%% downloaded from CTAN. It won't work without it! The memoir class
%%% is a very powerfull document class which gives wast possibilites
%%% to the design of the page. It also requires the Times package (the
%%% Times font), the ifthen package and the multicol package.

%%% As already stated, AAT.CLS is a LaTeX class to produce the back
%%% page of the Al Amarja Today newspaper, the page with
%%% ''Oppertunities On The Edge'' and ''Little Scratches''. It is not
%%% restricted to the oppertunities and little scratches, also
%%% ''ordinary'' news articles can be incorporated. Except for
%%% the class options (see below) it also contains a small number of
%%% commands and environments to ease the task.

%%% It currently only supports A4 paper in portrait, or to be
%%% specific: It *requires* A4 paper in portrait.

%%% Class options and usage of the class:

%%% \documentclass[options]{aat} where options are either
%%% ''playerversion'' (default, used if no option is given) or
%%% ''GMversion''. They are mutually exclusive and the difference is
%%% that in ''GMversion'', the GM note is printed (see the environment
%%% aatnote*)

%%% Commands:

%%% There are five commands that the user need to bother about:

%%% \aatheading  Used in an aatnote or aatnote* environment and
%%%              produces the bold heading in the notes. Takes two
%%%              arguments, one optional and the heading. The optional
%%%              is the name of the command (without the backslash) to
%%%              format the heading. Valid optional arguments are
%%%              ''textbf'' (default) and friends:
%%%              \aatheading{Money for Fighting}
%%%              \aatheading[textit]{Money for Fighting}

%%% \littlescratches  Produces the texts ''Oportunites on Al Amarja''
%%% \opportunites     and ''Little Scatches''.

%%% \newsheadline     Produces a news headline, like ''Peace Force's
%%%                   campain on drug abuse continues.'' It takes one
%%%                   argument that is the headline.

%%% \sectionfontname  The name of the section font according to
%%%                   NFSS. Default is ''egs'', use
%%%                   \renewcommand{\sectionfontname}{ptm} to use
%%%                   Times for section headings too. (egs is Gill Sans.)

%%% \AATheadline  Produces the headline for the page (''The only
%%%               news...'' etc.), use it after \begin{document}.
%%%               Takes two arguments, the issue number and the author
%%%               (or any other misc. text). The second argument, the
%%%               author, is not produced unless it's a GM's
%%%               version.

%%% Environments:

%%% There are one environment, aatnote, and a starred version of it.
%%% The unstarred version is straight forward. It produces its
%%% contents with some space to the note before and after. The starred
%%% version takes one argument which is a GM's note. If the
%%% ''GMversion'' class option is used, this note is printed after the
%%% aatnote. I.e. to produce a GM's version of the page which he uses
%%% for his own reference. With the ''playerversion'', this GM's note
%%% is naturally not printed.

%%% \begin{aatnote}
%%%   Blah blah.
%%% \end{aatnote}

%%% \begin{aatnote*}{More blah blah.}
%%%   Blah blah.
%%% \end{aatnote*}

%%% Usage:

%%% Use \documentclass[options]{aat} with the option of you choice,
%%% load other packages etc. Then begin the document,
%%% \begin{document}, call \AATheadline with the arguments of your
%%% choice. The next thing to do is to is to begin a four multicolumn
%%% environment, \begin{multicols}{4}, and to use \opportunites. After
%%% all opportunites, call \littlescratches and then end the multicols
%%% environment and the document itself.

%%% ----------------------------------------------------------------------


\NeedsTeXFormat{LaTeX2e}

\ProvidesClass{aat}[2002/11/24 LaTeX class for Al Amarja Today, built upon the memoir class, Copyright Jonas Steverud, distributed according to LaTeX Project Public Licence.]

%% Load memoir with the appropriate options.
\LoadClass[a4paper,11pt,twoside,article,openright]{memoir}%

%% Load packages
\RequirePackage{times}%
\RequirePackage{ifthen}%
\RequirePackage{multicol}%

% Help commands to select the currect heading font etc.
\newcommand{\sectionfontname}{egs}%
\newcommand{\sectionfont}{\fontfamily{\sectionfontname}\selectfont\Large{}}%
\newcommand{\sectionfontsize}[2]{\fontsize{#1}{#2}\sectionfont}%

\newcommand{\SetupPagestyle}{%
  \makeoddhead{plain}{}{}{}%
  \makeevenhead{plain}{}{}{}%
  \makeoddfoot{plain}{}{}{}%
  \makeevenfoot{plain}{}{}{}%
  \pagestyle{plain}%
}%


\setlength{\parindent}{0em}%

%% These commands comes from the memoir class.
%% w = 210 mm, h = 297 mm, a4paper is expected.
\settypeblocksize{280mm}{190mm}{*}%
\setlrmargins{1cm}{*}{*}%
\setulmargins{1cm}{*}{*}%
\setheadfoot{1mm}{1mm}
\setheaderspaces{*}{1mm}{*}
\setmarginnotes{1mm}{1mm}{1pt}
\checkandfixthelayout%


%%% Shall we use a GM's version or a players' version?
\newboolean{GMversion}%
\newcommand{\@playerversiontrue}{\setboolean{GMversion}{false}}%
\newcommand{\@GMversiontrue}{\setboolean{GMversion}{true}}%
\@playerversiontrue% Default
\newcommand{\isGMversion}[1]{\ifthenelse{\boolean{GMversion}}{#1}{}}%

\DeclareOption{GMversion}{\@GMversiontrue}%
\DeclareOption{playerversion}{\@playerversiontrue}%
\DeclareOption*{\ClassWarningNoLine{aat}{Unknown option `\CurrentOption'.}}%
\ProcessOptions\relax%

\AtBeginDocument{\SetupPagestyle}%

\newenvironment{aatnote}{\noindent}{\par\noindent\vspace{.5\baselineskip}}%

\newcommand{\saveGMnote}[1]{\sbox{\aatGMnotebox}{%
    \parbox{\columnwidth}{\hrulefill\\%
      \textsc{GM's note:} \textit{#1}}}}%

\newcommand{\typesetGMnote}{\par\noindent\usebox{\aatGMnotebox}}%

\newsavebox{\aatGMnotebox}%
\newenvironment{aatnote*}[1]{%
  \isGMversion{\saveGMnote{#1}}%
  \begin{aatnote}}{%
    \isGMversion{\typesetGMnote}\end{aatnote}}%


\newcommand{\opportunites}{\vspace{1.5\baselineskip}\noindent{\sectionfont{}Opportunities On\\ \textsc{The Edge}}\newline\vspace{1.5\baselineskip}\noindent}%

\newcommand{\littlescratches}{\vspace{1.5\baselineskip}\noindent{\sectionfont{}Little Scratches}\vspace{1.5\baselineskip}}%

\newcommand{\newsheadline}[1]{\noindent{\sectionfont{}News: #1}\newline\vspace{1.5\baselineskip}\noindent}%

\newcommand{\AATheadline}[2]{%
  \begin{center}
    {\fontsize{.8cm}{1.2cm}\selectfont\itshape{}``The only news you need to read!''}
    \rule{\textwidth}{.2pt}
    \raisebox{\baselineskip}{\rule{0pt}{.8pt}\rule{\textwidth}{1pt}}
    \vspace{\baselineskip}
    \noindent{\fontsize{1.5cm}{1.8cm}\selectfont{}AL AMARJA TODAY}
    \makebox[\textwidth][r]{Issue: #1\isGMversion{ (#2)}}
    \rule{\textwidth}{2pt}
  \end{center}%
}%

% Sets an heading for the aatnote. Optional argument is the name - one
% and only one of the LaTeX command which changes the style of the
% text and takes one argument. Valid optional arguments are
% e.g textbf (default), textit, ...
% Large etc. doesn't seems to work no matter what.
\newcommand{\aatheading}[2][textbf]{\csname #1 \endcsname {#2}\\}%

