%
% Hyper.sty for TeX for Windos (WinDvi) --- version 1.2
% Copyright(C) 1994 by impress corporation.
%
%%%%%%%%%%%%%%%%%%%%%%
%
% BMPファイルの取り込み
%
% \bmpfile(#1,#2){#3}
%
% #1 : width
% #2 : height
% #3 : BMP filename

\newdimen\bmp@tk \bmp@tk=0pt % thickness of rule

\def\bmpfile(#1,#2)#3{%
  \@tempdima\normalbaselineskip \advance\@tempdima by-1zh
  \vskip\@tempdima
  \leavevmode\vbox{\@ifundefined{yoko}{}{\yoko}%
  \parindent=0pt\offinterlineskip
  \special{Windows org}
  \hrule width#1 height\bmp@tk depth0pt\vss
  \hbox to#1{%
    \vrule width\bmp@tk height#2 depth0pt
    \hss\vbox to#2{\vss}\hss
    \vrule width\bmp@tk height#2 depth0pt
    \special{Windows bmp #3}}\vss
  \hrule width#1 height\bmp@tk depth0pt}}

%%%%%%%%%%%%%%%%%%%%%%
%
% ハイパー構造/ボタン
%
% \hyperbutton[#1]{#2}{#3}
%
% #1 : filename（同一ファイル内であれば、省略可）
% #2 : Label
% #3 : strings

\def\hyperbutton{%
  \@ifnextchar[{\@HyperButton}{\@HyperButton[\jobname]}}

\def\@HyperButton[#1]#2#3{%
% \xdef\hyper@filename{#1}
% \xdef\hyper@label{#2}
  \special{/> #2@#1 [}#3\special{/> #2@#1 ]}}

%%%%%%%%%%%%%%%%%%%%%%
%
% ハイパー構造/ラベル
%
% \hyperlabel{#1}{#2}
%
% #1 : Label
% #2 : Region

\def\hyperlabel#1#2{%
  \special{/< #1 [}#2\special{/< #1 ]}}

%%%%%%%%%%%%%%%%%%%%%%
%
% 階層構造
%
% \Hierarcy{#1}{#2}
%
% #1 : Level (0 .. 9)
% #2 : Label

%\newcounter{part}
%\newcounter{chapter}
%\newcounter{section}[chapter]
%\newcounter{subsection}[section]
%\newcounter{subsubsection}[subsection]
%\newcounter{paragraph}[subsubsection]
%\newcounter{subparagraph}[paragraph]

\xdef\one@lvl{1}% Level 1. part
\xdef\two@lvl{2}% Level 2. chapter
\xdef\thr@lvl{3}% Level 3. section
\xdef\fur@lvl{4}% Level 4. subsection
\xdef\fve@lvl{5}% Level 5. subsubsection
\xdef\six@lvl{6}% Level 6. paragraph
\xdef\sve@lvl{7}% Level 7. subparagraph

\def\NumberingPageContents{%
  \count1=\the\c@part
  \@ifundefined{chapter}{\count2=0\relax}{\count2=\the\c@chapter}
  \count3=\the\c@section
  \count4=\the\c@subsection
  \count5=\the\c@subsubsection
  \count6=\the\c@paragraph
  \count7=\the\c@subparagraph}

\def\Hierarcy#1#2{%
  \special{/#1[}#2\special{/#1]}}


\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum#2>\c@secnumdepth
    \def\@svsec{}\else 
    \refstepcounter{#1}\edef\@svsec{\csname the#1\endcsname\hskip 1em}\fi
  \@tempskipa #5\relax
  \ifdim\@tempskipa>\z@ 
    \begingroup #6\relax
      \@hangfrom{\hskip#3\relax\@svsec}{%
      \interlinepenalty\@M \Hierarcy{#2}{#8}\par}%
    \endgroup
    \NumberingPageContents
    \csname #1mark\endcsname{#7}
    \addcontentsline{toc}{#1}{%
      \ifnum#2>\c@secnumdepth\else
        \protect\numberline{\csname the#1\endcsname}\fi #7}
  \else
    \def\@svsechd{#6\hskip#3 \@svsec\Hierarcy{#2}{#8}\csname #1mark\endcsname{#7}
    \addcontentsline{toc}{#1}{%
      \ifnum#2>\c@secnumdepth\else\protect\numberline{\csname the#1\endcsname}\fi#7}}\fi
  \@xsect{#5}}

\def\@ssect#1#2#3#4#5{%
  \@tempskipa #3\relax
  \ifdim\@tempskipa>\z@
  \begingroup #4\@hangfrom{\hskip #1}{%
    \interlinepenalty\@M \Hierarcy{#2}{#5}\par}\endgroup
  \else
    \def\@svsechd{#4\hskip#1\relax\Hierarcy{#2}{#5}}\fi
  \NumberingPageContents
  \@xsect{#3}}


\def\@part[#1]#2{%
  \ifnum\c@secnumdepth>-2\relax
    \refstepcounter{part}
    \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}\else
    \addcontentsline{toc}{part}{#1}\fi
  \markboth{}{}{%
    \centering\ifnum\c@secnumdepth>-2\relax
    \huge\bf Part \thepart \par
    \vskip 20pt\fi
    \Hierarcy{\one@lvl}{\Huge\bf #1}
    \par}\@endpart}

\def\@makechapterhead#1{%
  \vspace*{50pt}{\parindent 0pt \raggedright 
  \ifnum\c@secnumdepth>\m@ne
    \huge\bf\@chapapp{}\thechapter\par 
    \vskip 20pt\fi
  \Hierarcy{\two@lvl}{\Huge\bf #1}\par 
  \nobreak
  \vskip40pt}}

\def\@makeschapterhead#1{%
  \vspace*{50pt}{\parindent 0pt \raggedright 
  \Hierarcy{\two@lvl}{\Huge\bf #1}\par 
  \nobreak
  \vskip40pt}}

\def\section{%
  \@startsection{section}{\thr@lvl}{\z@}{%
  3.5ex plus1ex minus.2ex}{2.3ex plus.2ex}{\Large\bf}}

\def\subsection{%
  \@startsection{subsection}{\fur@lvl}{\z@}{%
  3.25ex plus1ex minus.2ex}{1.5ex plus.2ex}{\large\bf}}

\def\subsubsection{%
  \@startsection{subsubsection}{\fve@lvl}{\z@}{%
  3.25ex plus1ex minus.2ex}{1.5ex plus.2ex}{\normalsize\bf}}

\def\paragraph{%
  \@startsection{paragraph}{\six@lvl}{\z@}{%
  3.25ex plus1ex minus.2ex}{-1em}{\normalsize\bf}}

\def\subparagraph{%
  \@startsection{subparagraph}{\sve@lvl}{\parindent}{%
  3.25ex plus1ex minus.2ex}{-1em}{\normalsize\bf}}

\@ifundefined{chapter}%
  {\setcounter{secnumdepth}{5}}{\setcounter{secnumdepth}{4}}
