% class file for Journal of Cellular Automata, (publisher: Old City Publishing)
% http://www.oldcitypublishing.com/JCA/JCA.html
% Author : Jean-Baptiste Rouquier
% Warning : absolutely incomplete and full of bugs. I will happily include patches.
% Adapted from ijuc.cls

% Please enter title and author like this:
% \title[Short running title]{Main and long title}
% \author{Rouquier, Random} %lastanmes, for headers
% {Jean-Baptiste Rouquier\instref{univ-lyon}\instref{ensl}\instref{ixxi}
% \and Joe Random\instref{univ-lyon}\instref{foo}}
% \institute{univ-lyon}{Universit\'e de Lyon}
% \institute{ensl}{ENS Lyon, LIP, 46 allée d'Italie, F-69364 LYON cedex 03, France}
% \institute{ixxi}{Institut des Syst\`emes Complexes Rh\^one-Alpes (IXXI)}
% \institute{foo}{University of Somewhere}

%% This file may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License, either version 1.3 or (at your option) any
%% later version. The latest version of this license is in
%% http://www.latex-project.org/lppl.txt

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{ocp-jca}[01/12/2007 v0.1 OCP-JCA]
\LoadClass[twoside,10pt]{article}

\RequirePackage[paperheight=228mm,paperwidth=152mm,textwidth=108mm,textheight=180mm]{geometry}
\RequirePackage[english]{babel} %for the \addto macro

\setlength{\parindent}{4.25mm}
\setlength{\parskip}{0mm}
\RequirePackage{indentfirst}
\renewcommand{\baselinestretch}{1.1}  % approx 13pt leading
% \setcounter{secnumdepth}{2} % number first and second level headings
% \bibliographystyle{ijuc}

% Times font. These three commands make up the entire times.sty package.
\renewcommand{\sfdefault}{phv}
\renewcommand{\rmdefault}{ptm}
\renewcommand{\ttdefault}{pcr}
\normalfont\selectfont % enable Times now 


%==================
%  title (adapted from LLNCS)
%==================

\RequirePackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} %delete current setting for header and footer
\fancyhead[RO,LE]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\newcounter{@inst}
\newcommand{\@institute}{}
% \newcommand{\instref}[1]{\textsuperscript{\ref{#1}}}
\def\instref#1{\textsuperscript{\ref{#1}}}
\newcommand{\institute}[2]{%
  \refstepcounter{@inst}\label{#1}%
  \addto{\@institute}{\textsuperscript{\ref{#1}}#2\\}}

\renewcommand{\title}{\@ifnextchar[{\title@withOptionalArg}{\title@withoutOptionalArg}}
\newcommand{\title@withoutOptionalArg}[1]{\title@withOptionalArg[#1]{#1}}
\newcommand{\title@withOptionalArg}[2][]{%
  \gdef\@title{#2}%
  \fancyhead[CO]{#1}}

\renewcommand{\author}[2]{%
  \gdef\@author{#2}%
  \fancyhead[CE]{#1}}

\def\received{}

\newcommand{\@email}{}
\def\email#1{\gdef\@email{#1}}

\def\@maketitle{%
\renewcommand\thefootnote{\@arabic\c@footnote}
  \def\and{\unskip, }
  \newpage
  \begin{center}%
    \rule{0pt}{13.4mm}
    {\Large \bfseries\boldmath\@title \par}\vskip 9mm
    \textsc{\@author}\vskip 6mm
    {\small\textit{\@institute}\par
      \texttt{\@email}
      \vskip 4mm
      \received\vskip13.5mm}
  \end{center}%
}
\renewcommand\thefootnote{\@fnsymbol\c@footnote}

\renewenvironment{abstract}{%
  \renewcommand{\baselinestretch}{1.0}\normalsize
  \begin{quote}
}{\end{quote}}

\def\keywords#1{%
  \renewcommand{\baselinestretch}{1.0}\small
  \vskip 9mm
  \begin{quote}\textit{Key words:} #1\end{quote}
  \vskip 11.7mm
  \renewcommand{\baselinestretch}{1.1}\normalsize
}

%===================
%  figure/table captions: small font, normal leading, 5mm before, 10mm after
%     FIGURE/TABLE nn
%     caption text
%===================

\def\figurename{FIGURE}
\def\tablename{TABLE}
\def\fnum@figure{\figurename~\thefigure}
\def\fnum@table{\tablename~\thetable}


\long\def\@caption#1[#2]#3{
  \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}
}

\long\def\@makecaption#1#2{%
  \vskip 5mm
  \renewcommand{\baselinestretch}{1.0}\small
  {#1}\newline #2\par
  \renewcommand{\baselinestretch}{1.1}\normalsize
  \vskip 6mm
}

%===================
%  section: 2 lines before, one after, bold, normal size, all caps
%  subsection: 1 line before, none after, bold, normal size
%  subsection: 1 line before, none after, italic, normal size
%===================

\renewcommand\section{%
  \@startsection{section}{1}{\z@}%
  {-20\p@ \@plus -4\p@ \@minus -4\p@}%
  {10\p@ \@plus 4\p@ \@minus 4\p@}%
  {\normalfont\bfseries\boldmath\MakeUppercase}}
\renewcommand\subsection{%
  \@startsection{subsection}{2}{\z@}%
  {-10\p@ \@plus -4\p@ \@minus -4\p@}%
  {1\p@ \@plus 1\p@ \@minus 1\p@}%
  {\normalfont\normalsize\bfseries\boldmath}}
\renewcommand\subsubsection{%
  \@startsection{subsubsection}{3}{\z@}
  {-10\p@ \@plus -4\p@ \@minus -4\p@}
  {1\p@ \@plus 1\p@ \@minus 1\p@}
  {\normalfont\normalsize\underline}}


%===================
%  bibliography
%===================

\renewenvironment{thebibliography}[1]{%
  \section*{References}
  \renewcommand{\baselinestretch}{1.0}
  \footnotesize
  \list{%
    \@biblabel{\@arabic\c@enumiv}}%
    {\settowidth\labelwidth{\@biblabel{#1}}%
      \leftmargin\labelwidth
      \advance\leftmargin\labelsep
      \usecounter{enumiv}%
      \let\p@enumiv\@empty
      \renewcommand\theenumiv{\@arabic\c@enumiv}
  }%
}%
{ \endlist
  \renewcommand{\baselinestretch}{1.1}
  \normalsize
}
