% ctex-report.def: definitions for report class files
% vim:ft=tex

\def\CTEX@prepart{Part\space}
\def\CTEX@prechapter{Chapter\space}
\def\CTEX@part@format{\centering}
\def\CTEX@part@nameformat{\huge\bfseries}
\def\CTEX@part@aftername{\par\vskip 20\p@}
\def\CTEX@part@titleformat{\Huge\bfseries}
\def\CTEX@chapter@format{\raggedright}
\def\CTEX@chapter@nameformat{\huge\bfseries}
\def\CTEX@chapter@aftername{\par\nobreak\vskip 20\p@}
\def\CTEX@chapter@titleformat{\Huge\bfseries}
\def\CTEX@chapter@beforeskip{50\p@}
\def\CTEX@chapter@afterskip{40\p@}
\def\CTEX@chapter@indent{\z@}
\def\CTEX@section@format{\Large\bfseries}
\def\CTEX@section@aftername{\quad}
\def\CTEX@section@beforeskip{-3.5ex \@plus -1ex \@minus -.2ex}
\def\CTEX@section@afterskip{2.3ex \@plus .2ex}
\def\CTEX@section@indent{\z@}
\def\CTEX@subsection@format{\large\bfseries}
\def\CTEX@subsection@aftername{\quad}
\def\CTEX@subsection@beforeskip{-3.25ex \@plus -1ex \@minus -.2ex}
\def\CTEX@subsection@afterskip{1.5ex \@plus .2ex}
\def\CTEX@subsection@indent{\z@}
\def\CTEX@subsubsection@format{\normalsize\bfseries}
\def\CTEX@subsubsection@aftername{\quad}
\def\CTEX@subsubsection@beforeskip{-3.25ex \@plus -1ex \@minus -.2ex}
\def\CTEX@subsubsection@afterskip{1.5ex \@plus .2ex}
\def\CTEX@subsubsection@indent{\z@}
\def\CTEX@paragraph@format{\normalsize\bfseries}
\def\CTEX@paragraph@aftername{\quad}
\ifnum\c@CTEX@sectiondepth>2
  \def\CTEX@paragraph@beforeskip{-3.25ex \@plus -1ex \@minus -.2ex}
  \def\CTEX@paragraph@afterskip{1ex \@plus .2ex}
\else
  \def\CTEX@paragraph@beforeskip{3.25ex \@plus1ex \@minus .2ex}
  \def\CTEX@paragraph@afterskip{-1em}
\fi
\def\CTEX@paragraph@indent{\z@}
\def\CTEX@subparagraph@format{\normalsize\bfseries}
\def\CTEX@subparagraph@aftername{\quad}
\ifnum\c@CTEX@sectiondepth>3
  \def\CTEX@subparagraph@beforeskip{-3.25ex \@plus -1ex \@minus -.2ex}
  \def\CTEX@subparagraph@afterskip{1ex \@plus .2ex}
\else
  \def\CTEX@subparagraph@beforeskip{3.25ex \@plus1ex \@minus .2ex}
  \def\CTEX@subparagraph@afterskip{-1em}
\fi
\ifnum\c@CTEX@sectiondepth>2
  \def\CTEX@subparagraph@indent{\z@}
\else
  \def\CTEX@subparagraph@indent{\parindent}
\fi
\def\CTEX@appendixname{Appendix\space}
\def\CTEX@appendixnumber{\@Alph\c@chapter}
\let\CTEX@save@appendix\appendix
\renewcommand*\appendix{\CTEX@save@appendix%
  \gdef\CTEX@prechapter{\CTEX@appendixname}%
  \gdef\CTEX@thechapter{\CTEX@appendixnumber}%
  \gdef\CTEX@postchapter{}}%
