% \iffalse meta-comment
%
% This package can be used for writing a thesis in the Hebrew/English
% languages, at the Technion --- Israel Institute of Technology.
% 
% Copyright 1994 Irina Abramovici, Taub Computer Center, Technion ---
% Israel Institute of Technology, e-mail ccaiire@tx.technion.ac.il.
%
% Copyright 1997-1998 Boris Lavva, e-mail lavva@tx.technion.ac.il.
% 
% Copyright 1997-1998 Tzafrir Cohen, e-mail tzafrir@technion.ac.il.
% 
% For further copyright information see any other copyright notices in 
% this file.
% 
% This file is contributed to the Babel system release 3.6.
% ---------------------------------------------------------
%   This system is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% 
%   For error reports concerning UNCHANGED versions of this file no
%   more than one year old, see bugs.txt.
% 
%   Please do not request updates from me directly.  Primary
%   distribution is through the CTAN archives.
% 
% 
% IMPORTANT COPYRIGHT NOTICE:
% 
% You are NOT ALLOWED to distribute this file alone.
% 
% You are allowed to distribute this file under the condition that it
% is distributed together with all the files listed in manifest.txt.
% 
% If you receive only some of these files from someone, complain!
% 
% Permission is granted to copy this file to another file with a
% clearly different name and to customize the declarations in that
% copy to serve the needs of your installation, provided that you
% comply with the conditions in the file legal.txt from the LaTeX2e
% distribution.
% 
% However, NO PERMISSION is granted to produce or to distribute a
% modified version of this file under its original name.
%  
% You are NOT ALLOWED to change this file.
% 
% Babel package for LaTeX version 2e
% Copyright (C) 1989 -- 1997 by Johannes Braams,
%                            TeXniek
%                            All rights reserved.
%
%% LaTeX2e iitthes class, derived by Boris Lavva from original hebtech
%% macros created for LaTeX 2.09.
%% 
%% Copyright 1994 Irina Abramovici, Taub Computer Center, Technion ---
%% Israel Institute of Technology, e-mail ccaiire@tx.technion.ac.il.
%%
%% This package can be used for writing a thesis in the Hebrew/English
%% languages, at the Technion --- Israel Institute of Technology.
%%
%% Bugs reports and suggestions should be addressed to 
%% Irina Abramovici, Taub Computer Center, Technion, tel: 04-8293690,
%% e-mail: ccaiire@tx.technion.ac.il 
%% OR 
%% to Boris Lavva, tel: 04-8294659, e-mail: lavva@tx.technion.ac.il.
%% 
%% This package is an experimental meant to answer to the demands of
%% the Graduate School of the Technion --- Israel Institute of
%% Technology.
%% 
% \fi
%
% \CheckSum{1324}
%
% \iffalse
%<iitthes>\NeedsTeXFormat{LaTeX2e}[1996/06/01]
%<iitthes>\ProvidesClass{iitthes}
%<*driver>
\ProvidesFile{iitthes.drv}
%</driver>
% \fi
% \ProvidesFile{iitthes.dtx}
        [1997/12/09 v.1.0a Technion thesis class]
%
% \iffalse
% \subsection{A driver for this document}
%
% The next bit of code contains the documentation driver file for
% \TeX{}, i.e., the file that will produce the documentation you are
% currently reading. It will be extracted from this file by the \dst{}
%  program.
%
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\title{Hebrew/English thesis class for \LaTeXe}
\author{Boris Lavva\\%
        Original version for \LaTeX2.09 by Irina Abramovici}
\date{Printed \today}
\begin{document}
   \maketitle
   \DocInput{iitthes.dtx}
