% 
% e-Informatyka.pl TeX styles definitions
% 

\ProvidesClass{einformatyka}[2005/06/22]
\NeedsTeXFormat{LaTeX2e}


\PassOptionsToClass{12pt}{article}
\PassOptionsToClass{twoside}{article}
\PassOptionsToClass{a4paper}{article}
\ProcessOptions
\LoadClass{article}

\setlength\textwidth{150mm}
\setlength\marginparwidth{0mm}
\setlength\marginparsep{0mm}
\setlength\oddsidemargin{10mm}
\setlength\evensidemargin{0mm}

\RequirePackage{fancyhdr}
\thispagestyle{empty}
\pagestyle{fancy}

% potrzebne dla komendy \collect@body
\RequirePackage{amsmath}


\def\title#1{\xdef\@etitle{#1}}
\def\subtitle#1{\xdef\@esubtitle{#1}}
\def\keywordset#1{\xdef\@ekeywordset{#1}}

\def\firstname#1{\xdef\@efirstname{#1}}
\def\surname#1{\xdef\@esurname{#1}}
\def\email#1{\xdef\@eemail{#1}}
\def\orgname#1{\xdef\@eorgname{#1}}
\def\orgdiv#1{\xdef\@eorgdiv{#1}}

\newenvironment{authorgroup}{}{
 \gdef\@edots\undefined
 \gdef\@eauthors\undefined
 \gdef\@eorgs\undefined
 \gdef\@eemails\undefined
}

\renewenvironment{author}{}{
 % polacz nazwe organizacji z nazwa jej oddzialu
 \xdef\@etmporg{%
   \ifx\@eorgdiv\undefined\else
     \@eorgdiv
   \fi
   \ifx\@eorgdiv\undefined\else\ifx\@eorgname\undefined\else,\ \fi\fi  
   \ifx\@eorgname\undefined\else
     \@eorgname
   \fi
 }

 \ifx\@elastorg\undefined
  \xdef\@elastorg{empty}
 \fi

 % czy podany orgdiv lub orgname
 \ifx\@eorgdiv\undefined
   \ifx\@eorgname\undefined
   \else
     \xdef\@ethisorg{\@etmporg}
   \fi
 \else
   \xdef\@ethisorg{\@etmporg}
 \fi

 % jezeli organizacja nie podana to nie zwiekszamy gwiazdek
 \ifx\@ethisorg\undefined\else
   % jezeli poprzednia organizacja jest identyczna, to nie zwiekszaj gwiazdek
   \ifx\@ethisorg\@elastorg\else
     \xdef\@edots{\ifx\@edots\undefined\else\@edots\fi*}
   \fi
 \fi

 % dodaj autora do listy autorow
 \ifx\@efirstname\undefined
   \ClassError{einformatyka}{Author firstname not defined!}{}
  \else
   \ifx\@esurname\undefined
     \ClassError{einformatyka}{Author surname not defined!}{}
   \else
     \xdef\@eauthors{%
      \ifx\@eauthors\undefined\else
        \@eauthors,\ 
      \fi
      \ifx\@efirstname\undefined\else
        \@efirstname\ 
      \fi

      \ifx\@esurname\undefined\else
        \@esurname
      \fi

      \ifx\@ethisorg\undefined\else
        $^{\@edots}$\ignorespaces
      \fi
    }
  \fi
 \fi

 % dodaj organizacje do listy organizacji (jezeli niepusta i nieidentyczna z ostatnia)
 \ifx\@ethisorg\undefined\else
   \ifx\@ethisorg\@elastorg\else
    \xdef\@eorgs{
      \ifx\@eorgs\undefined\else \@eorgs \protect\break \fi
       $^\@edots$\@ethisorg
     }
   \fi
 \fi

 % dodaj maila do listy maili
 \ifx\@eemail\undefined\else
  \xdef\@eemails{\ifx\@eemails\undefined\else\@eemails \ \fi
    \@eemail 
  }
 \fi

 \ifx\@ethisorg\undefined\else
   \xdef\@elastorg{\@ethisorg}
 \fi

 \gdef\@efirstname\undefined
 \gdef\@esurname\undefined
 \gdef\@eemail\undefined
 \gdef\@eorgname\undefined
 \gdef\@eorgdiv\undefined
 \gdef\@ethisorg\undefined
}

\def\@storeabstract#1{\gdef\@eabstract{#1}}
\renewenvironment{abstract}[1][-]{\collect@body\@storeabstract}{}

\def\@storeepigraph#1{\gdef\@eepigraph{#1}}
\newenvironment{epigraph}{\collect@body\@storeepigraph}{}



\newenvironment{articleinfo}
{
 \begin{center}
}{
 \ifx\@etitle\undefined
  \ClassError{einformatyka}{Title not defined!}{}
 \else
  {\bf\LARGE \@etitle} 
 \fi

 \ifx\@esubtitle\undefined\else
  \vspace{2mm} {\large \@esubtitle} 
 \fi

 \vspace{7mm} 

 \ifx\@eauthors\undefined
   \ClassError{einformatyka}{Authors not defined!}{}
 \else
   {\large \@eauthors }
 \fi

 \ifx\@eorgs\undefined\else
  \vspace{1mm} {\small\it \@eorgs} 
 \fi

 \ifx\@eemails\undefined\else
  \vspace{1mm} {\small\tt \@eemails} 
 \fi

 \ifx\@eepigraph\undefined\else
  \vspace{5mm}
  \begin{minipage}{0.9\textwidth}
   \begin{flushright}
    \small\it \@eepigraph
   \end{flushright}
  \end{minipage}
 \fi


 \ifx\@eabstract\undefined
   \ClassError{einformatyka}{Abstract not defined!}{}
 \else
  \vspace{5mm} {\bf Streszczenie} 

  \vspace{1mm}
  \begin{minipage}{0.9\textwidth}\small
    \@eabstract
  \end{minipage} \vspace{1mm}
 \fi


 \ifx\@ekeywordset\undefined\else
  \vspace{2mm}
  \begin{minipage}{0.9\textwidth}
    {\bf S\l owa kluczowe:} \@ekeywordset
  \end{minipage}
 \fi

 \vspace{3mm}

 \end{center}

 \lfoot{}\cfoot{}\rfoot{}
 \lhead[\thepage]{\@etitle}
 \rhead[\@etitle]{\thepage}

 \gdef\@earticleinfo
}

\AtEndDocument{
 \ifx\@earticleinfo\undefined
   \ClassError{einformatyka}{ArticleInfo not defined!}{}
 \fi
}
