%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Unofficial EGRWS document class for Latex 2e
%
% Authors: Jan Prikryl <prikryl@acm.org>
%
% Simplified version of the Latex 2.09 style created by Phillippe
% Bekaert and adopted for Latex 2e by Alvar Vinacua and Marta
% Fairen. Some hard-core hacks adopted from works of Petr Olsak.
%
% Thanks to Philippe for his remarks.
%
% Changes:
%
% 1997/07/28 - First version.
% 1998/02/03 - Added 'nopsfonts' option
%            - Math is typeset with PostScript fonts by default
%            - Corrected the output of \maketite when \author and 
%              \institiution are used more than once
% 1998/03/20 - 'thebibliography' environment redefined
%            - Low-level routines used by \item redefined to
%              produce a more compact output
%            - Small change of \@makecaption to produce more
%              compact output too
%            - 'abstract' redefined
% 1998/03/21 - Minor changes (spacing, title font)
%            - Removed the duplicated definition of \small
% 1998/03/22 - Redefined \normalsize so that \baselineskip will be
%              really 11pt now
%            - Captions titles are ended with `.'
% 1998/05/21 - Minor changes (spell-checked, times-math is commented
%              out by default, ...) 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Class header
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{egwr}[1998/03/22 Unofficial egrw class]
%
% Let users to switch off PostScript fonts if they want to.
% This approach is probably not very intelligent, if you have an idea
% how to do it better, let me know.
%
\DeclareOption{nopsfonts}{%
  \AtEndOfPackage{%
    \renewcommand{\rmdefault}{cmr} \mathversion{normal} } }
%
% Ignore all the options
%
\DeclareOption*{%
  \ClassWarning{egwr}{Option `\CurrentOption' ignored}%
}
%
% Process the options from user
%
\ProcessOptions\relax
%
% Load the article class
%
\LoadClass[10pt]{article}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Adobe Times Roman is the standard font
%
\renewcommand{\rmdefault}{ptm}
%
% Default math alphabet
%
\DeclareMathVersion{egrw}
\SetMathAlphabet{\mathnormal}{egrw}{OT1}{ptm}{m}{it}
\SetMathAlphabet{\mathrm}{egrw}{OT1}{ptm}{m}{n}
\SetMathAlphabet{\mathbf}{egrw}{OT1}{ptm}{bx}{n}
\SetMathAlphabet{\mathsf}{egrw}{OT1}{phv}{m}{n}
\SetMathAlphabet{\mathit}{egrw}{OT1}{ptm}{m}{it}
\SetMathAlphabet{\mathtt}{egrw}{OT1}{pcr}{m}{n}
%
% You may try to uncomment this, but first consult the PSNFSS
% documentation. My version of PSNFSS works, but the font sizes are somehow
% mismatched - the letters of Greek alphabet seem to be bigger that they
% actually should be
%
%\SetSymbolFont{operators}{egrw}{OT1}{ptmcm}{m}{n}
%\SetSymbolFont{letters}{egrw}{OML}{ptmcm}{m}{it}
%\SetSymbolFont{symbols}{egrw}{OMS}{pzccm}{m}{n}
%\SetSymbolFont{largesymbols}{egrw}{OMX}{psycm}{m}{n}
%
\mathversion{egrw}
%
% \underbar
% \underline
%
\renewcommand{\underbar}{%
    \@latex@error{Use of \noexpand\underbar is not permitted in this style}}
\renewcommand{\underline}{%
    \@latex@error{Use of \noexpand\underline is not permitted in this style}}
