%%
%% This is file `scrreprt-xetex-bidi.def',

%% 
%%   __________________________________
%%   Copyright © 2009-2010 Vafa Khalighi
%% 
%%   License information appended.
%% 
%% 
\ProvidesFile{scrreprt-xetex-bidi.def}[2010/07/25 v0.3 bidi adaptations for scrreprt class for XeTeX engine]
\renewcommand*\maketitle[1][1]{%
  \if@titlepage
    \begin{titlepage}
      \setcounter{page}{%
        #1%
      }%
      \let\footnotesize\small
      \let\right@footnote\relax
      \let\left@footnote\relax
      \let\textwidth@footnote\relax
      \let\footnote\thanks
      \let\LTRfootnote\LTRthanks
      \let\RTLfootnote\RTLthanks
      \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
      \let\@oldmakefnmark\@makefnmark
      \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}%
      \ifx\@extratitle\@empty \else
        \noindent\@extratitle\next@tpage\cleardoubleemptypage
        \thispagestyle{empty}%
      \fi
      \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
      \ifx\@titlehead\@empty \else
        \begin{minipage}[t]{\textwidth}%
        \@titlehead
        \end{minipage}\par
      \fi
      \null\vfill
      \begin{center}
        \ifx\@subject\@empty \else
          {\subject@font \@subject \par}%
          \vskip 3em
        \fi
        {\titlefont\huge \@title\par}%
        \vskip 1em
        {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
        \vskip 2em
        {\Large \lineskip 0.75em
          \begin{tabular}[t]{c}
            \@author
          \end{tabular}\par
        }%
        \vskip 1.5em
        {\Large \@date \par}%
        \vskip \z@ \@plus3fill
        {\Large \@publishers \par}%
        \vskip 3em
      \end{center}\par
      \@thanks
      \vfill\null
      \if@twoside\next@tpage
        \begin{minipage}[t]{\textwidth}
          \@uppertitleback
        \end{minipage}\par
        \vfill
        \begin{minipage}[b]{\textwidth}
          \@lowertitleback
        \end{minipage}
      \fi
      \ifx\@dedication\@empty \else
        \next@tpage\null\vfill
        {\centering \Large \@dedication \par}%
        \vskip \z@ \@plus3fill
        \if@twoside \next@tpage\cleardoubleemptypage \fi
      \fi
    \end{titlepage}
  \else
    \par
    \@tempcnta=%
    #1%
    \relax\ifnum\@tempcnta=1\else
      \ClassWarning{\KOMAClassName}{%
        Optional argument of \string\maketitle\space ignored
        at\MessageBreak
        notitlepage-mode%
      }%
    \fi
    \begingroup
      \renewcommand*\thefootnote{\@fnsymbol\c@footnote}%
      \let\@oldmakefnmark\@makefnmark
      \renewcommand*{\@makefnmark}{\rlap\@oldmakefnmark}
      \if@twocolumn
        \ifnum \col@number=\@ne
          \@maketitle
        \else
          \twocolumn[\@maketitle]%
        \fi
      \else
        \newpage
        \global\@topnum\z@
        \@maketitle
      \fi
      \thispagestyle{\titlepagestyle}\@thanks
    \endgroup
  \fi
  \setcounter{footnote}{0}%
  \let\thanks\relax
  \let\LTRthanks\relax
  \let\RTLthanks\relax
  \let\maketitle\relax
  \let\@maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\@subtitle\@empty
  \global\let\@extratitle\@empty
  \global\let\@titlehead\@empty
  \global\let\@subject\@empty
  \global\let\@publishers\@empty
  \global\let\@uppertitleback\@empty
  \global\let\@lowertitleback\@empty
  \global\let\@dedication\@empty
  \global\let\author\relax
  \global\let\title\relax
  \global\let\extratitle\relax
  \global\let\titlehead\relax
  \global\let\subject\relax
  \global\let\publishers\relax
  \global\let\uppertitleback\relax
  \global\let\lowertitleback\relax
  \global\let\dedication\relax
  \global\let\date\relax
  \global\let\and\relax
}%
\renewcommand*{\@maketitle}{%
  \clearpage
  \let\footnote\thanks
  \let\LTRfootnote\LTRthanks
  \let\RTLfootnote\RTLthanks
  \ifx\@extratitle\@empty \else
    \noindent\@extratitle \next@tpage \if@twoside \null\next@tpage \fi
  \fi
  \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
  \ifx\@titlehead\@empty \else
    \begin{minipage}[t]{\textwidth}
      \@titlehead
    \end{minipage}\par
  \fi
  \null
  \vskip 2em%
  \begin{center}%
    \ifx\@subject\@empty \else
      {\subject@font \@subject \par}
      \vskip 1.5em
    \fi
    {\titlefont\huge \@title \par}%
    \vskip .5em
    {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
    \vskip 1em
    {\Large
      \lineskip .5em%
      \begin{tabular}[t]{c}
        \@author
      \end{tabular}\par
    }%
    \vskip 1em%
    {\Large \@date \par}%
    \vskip \z@ \@plus 1em
    {\Large \@publishers \par}
    \ifx\@dedication\@empty \else
      \vskip 2em
      {\Large \@dedication \par}
    \fi
  \end{center}%
  \par
  \vskip 2em
}%
\renewcommand*\l@part[2]{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty{-\@highpenalty}%
    \addvspace{2.25em \@plus\p@}%
    \setlength{\@tempdima}{2em}%
    \if@tocleft
      \ifx\toc@l@number\@empty\else
        \setlength\@tempdima{0\toc@l@number}%
      \fi
    \fi
    \begingroup
      \parindent \z@ \if@RTL\leftskip\else\rightskip\fi \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode
      \advance\if@RTL\rightskip\else\leftskip\fi\@tempdima
      \hskip -\if@RTL\rightskip\else\leftskip\fi
      \usekomafont{partentry}{#1\nobreak
        \usekomafont{partentrypagenumber}{\hfil\nobreak
          \hb@xt@\@pnumwidth{\hss#2}}}\par
      \ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
      \endgroup
      \penalty20010
      \else
          \penalty\@highpenalty
      \endgroup
    \fi
  \fi
}
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \ifnum \lastpenalty<20010
      \addpenalty{-\@highpenalty}%
    \fi
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \if@tocleft
      \ifx\toc@l@number\@empty\else
        \setlength\@tempdima{0\toc@l@number}%
      \fi
    \fi
    \begingroup
      \raggedchapterentry
      \parindent \z@ \advance\if@RTL\leftskip\else\rightskip\fi \@pnumwidth
      \parfillskip -\@pnumwidth
      \interlinepenalty\@M
      \leavevmode
      \advance\if@RTL\rightskip\else\leftskip\fi \@tempdima \null\nobreak\hskip -\if@RTL\rightskip\else\leftskip\fi
      \usekomafont{chapterentry}{#1\nobreak
        \usekomafont{chapterentrypagenumber}{%
          \hfill\nobreak
          \hb@xt@\@pnumwidth{\hss#2}}}\par
      \ifnum \scr@compatibility>\@nameuse{scr@v@2.96}\relax
      \endgroup
      \penalty20009
      \else
        \penalty\@highpenalty
      \endgroup
    \fi
  \fi
}
\def\raggedsection{\if@RTL\raggedleft\else\raggedright\fi}
\renewcommand*\autodot{\if@altsecnumformat\@SepMark\fi}
\renewcommand*\thesection{%
  \thechapter\@SepMark%
  \@arabic\c@section
}
\renewcommand*{\thesubsection}{\thesection\@SepMark\@arabic\c@subsection}
\renewcommand*{\thesubsubsection}{%
  \thesubsection\@SepMark\@arabic\c@subsubsection
}
\renewcommand*{\theparagraph}{\thesubsubsection\@SepMark\@arabic\c@paragraph}
\renewcommand*{\thesubparagraph}{%
  \theparagraph\@SepMark\@arabic\c@subparagraph
}
\renewcommand*\thefigure{%
  \thechapter\@SepMark%
  \@arabic\c@figure
}
\renewcommand*\thetable{%
  \thechapter\@SepMark%
  \@arabic\c@table
}
\renewcommand*\theequation{%
  \thechapter\@SepMark%
  \@arabic\c@equation
}
\renewenvironment{thebibliography}[1]{%
  \if@bib@break@
    \bib@beginhook
  \else
    \ifx\bibpreamble\relax\else\ifx\bibpreamble\@empty\else
        \setchapterpreamble{\bibpreamble}%
    \fi\fi
    \bib@heading
    \bib@beginhook
    \bib@before@hook
  \fi
  \renewcommand{\BreakBibliography}[1]{%
    \@bib@break
    \end{thebibliography}%
    \begingroup ##1\endgroup
    \begin{thebibliography}{#1}
  }%
  \if@RTL\if@LTRbibitems\@RTLfalse\else\fi\else\if@RTLbibitems\@RTLtrue\else\fi\fi
  \list{%
    \@biblabel{\@arabic\c@enumiv}%
  }{%
    \settowidth\labelwidth{\@biblabel{#1}}%
    \leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \@openbib@code
    \if@bib@break@
      \edef\@tempa{%
        \noexpand\usecounter{enumiv}%
        \noexpand\setcounter{enumiv}{\the\c@enumiv}%
      }\@tempa
      \no@bib@break
    \else
      \usecounter{enumiv}%
    \fi
    \let\p@enumiv\@empty
    \renewcommand*\theenumiv{\@arabic\c@enumiv}%
  }%
  \sloppy\clubpenalty4000 \widowpenalty4000
  \sfcode`\.=\@m
}{%
  \if@bib@break@
    \def\@noitemerr{%
      \@latex@warning{%
        \string\BreakBibliography\space at begin of `thebibliography'
        environment\MessageBreak
        or following \string\BreakBibliography}%
    }%
  \else
    \def\@noitemerr{%
      \@latex@warning{%
        Empty `thebibliography' environment or
        \string\BreakBibliography\MessageBreak
        before end of `thebibliography' environment}%
    }%
  \fi
  \endlist
  \if@bib@break@
  \else
    \bib@after@hook
    \let\bib@before@hook\@empty
    \let\bib@after@hook\@empty
  \fi
  \bib@endhook
}
\renewcommand*\left@footnote{%
  \kern-3\p@
  \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
  \hrule\@width.4\columnwidth
  \kern 2.6\p@}
\renewcommand*\right@footnote{%
  \hbox to \columnwidth
  {\beginR \vbox{%
  \kern-3\p@
  \ifx\@textbottom\relax\else\vskip \z@ \@plus.05fil\fi
  \hrule\@width.4\columnwidth
  \kern 2.6\p@}\hfil\endR}}
%% 
%% Copyright © 2009-2010      by Vafa Khalighi     <vafakh84@gmail.com>
%% 
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status)
%% by Vafa Khalighi.
%% 
%% 
%% 
%% 
%%
%% End of file `scrreprt-xetex-bidi.def'.