\def\@part[#1]#2{%
  \ifnum \c@secnumdepth >-2\relax
    \refstepcounter{part}%
    \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}%
  \else
    \addcontentsline{toc}{part}{#1}%
  \fi
  \markboth{}{}%
  {\interlinepenalty \@M
   \normalfont \CTEX@part@format
   \ifnum \c@secnumdepth >-2\relax
     \CTEX@partname
   \fi
   \CTEX@part@titleformat #2\par}%
  \@endpart}
\def\@spart#1{%
    {\interlinepenalty \@M
     \normalfont \CTEX@part@format
     \CTEX@part@titleformat #1\par}%
    \@endpart}
\def\@chapter[#1]#2{%
  \ifnum \c@secnumdepth >\m@ne
    \refstepcounter{chapter}%
    \typeout{\CTEXthechapter}%
    \addcontentsline{toc}{chapter}
      {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}%
  \else
    \addcontentsline{toc}{chapter}{#1}%
  \fi
  \chaptermark{#1}%
  \addtocontents{lof}{\protect\addvspace{10\p@}}%
  \addtocontents{lot}{\protect\addvspace{10\p@}}%
  \if@twocolumn
    \@topnewpage[\@makechapterhead{#2}]%
  \else
    \@makechapterhead{#2}%
  \@afterheading
  \fi}
\def\@makechapterhead#1{%
  \vspace*{\CTEX@chapter@beforeskip}%
  {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format
   \ifnum \c@secnumdepth >\m@ne
     \CTEX@chaptername
   \fi
   \interlinepenalty\@M
   \CTEX@chapter@titleformat #1\par\nobreak
   \vskip \CTEX@chapter@afterskip
  }}
\def\@makeschapterhead#1{%
  \vspace*{\CTEX@chapter@beforeskip}%
  {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format
   \interlinepenalty\@M
   \CTEX@chapter@titleformat #1\par\nobreak
   \vskip \CTEX@chapter@afterskip
  }}
\def\@seccntformat#1{%
  \@ifundefined{CTEX@#1name}%
    {\csname the#1\endcsname\quad}%
    {\csname CTEX@#1name\endcsname}}
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum #2>\c@secnumdepth
    \let\@svsec\@empty
  \else
    \refstepcounter{#1}%
    \protected@edef\@svsec{\@seccntformat{#1}\relax}%
  \fi
  \@tempskipa #5\relax
  \ifdim \@tempskipa>\z@
    \begingroup
      #6{%
        \@hangfrom{\hskip #3\relax\@svsec}%
        \interlinepenalty \@M
        \csname CTEX@#1@titleformat\endcsname #8\@@par}%
    \endgroup
    \csname #1mark\endcsname{#7}%
    \addcontentsline{toc}{#1}{%
      \ifnum #2>\c@secnumdepth \else
        \protect\numberline{\@ifundefined{CTEXthe#1}%
                              {\csname the#1\endcsname}%
                              {\csname CTEXthe#1\endcsname}}%
      \fi
      #7}%
  \else
    \def\@svsechd{%
    #6{\hskip #3\relax
      \@svsec \csname CTEX@#1@titleformat\endcsname #8}%
    \csname #1mark\endcsname{#7}%
    \addcontentsline{toc}{#1}{%
      \ifnum #2>\c@secnumdepth \else
        \protect\numberline{\@ifundefined{CTEXthe#1}%
                              {\csname the#1\endcsname}%
                              {\csname CTEXthe#1\endcsname}}%
      \fi
      #7}}%
  \fi
  \@xsect{#5}}
\def\numberline#1{%
  \settowidth\@tempdimb{#1\hspace{0.5em}}%
  \ifdim\@tempdima<\@tempdimb%
    \@tempdima=\@tempdimb%
  \fi%
  \hb@xt@\@tempdima{#1\hfil}}
\renewcommand\section{\@startsection{section}{1}%
                                   {\CTEX@section@indent}%
                                   {\CTEX@section@beforeskip}%
                                   {\CTEX@section@afterskip}%
                                   {\normalfont\CTEX@section@format}}
\renewcommand\subsection{\@startsection{subsection}{2}%
                                   {\CTEX@subsection@indent}%
                                   {\CTEX@subsection@beforeskip}%
                                   {\CTEX@subsection@afterskip}%
                                   {\normalfont\CTEX@subsection@format}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}%
                                   {\CTEX@subsubsection@indent}%
                                   {\CTEX@subsubsection@beforeskip}%
                                   {\CTEX@subsubsection@afterskip}%
                                   {\normalfont\CTEX@subsubsection@format}}
\renewcommand\paragraph{\@startsection{paragraph}{4}%
                                   {\CTEX@paragraph@indent}%
                                   {\CTEX@paragraph@beforeskip}%
                                   {\CTEX@paragraph@afterskip}%
                                   {\normalfont\CTEX@paragraph@format}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}%
                                   {\CTEX@subparagraph@indent}%
                                   {\CTEX@subparagraph@beforeskip}%
                                   {\CTEX@subparagraph@afterskip}%
                                   {\normalfont\CTEX@subparagraph@format}}
\if@twoside
  \def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\thepage\hfil\slshape\leftmark}%
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markboth {\MakeUppercase{%
        \ifnum \c@secnumdepth >\m@ne
          \CTEXthechapter \quad %
        \fi
        ##1}}{}}%
    \def\sectionmark##1{%
      \markright {\MakeUppercase{%
        \ifnum \c@secnumdepth >\z@
          \CTEXthesection \quad %
        \fi
        ##1}}}}
\else
  \def\ps@headings{%
    \let\@oddfoot\@empty
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markright {\MakeUppercase{%
        \ifnum \c@secnumdepth >\m@ne
          \CTEXthechapter \quad %
        \fi
        ##1}}}}
\fi
\pagestyle{headings}
\@ifundefined{ps@fancy}{}{%
  \def\ps@fancy{%
  \@ifundefined{@chapapp}{\let\@chapapp\chaptername}{}%for amsbook
  \@ifundefined{MakeUppercase}{\def\MakeUppercase{\uppercase}}{}%
  \@ifundefined{chapter}{\def\sectionmark##1{\markboth
  {\MakeUppercase{\ifnum \c@secnumdepth>\z@
   \CTEXthesection\quad \fi ##1}}{}}%
  \def\subsectionmark##1{\markright {\ifnum \c@secnumdepth >\@ne
   \CTEXthesubsection\quad \fi ##1}}}%
  {\def\chaptermark##1{\markboth {\MakeUppercase{\ifnum \c@secnumdepth>\m@ne
   \ifCTEX@cls{book}{\if@mainmatter\CTEXthechapter \quad\fi}{\CTEXthechapter \quad}
   \fi ##1}}{}}%
  \def\sectionmark##1{\markright{\MakeUppercase{\ifnum \c@secnumdepth >\z@
   \CTEXthesection \quad \fi ##1}}}}%
  \ps@@fancy
  \gdef\ps@fancy{\@fancyplainfalse\ps@@fancy}%
  \ifdim\headwidth<0sp
      \global\advance\headwidth123456789sp\global\advance\headwidth\textwidth
  \fi}
}

\endinput