%
% \normalsize
% \small
% \footnotesize
% \@listXX
%
% This has been defined in size10.clo, unfortunately they redefine
% \itemsep for the environments too ... we set another values for \itemsep
% and \parsep,  also the baselineskips for \normalsize, \small, and
% \footnotesize are (hopefully) redefined. 
%
\renewcommand\normalsize{%
   \@setfontsize\normalsize\@xpt\@xipt
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\normalsize
\renewcommand\small{%
   \@setfontsize\small\@ixpt\@xpt%
   \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@
   \abovedisplayshortskip \z@ \@plus2\p@
   \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
   \def\@listi{\leftmargin\leftmargini
               \topsep 4\p@ \@plus2\p@ \@minus2\p@
               \parsep 0.5\p@ \@plus0.5\p@ \@minus0.2\p@
               \itemsep 0pt}%
   \belowdisplayskip \abovedisplayskip
}
\renewcommand\footnotesize{%
   \@setfontsize\footnotesize\@viiipt\@ixpt%
   \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@
   \abovedisplayshortskip \z@ \@plus\p@
   \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@
   \renewcommand\@listi{\leftmargin\leftmargini
               \topsep 3\p@ \@plus\p@ \@minus\p@
               \parsep 2\p@ \@plus\p@ \@minus\p@
               \itemsep 0pt}%
   \belowdisplayskip \abovedisplayskip
}
\renewcommand\@listi{\leftmargin\leftmargini
            \parsep 0.5\p@ \@plus0.5\p@ \@minus0.2\p@
            \topsep 8\p@ \@plus2\p@ \@minus4\p@
            \itemsep 0pt}
\let\@listI\@listi
\renewcommand\@listii{\leftmargin\leftmarginii
              \labelwidth\leftmarginii
              \advance\labelwidth-\labelsep
              \topsep    4\p@ \@plus2\p@ \@minus\p@
              \parsep    2\p@ \@plus\p@  \@minus\p@
              \itemsep 0pt}
\renewcommand\@listiii{\leftmargin\leftmarginiii
              \labelwidth\leftmarginiii
              \advance\labelwidth-\labelsep
              \topsep    2\p@ \@plus\p@\@minus\p@
              \parsep    \z@
              \partopsep \p@ \@plus\z@ \@minus\p@
              \itemsep 0pt}
%
% Page dimensions
%
\textwidth 12.2truecm
\textheight 19.4truecm
%
% \baselineslip
%
\baselineskip 11pt
%
% No page numbers
%
\pagestyle{empty}
%
% \topskip
%
\topskip 0pt
%
% Page margins
%
\topmargin 12truemm
\oddsidemargin 19truemm 
%
% \institute
% \institution
%
% We are using two counters to define macros \auth@@r0, \auth@@r1 and
% \insti@@0 and so on. Doing so, data provided by particular calls of
% \author and \institution are stored as different macros which are then
% called when performing the \maketitle command
%
\tracingmacros=2 \newcount\egrw@authors \egrw@authors=0
\newcount\egrw@instis \egrw@instis=0
%
\renewcommand{\author}[1]{%
  \expandafter\gdef \csname auth@@r\the\egrw@authors\endcsname {#1}%
  \advance\egrw@authors by 1
}
\newcommand{\institute}[1]{\institution{#1}}
\newcommand{\institution}[1]{
  \expandafter\gdef \csname insti@@\the\egrw@instis\endcsname {#1}%
  \advance\egrw@instis by 1
}
%
% abstract environment
%
% It is possible to temporarily set \catcode of the newline to 10
% (space) so taht one can get rid of all the newlines that would
% produce paragraph spacing before and after the abstract; as I am not
% really sure that it has to be done like that though, I leave it
% commented out.
%
% In Latex 2.09 it was possible to use either the \abstract{} command or
% the abstract environment. This is IMHO longer possible in 2e, so do not
% expect any warnings when you call \abstract{}. The only effect would be
% the whole TeX going bullistic as \abstract is in fact the opening command
% of the abstract environment - and the corresponding \endabstract is never
% called in this case.    
%
\renewenvironment{abstract}{%
  \parindent 0pt \parskip 0pt
    \vspace*{20pt}%
    \hspace*{1truecm}%
%    \catcode13=10
    \small
    \begin{minipage}[l]{10.2cm}%
        \textbf{Abstract.} }% The space is important!
    {\end{minipage}%
    \vspace*{5pt}
    \catcode13=5
    }
%
% \maketitle
%
% Two temporary counters are used to select the n-th \author or \institution
% data. After the check, that the user has supplied the same number of
% \author and \institution command, we perform a loop over oll given data
% and print them out.
% 
\newcount\egrw@author@t \newcount\egrw@insti@t
\def\egrw@counterror{%
  \ClassError{egrw}{\the\egrw@authors\space \noexpand\author used, but only
    \the\egrw@instis\space \noexpand\institution found}{You have to use the
    same number of \noexpand\author and \noexpand\institution commands.}
}
\def\auth@r{\csname auth@@r\the\egrw@author@t\endcsname}
\def\insti@{\csname insti@@\the\egrw@insti@t\endcsname}
\def\auth@rs{%
  \egrw@author@t=0
  \egrw@insti@t=0
  \let\next=\egrw@counterror
  \ifnum\egrw@authors=\egrw@instis \let\next=\auth@rs@ \fi
  \next
}
\def\auth@rs@{%
  \vspace*{1em}%
  {\normalsize \auth@r \par}%
  \vspace*{0.3em}%
  {\small \insti@ \par}%
  \advance\egrw@author@t by 1
  \advance\egrw@insti@t by 1
  \ifnum\egrw@author@t=\egrw@authors \let\next=\relax \fi
  \next
}
\renewcommand{\maketitle}{
    \parskip 0pt
    \begin{center}%
        \vspace*{3pt}
        {\LARGE\bf\boldmath \@title \par}%
        \auth@rs
    \end{center}%
}
%
% \secnumdepth
%
\setcounter{secnumdepth}{2}
%
% \section
% \subsection
% \subsubsection
%
\renewcommand{\section}{\@startsection{section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\large\bfseries}}
\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
                                   {-3.25ex\@plus -1ex \@minus -.2ex}%
                                   {1.5ex \@plus .2ex}%
                                   {\normalfont\normalsize\bfseries}}
\renewcommand{\subsubsection}[1]{\@startsection{subsubsection}{3}{\z@}%
                                   {-3.25ex\@plus -1ex \@minus -.2ex}
                                   {-0.8em}%
                                   {\normalfont\normalsize\bfseries}{#1.}}
\renewcommand{\paragraph}[1]{\@startsection{paragraph}{4}{\z@}%
                                   {3.25ex \@plus1ex \@minus.2ex}%
                                   {-0.8em}%
                                   {\normalfont\normalsize\itshape}{#1:}}
\renewcommand{\subparagraph}{%
  \@latex@error{You cannot use \noexpand\subparagraph in this style}}
%
% caption
%
% I had troubles with \baselineskip in captions and solved it by adding
% \baselineskip 10pt; it does not look very clean and I am not stating that
% it is ...
% 
\renewcommand{\@makecaption}[2]{%
  {\baselineskip 10pt
   \vskip\abovecaptionskip
   \sbox\@tempboxa{{\small {\bf #1} #2}}%
   \ifdim \wd\@tempboxa >\hsize
     {\small {\bf #1} #2}\par
   \else
     \global \@minipagefalse
     \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
   \fi
   \vskip\belowcaptionskip}}
%
% figure
%
\renewcommand{\figurename}{Fig.}
\def\fnum@figure{\figurename~\thefigure{}.}
%
% table
%
\def\fnum@table{\tablename~\thetable{}.}
%
% thebibliography
%
% thebibliography environment uses different label style and is typeset in
% \small instead of \normalsize
%
\renewcommand{\@biblabel}[1]{#1.}
\renewenvironment{thebibliography}[1]
     {\section*{\refname
        \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}}%
      \small % Here is the only change against article.cls
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy
      \clubpenalty4000
      \@clubpenalty \clubpenalty
      \widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% End of egwr class
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
