%%%%%%%%%%%%%%%%%%%%%%%% Class file for GFS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                     %%
%% Declarations,                                                       %%
%% Titlepage,                                                          %%
%% Acknowledgements,                                                   %%
%% Declaration of Authorship,                                          %%
%% Roman Pages,                                                        %%
%% Sectioning and Headings,                                            %%
%% Pagestyle Definitionsi                      (c) Paola D Ambros 2001 %% 
%%                                       edited by Dennis Felsing 2007 %%
%%                                                                     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 


%-------------------------- identification ---------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{Gfs}[2007/05/04 v0.1 Style for %
GFS, BSB] 
%-------------------------- initial code -----------------------
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions\relax
\LoadClass[a4paper,12pt]{scrreprt}
%---------------------------------------------------------------

%%%%% DECLARATIONS

% These macros are used to declare arguments needed for the
% construction of the title page and other...

\def\dept#1{\gdef\@dept{#1}}
\def\author#1{\gdef\@author{#1}}
\def\submitdata#1{\gdef\@submitdata{#1}}

\def\school#1{\gdef\@school{#1}}
\def\teacher#1{\gdef\@teacher{#1}}
\def\schoolyr#1{\gdef\@schoolyr{#1}}
\def\lesson#1{\gdef\@lesson{#1}}

\def\type#1{\gdef\@type{#1}}
\def\date#1{\gdef\@date{#1}}

%%%%% TITLEPAGE

\def\titlep
{
	\thispagestyle{empty}
	%\null\vskip1cm   
	\begin{flushleft}
	{
		\large\expandafter
		{
			\@school\\
			\@dept\\
			\@lesson\\
			Lehrer: \@teacher\\
			\@schoolyr\\
		}
	}
	\end{flushleft}
	\vfill
	\begin{center}
	{
		\Huge\bf\uppercase\expandafter
		{
			\rotatebox{90}{\scalebox{0.5}{\includegraphics{logo}}}
		}
	}
	\end{center}
	\vfill
	\begin{flushright}
	{
        \large\expandafter
		{
			vorgelegt von: {\bf\@author}\\
			\@date\\
		}
	}
	\end{flushright}
	\newpage
}

%%%%% DECLARATION OF AUTHORSHIP

% The standard declaration is created.

\def\erklaerung{\newpage%
     \thispagestyle{empty}%
     \null\vskip1in%
     \begin{center}
      {\Large \scshape Erkl\"arung:}
     \end{center}
     \vspace{0.5cm}

  Wir versichern, dass wir die schriftliche Hausarbeit selbst\"andig
  verfasst und keine anderen als die angegebenen Quellen und
  Hilfsmittel benutzt habe. Alle Stellen der Arbeit, die dem Wortlaut
  oder dem Sinne nach anderen Werken entnommen sind, haben wir in jedem Fall
  unter Angabe der Quelle deutlich als Entlehnung kenntlich gemacht.

  \medskip

  \@submitdata,
\newpage}


%%%%% ROMANPAGES

% The romanpages environment sets the page numbering to lowercase roman one
% for the contents and figures lists. It also resets page-numbering
% for the remainder of the dissertation (arabic, starting at 1). 

\newenvironment{romanpages}
{\setcounter{page}{1}
  \renewcommand{\thepage}{\roman{page}}}
{\newpage\renewcommand{\thepage}{\arabic{page}}\setcounter{page}{1}}


%%%%% SECTIONING AND HEADINGS

% Chapter, section and subsection HEADINGS are redefined. The spacing
% is changed. All titles appear centred and in small caps. 

\def\@makechapterhead#1{%
  \vspace*{10\p@}%  changed from 50\p@
  {\parindent \z@ \raggedright \normalfont \ifnum \c@secnumdepth
    >\m@ne \centering \Large\scshape \@chapapp\space \thechapter
        \par\nobreak
        \vskip -5\p@
    \fi
    \interlinepenalty\@M
    \center{\Large\scshape #1}\par\nobreak
    \vskip 40\p@
  }}

\def\@makeschapterhead#1{%
  \vspace*{10\p@}%  the same as above 
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
   \centering \Large \scshape #1\par\nobreak
    \vskip 40\p@
  }}

\renewcommand\section{\ifnum \value{section} > 0 \newpage \fi \@startsection {section}{1}{\z@}%
                                  {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\centering\scshape\large}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\scshape}}

% The TABLE OF CONTENTS appears in the same style:
% Chapter headings appear in small caps and
% chapter page numbers remain in boldface.

\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode\scshape\large %instead of  \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
  #1\nobreak\hfil\bfseries\normalsize \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      %\bfseries added for page number  
      \penalty\@highpenalty
    \endgroup
  \fi}

%%%%% new PAGE STYLE definitions: 

% 1. Chapter number and chapter title appear at the head of the page, the
% page number centered at the foot.

\newcommand{\ps@mythesis}{%
   \renewcommand{\@oddfoot}{\hfil\thepage\hfil}
   \renewcommand{\@oddhead}{\hfil{\scshape\rightmark}\hfil}%
    \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markright {\MakeUppercase{%
        \ifnum \c@secnumdepth >\m@ne
            \@chapapp\ \thechapter. \ %
       \fi
        ##1}}}}

% 2. As the above, but a thin rule appears under the header of the page.

\newcommand{\ps@ruled}{%
   \renewcommand{\@oddfoot}{\hfil\thepage\hfil}
   \renewcommand{\@oddhead}{\begin{minipage}{\textwidth}%
    {\hfil{\scshape\small\rightmark}\hfil \\[-9pt]%
     \rule{\textwidth}{0.3pt}}\end{minipage}}% 
    \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markright {%
        \ifnum \c@secnumdepth >\m@ne
            \@chapapp\ \thechapter. \ %
       \fi
        ##1}}}

% 3. As the above, but with date on the bottom. Good for telling apart
% different print-outs.

\newcommand{\ps@dateruled}{%
   \renewcommand{\@oddfoot}{\hfil\hfil\thepage\hfil\today}
   \renewcommand{\@oddhead}{\begin{minipage}{\textwidth}%
    {\hfil{\scshape\small\titolo}\hfil \\[-10pt]%
     \rule{\textwidth}{0.3pt}}\end{minipage}}%
    \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markright {\textsc{%
        \ifnum \c@secnumdepth >\m@ne
            \@chapapp\ \thechapter. \ %
       \fi
        ##1}}}}

% 4. Foot of the page is empty. Chapter number, chapter name and page
% numer appear at the top of the page, a thin rule under the header.

\def\ps@mypage{%
  \let\@oddfoot\@empty
    \def\@oddhead{\begin{minipage}{\textwidth}%
     {{\scshape\titolo}\hfill\thepage \\[-9pt]%
      \rule{\textwidth}{0.6pt}}\end{minipage}}%
    \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markright {%
        \ifnum \c@secnumdepth >\m@ne
            \@chapapp\ \thechapter. \ %
        \fi
        ##1}}}