\end{document}
%</driver>
%    \end{macrocode}
% \fi
%
% \providecommand\scrunch{\setlength{\itemsep}{-.05in}}
% \providecommand\babel{\textsf{babel}}
% \providecommand\file[1]{\texttt{#1}}
% \providecommand\pkg[1]{\texttt{#1}}
% \GetFileInfo{iitthes.dtx}
%
% \changes{hebtech~0.1}{1994/??/??}{%
%    Initial version. Provides \texttt{hebtech.sty} style file for
%    \LaTeX 2.09 with support for old 7-bit encoding only. Only
%    English language thesis with Hebrew cover, title and abstract
%    pages is supported (by Irina Abramovici)} 
% \changes{hebtech~1.0a}{1998/12/09}{%
%    \LaTeXe\ changes and updates. Now it is \texttt{hebtech.cls}
%    \LaTeXe\ document class, which supports all available input and
%    font encodings and thesis written both in Hebrew and English
%    (by Boris Lavva)}
% \changes{iitthes~1.1}{2002/07/09}{%
%    Renamed it to \texttt{iitthes}
%    (by Tzafrir Cohen)}
%
% \section{Writing Hebrew/English thesis with \LaTeXe}^^A
% \label{sec:iitthes}
%
%    The file \file{\filename}\footnote{The Hebrew/English thesis
%    class for \LaTeXe{} described in this section have version number
%    \fileversion\ and were last revised on \filedate.} can be useful
%    for writing a thesis or dissertation in both Hebrew and English
%    languages, at the Technion --- Israel Institute of Technology.
%    This package is an experimental meant to answer to the demands of
%    the Graduate School of the Technion, but can be easily adjusted
%    (I hope) for writing theses at other academic institutions at
%    Israel.
%
%    Original version of this style (called \pkg{iitthes.sty}) for
%    \LaTeX2.09 was written in April 1994 by Irina Abramovici from the
%    Taub Computer Center, Technion and was updated for \LaTeXe{} with
%    \babel{} support by Boris Lavva. The thesis class can be used for
%    English documents with a number of Hebrew parts, and for Hebrew
%    documents with a number of English parts. In addition, any other
%    languages supported by \babel\ can be used freely in thesis.
%
% \StopEventually{}
%
% \subsection{Common definitions}
%
%    We use standard \LaTeXe{} \pkg{report} class as the base of our
%    \pkg{iitthes} class. A thesis should be printed in A4 paper,
%    using $12pt$ fonts, one-sided.
%    \begin{macrocode}
%<*iitthes>
\ExecuteOptions{a4paper,12pt,oneside,onecolumn,final,openany}
%    \end{macrocode}
%
%    Declare some conditionals that will be used when processing the options.
%    All of them are prefixed with \texttt{iitthes@}:
%
%    \texttt{hebibm}, \texttt{nohebibm}: Should the IBM Type1 fonts be used 
%    rather than the default Hebrew fonts? Default: no. 
%    \begin{macrocode}
\newif\ifiitthes@hebibm   \iitthes@hebibmfalse
\newif\ifiitthes@eightbit \iitthes@eightbitfalse
\DeclareOption{hebibm}  {\iitthes@hebibmtrue \iitthes@eightbittrue}%
\DeclareOption{nohebibm}{\iitthes@hebibmfalse\iitthes@eightbitfalse}%
%    \end{macrocode}
%
%    \texttt{stdtheo}, \texttt{nostdtheo}: Should the class define some 
%    standard (that is: what Tzafrir needed) theorem-like environments?
%    Default: yes. 
%    \begin{macrocode}
\newif\ifiitthes@stdtheo  \iitthes@stdtheotrue
\DeclareOption{stdtheo}  {\iitthes@stdtheotrue}%
\DeclareOption{nostdtheo}{\iitthes@stdtheofalse}%
%    \end{macrocode}
%
%    \texttt{setspace}, \texttt{nosetspace}: Should the class set inter-line 
%    spacing to doublespace?
%    Default: yes. 
%    \begin{macrocode}
\newif\ifiitthes@setspace  \iitthes@setspacetrue
\DeclareOption{setspace}  {\iitthes@setspacetrue}%
\DeclareOption{nosetspace}{\iitthes@setspacefalse}%
%    \end{macrocode}
%
%    \texttt{hebmain}, \texttt{nohebmain}: Should the thesis be Hebrew with
%    some English (hebmain) or English with some Hebrew (nohebmain).
%    Default: yes
%    \begin{macrocode}
\newif\ifiitthes@hebmain  \iitthes@hebmaintrue
\DeclareOption{hebmain}  {\iitthes@hebmaintrue}%
\DeclareOption{nohebmain}{\iitthes@hebmainfalse}%
%    \end{macrocode}
%
%    \texttt{enccp862}, \texttt{enc8859-8}, \texttt{enccp1255},
%    \texttt{encsi960}: set input (Hebrew) encoding. Defualt: enforce no input
%    encoding, and use heblatex's default encoding (which should be 8859-8 or
%    cp1255)
%
%    Note: si960 (7bit Hebrew) is only here for the sake of completeness.
%    Please don't use it.
%    \begin{macrocode}
\DeclareOption{enccp862}{\providecommand{\class@inputenc}{cp862}}%
\DeclareOption{enc8859-8}{\providecommand{\class@inputenc}{8859-8}}%
\DeclareOption{enccp1255}{\providecommand{\class@inputenc}{cp1255}}%
\DeclareOption{encsi960}{\providecommand{\class@inputenc}{si960}}%
%    \end{macrocode}
%
%    \texttt{draft}: Should some draft options be applied?
%    default: no
%    \begin{macrocode}
\DeclareOption{draft}{%
  \PassOptionsToPackage{all,light}{draftcopy}
  \PassOptionsToClass{draft}{report}
  \AtEndOfClass{\RequirePackage{draftcopy}}}
%    \end{macrocode}
%    We pass all options to the \pkg{report} class and load it.
%    \begin{macrocode}
\DeclareOption*{%
  \PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions
\LoadClass{report}
%    \end{macrocode}
%    Double spacing is required by the Graduate School, so we include
%    \pkg{setspace} package. This is supported \LaTeXe{} package and
%    can be found on CTAN.
%    \begin{macrocode}
\ifiitthes@setspace
  \RequirePackage{setspace}
  \AtBeginDocument{\doublespacing}
\fi
%    \end{macrocode}
%    Check if the any of the \texttt{enc} options was used. If so: load the
%    apprpriate input encoding:
%    \begin{macrocode}

\ifx\iitthes@inputenc\@undefined\else% 
  % Do the following if an input encoding option was given
  \RequirePackage[\iitthes@inputenc]{inputenc}%
\fi
%    \end{macrocode}
%    Set the output Hebrew encoding of heblatex to 8bit (HE8), if required:
%    \begin{macrocode}

\ifiitthes@eightbit
  \def\HeblatexEightBitFont{}
\fi
%    \end{macrocode}


%
%    unless we were asked otherwise (the option 'nostdtho' given):
%    add standard theorem environments
%
%    \begin{macrocode}
\ifiitthes@stdtheo%
  \newtheorem{definition}{definitionname}[chapter]%
  \newtheorem{theorem}[definition]{\theoremname}%
  \newtheorem{lemma}[definition]{\lemmaname}%
  \newtheorem{claim}[definition]{\claimname}%

  % The definition of proof is borowed fom LyX, to have a proper QED.
  \newenvironment{proof}{%
    \textbf{\proofname:}%
  }{%
    \hfill\rule{2mm}{2mm}\par\vspace{2mm}%
  }
\fi%
%    \end{macrocode}


%    Thesis should be bilingual and use Hebrew and English by
%    default. If you want to add other languages, pass them as options
%    to class, for example:
%    \begin{quote}
%    |\documentclass[russian,spanish,greek]{iitthes}|
%    \end{quote}
%    Note, that hebrew is the last language in |\RequirePackage| line,
%    and will be used by default at the beginning of document, unless the 
%    \texttt{nohebmain} layout is in effect
%    \begin{macrocode}
\ifiitthes@hebmain%
  \RequirePackage[english,hebrew]{babel}%
\else%
  \RequirePackage[hebrew,english]{babel}%
\fi
%    \end{macrocode}
%    We have to print Jewish date in addition to Gregorian one. Hence,
%    the \pkg{hebcal} package will be used.
%    \begin{macrocode}
\RequirePackage{hebcal}
%    \end{macrocode}
%
%  \begin{macro}{\Hebrewdate}
%  \begin{macro}{\FormatForEnglish}
%  \begin{macro}{\FormatForHebrew}
%  \begin{macro}{\HebrewMonthNameInEnglish}
%    CURRENTLY REMMED-OUT (tzafrir)
%
%    |\HebrewDate{|\emph{day}|}{|\emph{month}|}{|\emph{year}|}| macro
%    and two additional macros |\Format|\-|For|\-|English| and
%    |\FormatForHebrew| from the \pkg{hebcal} package should be
%    redefined to print ``short'' date (without day).
%
%    We found that |\MakeUppercase| command for \LaTeXe does not work
%    with |hebcal| macros, so we have to redefine
%    |\HebrewMonthNameInEnglish| to print Hebrew months in uppercase.
%    \begin{macrocode}
% \renewcommand{\Hebrewdate}[3]{% 
%   \HebrewFromGregorian{#1}{#2}{#3}
%      {\Hebrewday}{\Hebrewmonth}{\Hebrewyear}%
%   \if@rl%           Hebrew (right-to-left) mode 
%      \FormatForHebrew{\Hebrewmonth}{\Hebrewyear}% 
%   \else%            English mode 
%      \FormatForEnglish{\Hebrewmonth}{\Hebrewyear}%
%   \fi}
% \renewcommand{\FormatForEnglish}[2]{% 
%   \HebrewMonthNameInEnglish{#1}{#2}, \space\number#2}
% \renewcommand{\FormatForHebrew}[2]{% 
%   \HebrewMonthName{#1}{#2} \space\HebrewYearName{#2}}
% \renewcommand{\HebrewMonthNameInEnglish}[2]{%
%   \ifnum #1 = 7%
%      \CheckLeapHebrewYear{#2}%
%      \if@HebrewLeap ADAR II\else ADAR\fi%
%   \else%
%      \ifcase #1%
%         % nothing for 0
%         \or TISHREI%
%         \or HESHVAN%
%         \or KISLEV%
%         \or TEBETH%
%         \or SHEBAT%
%         \or ADAR I%
%         \or ADAR II%
%         \or NISAN%
%         \or IYAR%
%         \or SIVAN%
%         \or TAMMUZ%
%         \or AV%
%         \or ELUL%
%      \fi
%   \fi}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\engmonth}
%  \begin{macro}{\Gregoriandate}
%    CURRENTLY REMMED-OUT (tzafrir)
%
%    Gregorian date will be printed with the aid of new macro
%    |\Gregoriandate{|\emph{day}|}| |{|\emph{month}|}{|^^A
%    \emph{year}|}|
%    which is similar to |\Hebrewdate| defined above. The name of
%    Gregorian month in English is created by |engmonth| macro,
%    defined below, and in Hebrew -- by |hebmonth| macro, defined in
%    the \pkg{hebrew.ldf} Hebrew language definition file.
%    \begin{macrocode}
\newcommand\engmonth[1]{%
  \ifcase#1\or January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi}
% \newcommand{\Gregoriandate}[3]{%
%   \if@rl%
%      \hebmonth{#2} \space{\beginL\number#3\endL}%
%   \else%
%      \engmonth{#2}, \space{\number#3}%
%   \fi}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\date}
%    CURRENTLY REMMED-OUT (tzafrir)
%
%    To provide the automatic calculation of Gregorian and Hebrew
%    dates, we define 3 new counts: |\dd| for `day', |\mm| for `month',
%    and |\yy| for `year'. Their initial value will be |\today|'s day,
%    month and year. An user can provide his/her own date with changed
%    command |\date{|\emph{day}|}{|\emph{month}|}{|\emph{year}|}|.
%    \begin{macrocode}
% \newcount\dd \newcount\mm \newcount\yy
% \dd=\number\day \mm=\number\month \yy=\number\year
% \renewcommand{\date}[3]{\dd=#1 \mm=#2 \yy=#3}
%    \end{macrocode}
%  \end{macro}
%

%  \begin{macro}{\date}
%    The author should input the submition date. e.g:
%    |\date{29}{2}{2000}| . If no date is given, the defalt is today's date.
%
%    Note that the date will only be printed in a "month-year" format, however
%    a relatively exact day-of-the-month is needed because the Hebrew month
%    will also be extracted from this date.
%
%    By setting this macro, the macros |\HGMonth|, |\LGMonth|, |\LJMonth| and
%    |\HJMonth| which give a month-year name: \emph{H} is Hebrew, \emph{L} is
%    latin (the text itself), \emph{G} is Georgian and \emph{J} is Jewish (the
%    calendar used).
%    \begin{macrocode}
\providecommand{\Ldir}[1]{\beginL #1\endL} % not yet part of all heblatex-s
\newcount\iitthes@day  \iitthes@day=\day %
\newcount\iitthes@mon  \iitthes@mon=\month %
\newcount\iitthes@year \iitthes@year=\year %
\newcommand{\LGMonth}{}
\newcommand{\HGMonth}{}
\newcommand{\LJMonth}{}
\newcommand{\HJMonth}{}
\renewcommand{\date}[3]{%#1=day,#2=month,#3=year
  \newcount\iitthes@day \iitthes@day=#1 %
  \newcount\iitthes@mon \iitthes@mon=#2 %
  \newcount\iitthes@year \iitthes@year=#3 %
  \newcount\iitthes@hday %
  \newcount\iitthes@hmon %
  \newcount\iitthes@hyear %
  %
  \def\Year{#3}%
  \def\HebGMonth{\hebmonth{#2}}%
  \def\LatGMonth{\engmonth{#2}}%
  \renewcommand{\LGMonth}{\LatGMonth~\Year}%
  \renewcommand{\HGMonth}{\HebGMonth~\Ldir{\Year}}%
  \HebrewFromGregorian%
    {\iitthes@day} {\iitthes@mon} {\iitthes@year}%
    {\iitthes@hday}{\iitthes@hmon}{\iitthes@hyear}%
  \renewcommand{\LJMonth}{%
    \HebrewMonthNameInEnglish{\iitthes@hmon}{\iitthes@hyear}%
    ~\number\iitthes@hyear%
  }%
  \renewcommand{\HJMonth}{%
    \HebrewMonthName{\iitthes@hmon}{\iitthes@hyear}%
    ~\HebrewYearName{\iitthes@hyear}%
  }%
}
% initialize everything with today's date:
\date{\day}{\month}{\year}

%    \end{macrocode}
%  \end{macro}
%  \begin{macro}{\captionsenglish}
%  \begin{macro}{\captionshebrew}
%    Here we provide the default acknowledgment name in English and
%    Hebrew for use in thesis acknowledgment pages, change the
%    default bibliography name to ``References'' and add a number of
%    useful captions in English and Hebrew for use in mathematical
%    manuscripts with \LaTeX\ and \AmSTeX.
%    \begin{macrocode}
\addto\captionsenglish{%
  \def\acknowledgmentname{Acknowledgment}%
  \def\bibname{References}%
  \def\continuedname{Cont'd}%
  \def\definitionname{Definition}%
  \def\theoremname{Theorem}%
  \def\lemmaname{Lemma}%
  \def\claimname{Claim}%
  \def\corollaryname{Corollary}%
  \def\axiomname{Axiom}%
  \def\assumptionname{Assumption}%
  \def\examplename{Example}%
  \def\propertyname{Property}%
  \def\remarkname{Remark}%
  \def\problemname{Problem}%
  \def\algorithmname{Algorithm}%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\addto\captionshebrew{%
  \def\acknowledgmentname{\hebhe\hebkaf\hebresh\hebtav\ \hebtav\hebvav\hebdalet\hebhe}%
  \def\bibname{\hebresh\hebshin\hebyod\hebmem\hebtav\ \hebmem\hebqof\hebvav\hebresh\hebvav\hebtav}%
  \def\continuedname{\hebhe\hebmem\hebshin\hebfinalkaf}%
  \def\definitionname{\hebhe\hebgimel\hebdalet\hebresh\hebhe}%
  \def\theoremname{\hebmem\hebshin\hebpe\hebtet}%
  \def\lemmaname{\heblamed\hebmem\hebhe}%
  \def\claimname{\hebtet\hebayin\hebnun\hebhe}%
  \def\corollaryname{\hebmem\hebsamekh\hebqof\hebnun\hebhe}%
  \def\axiomname{\hebalef\hebqof\hebsamekh\hebyod\hebvav\hebmem\hebhe}%
  \def\assumptionname{\hebhe\hebnun\hebhet\hebhe}%
  \def\examplename{\hebdalet\hebvav\hebgimel\hebmem\hebhe}%
  \def\propertyname{\hebtav\hebkaf\hebvav\hebnun\hebhe}%
  \def\remarkname{\hebhe\hebayin\hebresh\hebhe}%
  \def\problemname{\hebbet\hebayin\hebyod\hebhe}%
  \def\algorithmname{\hebalef\heblamed\hebgimel\hebvav\hebresh\hebyod\hebtav\hebfinalmem}%
}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\@makeschapterhead}
%    Let unnumbered |\chapter*|'s header be centered.
%    \begin{macrocode}
\def\@makeschapterhead#1{%   % Heading for \chapter* command
  \vspace*{50\p@}%           % Space at top of text page.
  {\parindent \z@ \centering % Center the header
    \normalfont
    \interlinepenalty\@M
    \huge \bfseries #1\par   % Title.
    \nobreak                 % TeX penalty to prevent page break.
    \vskip 40\p@             % Space between title and text.
  }}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\bchapternn}
%    For writer's convenience: unnumbered |\chapter*| will write to
%    English (\texttt{.toc}) and Hebrew (\texttt{.cot}) table of
%    contents.
%    \begin{macrocode}
\renewcommand{\bchapternn}[2]{\chapter*{%
    \protect\if@rl #1\protect\else #2\protect\fi%
    \@mkboth{\MakeUppercase{\protect\if@rl #1\protect\else 
                                           #2\protect\fi}}%
            {\MakeUppercase{\protect\if@rl #1\protect\else 
                                           #2\protect\fi}}}
  \addcontentsline{toc}{chapter}{%
    \protect\hspace{-1.5em}\protect\numberline{}%
    \protect\if@rl #1\protect\else #2\protect\fi}
  \addcontentsline{cot}{chapter}{%
    \protect\hspace{-1.5em}\protect\numberline{}%
    \protect\if@rl #1\protect\else #2\protect\fi}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\thebibliography}
%    For writer's convenience too: bibliography chapter will write to
%    English (\texttt{.toc}) and Hebrew (\texttt{.cot}) table of
%    contents.
%    \begin{macrocode}
\let\@@thebibliography\thebibliography
\def\thebibliography{%
  \addcontentsline{toc}{chapter}{\protect\hspace{-1.5em}\protect{%
      \bfseries\protect\numberline{}\protect\bibname}}
  \addcontentsline{cot}{chapter}{\protect\hspace{-1.5em}\protect{%
      \bfseries\protect\numberline{}\protect\bibname}}
  \@@thebibliography}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\bcaptionf}
%    We define a bilingual Hebrew and English caption for figures.
%
%    Usage: |\bcaptionf{|\emph{Heb caption}|}{|\emph{Eng caption}|}|.
%    \begin{macrocode}
\newcommand{\bcaptionf}[2]{%
  \caption[\protect\if@rl \R{#1}\protect\else \L{#2}\protect\fi]{%
    \if@rl\R{#1} \protect\\ \L{Figure~\thefigure: #2}
    \else\L{#2} \protect\\ \R{\hebalef\hebyod\hebvav\hebresh~\thefigure: #1}
    \fi}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\bcaptionff}
%    Extended bilingual Hebrew and English caption for figures.
%
%    Usage: |\bcaptionff{|\emph{to Heb LOF}|}{|\emph{to Eng LOF}^^A
%           |}{|\emph{Heb caption}|}{|\emph{Eng caption}|}|.
%    \begin{macrocode}
\newcommand{\bcaptionff}[4]{%
  \caption[\protect\if@rl \R{#1}\protect\else \L{#2}\protect\fi]{%
    \if@rl\R{#3}\protect\\ \L{Figure~\thefigure: #4}
    \else\L{#4}\protect\\ \R{\hebalef\hebyod\hebvav\hebresh~\thefigure: #3}
    \fi}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\bcaptiont}
%    Bilingual Hebrew and English caption for tables (short variant).
%
%    Usage: |\bcaptiont{|\emph{Heb caption}|}{|\emph{Eng caption}|}|.
%    \begin{macrocode}
\newcommand{\bcaptiont}[2]{%
  \caption[\protect\if@rl \R{#1}\protect\else \L{#2}\protect\fi]{%
    \if@rl\R{#1} \protect\\ \L{Table~\thetable: #2}
    \else\L{#2} \protect\\ \R{\hebtet\hebbet\heblamed\hebhe~\thetable: #1}
    \fi}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\bcaptiontt}
%    Extended bilingual Hebrew and English caption for tables.
%
%    Usage: |\bcaptiontt{|\emph{to Heb LOT}|}{|\emph{to Eng LOT}^^A
%           |}{|\emph{Heb caption}|}{|\emph{Eng caption}|}|.
%    \begin{macrocode}
\newcommand{\bcaptiontt}[4]{%
  \caption[\protect\if@rl \R{#1}\protect\else \L{#2}\protect\fi]{%
    \if@rl\R{#3} \protect\\ \L{Table~\thetable: #4}
    \else\L{#4} \protect\\ \R{\hebtet\hebbet\heblamed\hebhe~\thetable: #3}
    \fi}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{thestype}
%    The meaning of |thestype| counter is:
%    \begin{description}\scrunch^^A
%       \item[1] for a research thesis,
%       \item[2] for a project thesis,
%       \item[3] for a final paper.
%    \end{description}  
%    \begin{macrocode}
\newcounter{thestype}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{grade}
%    The meaning of |grade| counter is:
%    \begin{description}\scrunch^^A
%       \item[1] for master of science, 
%       \item[2] for master,
%       \item[3] for master of technology, 
%       \item[4] for doctor of science.
%    \end{description}
%    Note that the name is confusing, and is maintained for backword
%    compatibility alone. 
%    \begin{macrocode}
\newcounter{grade}
%    \end{macrocode}
%  \end{macro}
%
% \subsection{Parameters for title pages}
%
%     All following macros are defined with 2 obligatory parameters:
%     first is the Hebrew version and second is the English one. For
%     example, for |\title| macro:
%     \begin{quote}
%     |\title{Hebrew title}{English title}|
%     \end{quote}
% 
%  \begin{macro}{\title}
%    Thesis or dissertation's title.
%    \begin{macrocode}
\def\title#1#2{\gdef\@@titleh{#1}\gdef\@@title{#2}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\author}
%    The author(s) of thesis or dissertation.
%    \begin{macrocode}
\def\author#1#2{\gdef\@@authorh{#1}\gdef\@@author{#2}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\dept}
%    The name of faculty, for example, ``Electrical Engineering
%    Department''.
%    \begin{macrocode}
\def\dept#1#2{\gdef\@@depth{#1}\gdef\@@dept{#2}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\dom}
%    The domain of research, for example, ``Computer Engineering''.
%    \begin{macrocode}
\def\dom#1#2{\gdef\@@domh{#1}\gdef\@@dom{#2}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\advisori}
%    The name of advisor (or the main advisor if there are two).
%    \begin{macrocode}
\def\advisori#1#2{\gdef\@@advisorih{#1}\gdef\@@advisori{#2}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\advisorii}
%    The name of the second advisor, if exists.
%    \begin{macrocode}
\def\advisorii#1#2{\gdef\@@advisoriih{#1}\gdef\@@advisorii{#2}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\donori}
%    The name of the person or institution which granted help in the
%    form of scholarship, if any.
%    \begin{macrocode}
\def\donori#1#2{\gdef\@@donorih{#1}\gdef\@@donori{#2}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\donorii}
%    The name of the second person or institution which granted help
%    in the form of scholarship, if any.
%    \begin{macrocode}
\def\donorii#1#2{\gdef\@@donoriih{#1}\gdef\@@donorii{#2}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\donor}
%    User-defined line to replace the default one: ``The generous
%    financial help of \ldots{} is gratefully acknowledged''. If no
%    scholarship or other financial help need to be acknowledged, this
%    macro should be included and empty, i.e.\ |\donor{}{}|.
%    \begin{macrocode}
\def\donor#1#2{\gdef\@donorh{#1}\gdef\@donor{#2}}
%    \end{macrocode}
%  \end{macro}
%
% \subsection{English part}
%
%    Here we define all internal macros that will be needed for cover,
%    title, and acknowledgment pages in the English language version.
%    The |\@line|\ldots{}, |\@thestype| and |\@donor| macros are very
%    Technion-related and should be redefined when adjusting this
%    class for another academic institution.
%    \begin{macrocode}
\def\@@title{}
\def\@@author{}
\def\@@dom{}
\def\@@advisori{}
\def\@@advisorii{}
\def\@@donori{}
\def\@@donorii{}
\def\@donor{}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@thestype{%
   \ifcase\value{thestype}%
   \or \MakeUppercase{Research Thesis}%
   \or \MakeUppercase{Project Thesis}%
   \or \MakeUppercase{Final Paper} \else {}\fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@linei{%
  \MakeUppercase{Submitted in Partial Fulfillment 
                 of the Requirements}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@lineii{%
   \ifcase\value{grade}%
        \or \MakeUppercase{For the Degree of Master of Science}%
        \or \MakeUppercase{For the Degree of Master}%
        \or \MakeUppercase{For the Degree of Master of Technology}%
        \or \MakeUppercase{For the Degree of Doctor of Science}%
        \else %
	  {}%
%           {{\Huge INCORRECT VALUE FOR COUTER GRADE(=degree). Should be 1-4}}%
   \fi%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@lineiii{%
  \if\@@dom\else%
     \ifcase\value{grade}%
        \or \MakeUppercase{in} \MakeUppercase{\@@dom}%
        \or \MakeUppercase{in} \MakeUppercase{\@@dom}%
        \or \MakeUppercase{in} \MakeUppercase{\@@dom}%
        \else{}\fi%
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@lineiv{\mbox{\hspace{-.2in}\footnotesize\MakeUppercase{%
      Submitted to the Senate of the Technion --- %
      Israel Institute of Technology}}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@linev{\footnotesize{\LJMonth}%
            \hfill\MakeUppercase{Haifa}\hfill%
            \MakeUppercase{\LGMonth}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@linevi{\MakeUppercase{This}\ 
             \@thestype\
             \MakeUppercase{was supervised by}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@linevii{\MakeUppercase{under the auspices of the}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@donor{%
  \MakeUppercase{The generous financial help of}\ %
  \MakeUppercase{\@@donori}\ %
  \ifx\empty\@@donorii\else\MakeUppercase{and \@@donorii{} }\fi%
  \MakeUppercase{is gratefully acknowledged}}
%    \end{macrocode}
%
% \subsection{Hebrew part}
%
%    Here we define all internal macros that will be needed for cover,
%    title, and acknowledgment pages in the Hebrew language version.
%    The |\@line|\ldots|h|, |\@thestypeh| and |\@donorh| macros are
%    very Technion-related and should be redefined when rewriting this
%    class for another academic institution.
%    \begin{macrocode}
\def\@@titleh{}
\def\@@authorh{} 
\def\@@depth{}
\def\@@domh{} 
\def\@@advisorih{}
\def\@@advisoriih{} 
\def\@@donorih{}
\def\@@donoriih{} 
\def\@donorh{}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@thestypeh{% 
   \ifcase\value{thestype}% 
   \or \hebhet\hebyod\hebbet\hebvav\hebresh\ \hebayin\heblamed\ \hebmem\hebhet\hebqof\hebresh%
   \or \hebhet\hebyod\hebbet\hebvav\hebresh\ \hebayin\heblamed\ \hebpe\hebresh\hebvav\hebyod\hebqof\hebtet%
   \or \hebayin\hebbet\hebvav\hebdalet\hebtav\ \hebgimel\hebmem\hebresh \else {}\fi} 
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@lineih{%
  \heblamed\hebshin\hebfinalmem\ \hebmem\hebyod\heblamed\hebvav\hebyod\ \hebhet\heblamed\hebqof\hebyod\ %
  \hebshin\heblamed\ \hebhe\hebdalet\hebresh\hebyod\hebshin\hebvav\hebtav\ %
  \heblamed\hebqof\hebbet\heblamed\hebtav\ \hebtav\hebvav\hebalef\hebresh{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@lineiih{% 
   \ifcase\value{grade}% 
        \or \hebmem\hebgimel\hebyod\hebsamekh\hebtet\hebresh\ %
            \heblamed\hebmem\hebdalet\hebayin\hebyod\hebfinalmem%
        \or \hebmem\hebgimel\hebyod\hebsamekh\hebtet\hebresh% 
        \or \hebmem\hebgimel\hebyod\hebsamekh\hebtet\hebresh\ %
            \hebbet\hebtet\hebkaf\hebnun\hebvav\heblamed\hebvav\hebgimel\hebyod\hebhe%
        \or \hebdalet\hebqof\hebtet\hebvav\hebresh\ %
            \heblamed\hebmem\hebdalet\hebayin\hebyod\hebfinalmem%
        \else {}\fi} 
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@lineiiih{% 
   \ifcase\value{grade}% 
     \or \@@domh% 
     \or \@@domh% 
     \or \@@domh% 
     \else{}\fi} 
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@lineivh{\hebhe\hebvav\hebgimel\hebshin\ \heblamed\hebsamekh\hebnun\hebtet\ %
             \hebhe\hebtet\hebkaf\hebnun\hebyod\hebvav\hebfinalnun\ \textemdash\ %
             \hebmem\hebkaf\hebvav\hebfinalnun\ %
             \hebtet\hebkaf\hebnun\hebvav\heblamed\hebvav\hebgimel\hebyod\ %
             \heblamed\hebyod\hebshin\hebresh\hebalef\heblamed}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@linevh{\HJMonth%
             \hfill\hebhet\hebyod\hebpe\hebhe\hfill%
             \HGMonth}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@linevih{% 
   \ifcase\value{thestype}% 
   \or \@thestypeh{} \hebnun\hebayin\hebshin\hebhe% 
   \or \@thestypeh{} \hebnun\hebayin\hebshin\hebhe% 
   \or \@thestypeh{} \hebnun\hebayin\hebshin\hebtav\hebhe\else{}\fi} 
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@lineviih{\hebbet\hebhe\hebdalet\hebresh\hebkaf\hebtav{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@donorh{\hebalef\hebnun\hebyod\ \hebmem\hebvav\hebdalet\hebhe{}
  \heblamed\@@donorih{}
  \ifx\empty\@@donoriih\else\hebvav\heblamed\@@donoriih{} \fi
  \hebayin\heblamed\ \hebhe\hebtav\hebmem\hebyod\hebkaf\hebhe\ \hebhe\hebkaf\hebsamekh\hebpe\hebyod\hebtav\ %
  \hebhe\hebnun\hebdalet\hebyod\hebbet\hebhe\ \hebbet\hebhe\hebshin\hebtav\heblamed\hebmem\hebvav\hebtav\hebyod}%
%    \end{macrocode}
%
% \subsection{User-level commands and macros}
%
%    The following 3 macros: |\frontmatter|, |\mainmatter| and
%    |\backmatter| should be used to divide a thesis to 3 parts:
%    \begin{enumerate}\scrunch
%       \item Hebrew cover, title, acknowledgment, TOC, LOF, LOT when
%             the main language of the document will be Hebrew
%             \textbf{OR}
%             English cover, etc.\ when the main language of the
%             document will be English.\\ This part will be with hebrew
%             page numbering if in Hebrew and with roman page
%             numbering if in English.
%       \item The main part (in Hebrew or in English) will be with
%             arabic page numbering.
%       \item The opposite to the first part:\\
%             English cover, title, acknowledgment, TOC, LOF, LOT when
%             the main language of the document was Hebrew 
%             \textbf{OR} Hebrew
%             cover, etc.\ when the main language of the document was
%             English.\\ This part will be with roman page numbering
%             if in English and with hebrew page numbering if in
%             Hebrew.
%    \end{enumerate}
%
%  \begin{macro}{\frontmatter}
%    Should be used at the beginning of the first part
%    (for example, after the Hebrew |\makecover|).
%    \begin{macrocode}
\newcommand\frontmatter{%
  \if@openright\cleardoublepage\else\clearpage\fi%
  \ifiitthes@hebmain\pagenumbering{alph}\else\pagenumbering{roman}\fi}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\mainmatter}
%    Should be used at the beginning of the second part
%    (for example, after the Hebrew \emph{abstract}).
%    \begin{macrocode}
\newcommand\mainmatter{%
  \if@openright\cleardoublepage\else\clearpage\fi%
  \pagenumbering{arabic}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\backmatter}
%    Should be used at the beginning of the third part
%    (for example, after the English |\makecover|).
%    \begin{macrocode}
\let\backmatter\frontmatter
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\makecover}
%    This command is similar to |\maketitle| and builds a standard
%    thesis cover with title and author. The cover will be in Hebrew
%    when in Hebrew mode, and in English when in English mode.
%    \begin{macrocode}
\newcommand{\makecover}{%
  \begin{titlepage}
    \thispagestyle{empty}
    \null\vskip.8truein
    \begin{doublespace}
      \begin{center}
        \bfseries\if@rl\Huge\@@titleh
        \else\LARGE\MakeUppercase{\@@title}\fi
        \vskip2.7truein
        \if@rl\huge\@@authorh
        \else\LARGE\MakeUppercase{\@@author}\fi
      \end{center}
    \end{doublespace}
    \vfill\null
  \end{titlepage}
  \thispagestyle{empty}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\maketitle}
%    This updated command builds a standard thesis title page. It will
%    be in Hebrew when in Hebrew mode, and in English when in English
%    mode.
%    \begin{macrocode}
\renewcommand{\maketitle}{%
  \if@openright\cleardoublepage\else\clearpage\fi
  \thispagestyle{empty}
  \begin{doublespace}
    \begin{center}
      \bfseries\if@rl\huge\@@titleh
      \else\Large\MakeUppercase{\@@title}\fi
    \end{center}
    \vfill
    \begin{center}
      \if@rl\Large\@thestypeh\else\large\@thestype\fi
    \end{center}
    \vfill 
    \begin{center}
      \if@rl\large
         \@lineih \par
         \@lineiih \par
         \@lineiiih%
      \else\large
         \@linei\par
         \@lineii \par
         \@lineiii%
      \fi
    \end{center}
    \vfill%
    \begin{center}
      \bfseries\if@rl\LARGE\@@authorh
      \else\Large\MakeUppercase{\@@author}\fi
    \end{center}
    \vfill 
    \begin{center}
      \if@rl\large
         \@lineivh \par
         \@linevh
      \else
         \@lineiv \par
         \@linev\fi
    \end{center}
  \end{doublespace}
  \newpage\thispagestyle{empty}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{environment}{acknowledgment}
%    The acknowledgment environment is defined to help a writer to
%    add his/her customized acknowledgment to the third page (after
%    the cover and title pages). The acknowledgment will be in Hebrew
%    when in Hebrew mode, and in English when in English mode.
%
%    For example:
%    \begin{verbatim}
%       \begin{acknowledgment}
%          I want to ``thank'' my committee,\\
%          without whose ridiculous demands,\\
%          I would have graduated so, so, very much faster.
%       \end{acknowledgment}
%    \end{verbatim}
%    \begin{macrocode}
\newenvironment{acknowledgment}{%
  \if@openright\cleardoublepage\else\clearpage\fi
  \thispagestyle{empty}% 
  \begin{center}
    \if@rl\large
      \@linevih{}
      \@lineviih{}
      \@@advisorih{}
      \ifx\empty\@@advisoriih\else\hebvav\@@advisoriih{} \fi\\
      \@@depth
    \else
      \@linevi{}
      \MakeUppercase{\@@advisori}\ %
      \ifx\empty\@@advisorii\else\MakeUppercase{and \@@advisorii{} }\fi
      \@linevii{}
      \MakeUppercase{\@@dept}
    \fi
  \end{center}
  \vfill
  \begin{center}%
    \if@rl\LARGE\acknowledgmentname%
    \else\Large\MakeUppercase{\acknowledgmentname}\fi
  \end{center}
  \vspace{2\baselineskip}
  \begingroup\large}
{\endgroup\vfill
  \begin{center}
    \if@rl\large\@donorh\else\@donor\fi
  \end{center}
  \newpage\normalsize\thispagestyle{empty}}
%    \end{macrocode}
%  \end{environment}
%
%  \begin{environment}{dedication}
%    The dedication environment is similar to the previous one and
%    defined to help a writer to add his/her dedication page (fourth
%    page -- after the cover, title and acknowledgment  pages). 
%    The dedication will be in Hebrew when in Hebrew mode, and in
%    English when in English mode.
%
%    For example:
%    \begin{verbatim}
%       \begin{dedication}
%          To myself,\\
%          John W. Smith,\\
%          the only person worthy of my company.
%       \end{dedication}
%    \end{verbatim}
%    \begin{macrocode}
\newenvironment{dedication}{%
  \thispagestyle{empty}% 
  \vspace*{2\baselineskip}
  \begin{center}\large}
  {\end{center}
  \newpage\normalsize\thispagestyle{empty}}
%    \end{macrocode}
%  \end{environment}
%
%  \begin{environment}{abstract}
%    Builds standard abstract and adds title in Hebrew when in Hebrew
%    mode, and in English when in English mode.
%    \begin{macrocode}
\renewenvironment{abstract}{%
  \if@openright\cleardoublepage\else\clearpage\fi%
  \if@rl\bchapternn{\abstractname}{Hebrew Abstract}
  \else\bchapternn{\hebtav\hebqof\hebtsadi\hebyod\hebresh\ %
                   \hebbet\hebalef\hebnun\hebgimel\heblamed\hebyod\hebtav}
                  {\abstractname}\fi%
  \begingroup}{%
  \newpage\endgroup}
%    \end{macrocode}
%  \end{environment}
%
%
%  \begin{macro}{\ps@thesis}
%    Define the ``thesis'' page style which is based on the standard
%    |\ps@headings|, but adds a thick horisontal rule to running
%    headings. The following line should be added to the document's
%    preamble:
%    \begin{quote}
%       |\pagestyle{thesis}|
%    \end{quote}
%    \begin{macrocode}
\def\ps@thesis{%
  \def\headeven{\protect\rule[-4pt]{\textwidth}{.5pt}\kern-\textwidth%
                \protect\if@rl\beginR\thepage\hfil{%
                              \bfseries\rightmark}\endR%
                \protect\else\thepage\hfil{%
                             \bfseries\leftmark}\protect\fi}
  \def\headodd{\protect\rule[-4pt]{\textwidth}{.5pt}\kern-\textwidth%
               \protect\if@rl\beginR{\bfseries\leftmark}%
                             \hfil\thepage\endR%
               \protect\else{\bfseries\rightmark}%
                             \hfil\thepage\protect\fi}
  \ps@headings}
%    \end{macrocode}
%  \end{macro}
%
%    Set up page layout.
%
%  \begin{macro}{\textheight}
%  \begin{macro}{\textwidth}
%    Height and width of the main body of the text.
%    \begin{macrocode}
\setlength{\textheight}{8.25in}
\setlength{\textwidth}{6.0in}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\topmargin}
%    Margin on top of page.
%    \begin{macrocode}
\setlength{\topmargin}{0pt}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\headsep}
%    Space between header and top of body (for more details, see 
%    \emph{``The \LaTeX{} Companion''} book, p.~85).
%    \begin{macrocode}
\setlength{\headsep}{.5in}
\addtolength{\headsep}{-\headheight}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\oddsidemargin}
%  \begin{macro}{\evensidemargin}
%    Margins on the left for odd pages and on the right for even
%    pages.
%    \begin{macrocode}
\setlength{\oddsidemargin}{.25in}
\setlength{\evensidemargin}{.25in}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\marginparwidth}
%  \begin{macro}{\marginparsep}
%    Parameters for marginal notes: width of marginal notes and space
%    between marginal notes and text. 
%    \begin{macrocode}
\setlength{\marginparwidth}{40pt}
\setlength{\marginparsep}{10pt}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%    \begin{macrocode}
\brokenpenalty=10000
%</iitthes>
%    \end{macrocode}
%
% \Finale
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\endinput