%%% kitesthesis.cls modified from kuee.cls by K. Kobayashi
%%%% Version 2011.02.22.01
%%%% Version 2012.01.10.01
%%%% Version 2016.12.27.01
\ProvidesClass{kitesthesis}[2016/12/27]
\usepackage{color}
\usepackage{graphicx}
\definecolor{lightblue}{rgb}{0.678431,0.847059,0.901961}
\definecolor{lightgreen}{rgb}{0.564706,0.933333,0.564706}
\newif\if@NTT
\ifx\pfmtname\undefined
  \@NTTtrue
  \NeedsTeXFormat{LaTeX2e}
\else
  \@NTTfalse
  \NeedsTeXFormat{pLaTeX2e}
\fi
\newif\ifunclearfiguretable
\unclearfiguretablefalse
\newif\ifremovefiguretable
\removefiguretablefalse
\DeclareOption{removefiguretable}{\removefiguretabletrue}
\DeclareOption{unclearfiguretable}{\unclearfiguretabletrue}
\DeclareOption{clearfiguretable}{\unclearfiguretablefalse}
\newif\ifbachelor
\DeclareOption{bachelor}{\bachelortrue}
\DeclareOption{shuuron}{\bachelorfalse}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{jreport}}
\ProcessOptions\relax
\LoadClass[12pt]{report}

\ifremovefiguretable
\renewenvironment{figure}{}{}
\renewenvironment{table}{}{}
\renewcommand{\caption}[1]{}
\renewcommand{\includegraphics}[1][]{}
\else
\fi
% 互換性のために残しておく
\ifunclearfiguretable
\def\clearfigureandtable{}
\else
\def\clearfigureandtable{}
\fi

%%% カウンタの値を増やす
\count@\z@
\@whilenum\count@<16\do{%
   \advance\count@\@ne
   \expandafter\newinsert\csname bx@\romannumeral\count@\endcsname
   \@cons\@freelist{\csname bx@\romannumeral\count@\endcsname}}
%%% カウンタの値を増やす

\gdef\@univ{Kyoto Institute of Technology}
\gdef\@department{Department of Electronics}
\ifbachelor
\gdef\@course{School of Science and Technology}
\gdef\@maintitle{Bachelor's Thesis}
\else
\gdef\@course{Graduate School of Science and Technology}
\gdef\@maintitle{Master's Thesis}
\fi

%% 図を1枚/ページ
%\setcounter{topnumber}{1}
%\setcounter{bottomnumber}{1}
%\setcounter{totalnumber}{1}
%\renewcommand{\floatpagefraction}{0.01}

%均等割り付けマクロ
\def\expandstr#1#2{{\def\@tempa{#2}%
  \ifx\@tempa\empty\hbox to#1{\hss}%
  \else\relax\hbox to#1\bgroup\@expandstr#2\end@expandstr\fi}}
\def\@expandstr#1#2\end@expandstr{\def\@tempa{#2}#1%
  \ifx\@tempa\empty\let\next\end@expandstr
  \else\hfil\def\next{\@expandstr#2\end@expandstr}\fi
  \next}
\let\end@expandstr\egroup

\def\firstref#1{\label{crossref:#1}\ref{#1}}
\def\回転#1{\hbox{\tate #1}}
\def\Title#1{\gdef\@title{#1}}
%\def\英文題目#1{\gdef\@Etitle{#1}}
%\def\背表紙題目#1{\gdef\@backtitle{#1}}
\def\Supervisor#1{\gdef\@mainprofessor{#1}}
\def\SubSupervisor#1{\gdef\@professor{#1}}
\def\Number#1{\gdef\@IDcode{#1}}
\def\Name#1{\gdef\@author{#1}}
\def\JName#1{\gdef\@Jauthor{#1}}
\def\SubmissionDate#1{\gdef\@date{#1}}
\gdef\@year{2017}% 卒業年(平成)の定義
\gdef\@month{February}% 修了月の定義
\def\YearOfGraduation#1{\gdef\@year{#1}}
\def\MonthOfGraduation#1{\gdef\@month{#1}}
%\gdef\@christyear{2011}% 卒業年西暦の定義
%\def\西暦年#1{\gdef\@christyear{#1}}
\newif\ifCover\Coverfalse
\def\CoverPrint{\Covertrue}
%
%   Title page
%
\def\maketitle{\begin{titlepage}
\let\footnotesize\small \let\footnoterule\relax \setcounter{page}{0}
%\null
\ifCover
\maketitlelabel
\fi
%\vfil
\newpage\thispagestyle{empty}
\null
\vfil
\vskip 30pt 
\begin{center}

{\LARGE {\@maintitle}} \vskip 3em

\LARGE \@title 
\vskip 2em

{\Large
\begin{tabular}{p{4cm}l}
\ifbachelor
 Supervisor & \@mainprofessor\\\\
\else
 Supervisors & \@mainprofessor\\\\
      &  \@professor
\fi
\end{tabular}
} 
\vfill

{\Large \@course \par}
{\Large \@department \par}
{\Large \@univ \par}
{\Large Student ID \@IDcode \par}
{\Large \@author \par}
\vskip 1.5em {\Large \@date \par} 
\end{center}
\vfil
\end{titlepage}
\setcounter{footnote}{0} \let\thanks\relax
\let\maketitle\relax}
\def\abstract{\titlepage
\thispagestyle{empty}
\begin{center}
\textbf{\@title}\\\vspace{1em}
\@year\hfil\@IDcode\hfil\@author
\end{center}
\begin{center}\bf abstract\end{center}\par}
\def\endabstract{\endtitlepage
%\gdef\@thanks{}\gdef\@author{}\gdef\@IDcode{}\gdef\@professor{}\gdef\@title{}
}
%\iffalse
\def\jabstract{\titlepage
\thispagestyle{empty}
\begin{center}
\textbf{\@title}\\\vspace{1em}
%\@christyear \hfil\@IDcode\hfil\@Eauthor
平成\@year 年\hfil\@IDcode\hfil\@Jauthor
\end{center}
\begin{center}\bf 概要\end{center}\par}
\def\endjabstract{\endtitlepage
%\gdef\@thanks{}\gdef\@author{}\gdef\@IDcode{}\gdef\@professor{}\gdef\@title{}
}
%\fi
\def\contents{\pagenumbering{roman}\setcounter{page}{1}}
\def\endcontents{\newpage\pagenumbering{arabic}\setcounter{page}{1}}

%%%%背表紙
\def\backtitleline#1{\gdef\@backtitleline{#1}}
\gdef\@backtitleline{1}
%\def\backtitle#1{\gdef\@backtitle{#1}}

\def\maketitlelabel{%
\vbox{
\begin{center}
  \setlength{\textwidth}{136mm}
  \setlength{\textheight}{296mm}
  \setlength{\unitlength}{1mm}
  \setlength{\footskip}{0mm}
  \newlength{\topback}
  \setlength{\topback}{\topmargin}
  \addtolength{\topback}{\headheight}
  \addtolength{\topback}{\headsep}
  \addtolength{\topback}{\topskip}
  \addtolength{\topback}{1in}
  \vspace*{-\topback}
  %\vfil
  \begin{picture}(136,240)(0,55)
    \put(40,250){ %スケール表示
       \makebox(100,10){
         \begin{picture}(100,10)
          \put(0,5){\line(1,0){100}}
          \put(0,8){10cm Width. Print it out just in 10cm.}
          \put(0,3){\line(0,2){4}}
          \put(10,4){\line(0,1){2}}
          \put(20,4){\line(0,1){2}}
          \put(30,4){\line(0,1){2}}
          \put(40,4){\line(0,1){2}}
          \put(50,3){\line(0,2){4}}
          \put(60,4){\line(0,1){2}}
          \put(70,4){\line(0,1){2}}
          \put(80,4){\line(0,1){2}}
          \put(90,4){\line(0,1){2}}
          \put(100,3){\line(0,2){4}}
         \end{picture}
        }
    }
    \put(0,5){\framebox(10,280){
        \begin{picture}(15,280)
          \@ifundefined{@backtitle}{\let\@backtitle=\@title}{}
          \ifnum\@backtitleline=2{% if the back title is split into two lines, 
            \def\@assignleftrightbacktitle##1\\##2{\def\@rightbacktitle{##1}%
              \def\@leftbacktitle{##2}}
            \expandafter\@assignleftrightbacktitle\@backtitle%
            \put(7,142){\makebox(5,122)[rt]{%
                  \rotatebox[origin=l]{270}{\@rightbacktitle}
            }}
            \put(3,142){\makebox(5,120)[rt]{%
                  \rotatebox[origin=l]{270}{\@leftbacktitle}
            }}%
            }\else{ % if the back title is in one line, 
            \put(5,142){\makebox(5,122)[rt]{%
                  \rotatebox[origin=l]{270}{\@backtitle}
                  }}
          }\fi % end of the title part.
          \put(5,50){\makebox(5,45)[r]{
              \rotatebox[origin=l]{270}{\@author}
                }}

          \put(5,10){\makebox(5,40)[b]{
                \rotatebox[origin=l]{270}{\@month, \@year}
              }}

        \end{picture}
        }}
    \put(20,150){\framebox(135,79){% big label
        \begin{picture}(135,79)
%          \put(27,57.5){\makebox(77,7)[lb]{\huge\bf Master Thesis}}
\ifbachelor
          \put(30,57.5){\makebox(77,7)[cb]{\huge\bf \@maintitle\hfilneg}}
\else
          \put(30,57.5){\makebox(77,7)[cb]{\huge\bf \@maintitle\hfilneg}}
\fi
          \put(18,38){\makebox(19.5,3.5)[lb]{\normalsize Title\hfilneg}}
          \put(47,23){\makebox(85,30){\parbox{85\unitlength}{%
                \linepenalty=100\adjdemerits=10000\tolerance=1200
                \parfillskip=0pt\leftskip=0pt plus 9ex \rightskip=0pt plus 9ex
                \kanjiskip=0zw plus 0.5zw minus 0.1zw
                \def\\{\linebreak[4]}\large\vfil{}\@title\vfil
                }}}
\ifbachelor
          \put(18,20){\makebox(19.5,3.5)[lb]{\footnotesize Supervisor}}
          \put(50,20){\makebox(70,5)[b]{\parbox{70\unitlength}{\large\centerline{\@mainprofessor}}}}
\else
          \put(18,20){\makebox(19.5,3.5)[lb]{\footnotesize Supervisors}}
          \put(50,20){\makebox(70,5)[b]{\parbox{70\unitlength}{\large\centerline{\@mainprofessor}}}}
          \put(50,8){\makebox(70,5)[b]{\parbox{70\unitlength}{\large\centerline{\@professor}}}}
\fi
        \end{picture}
        }}
    \put(40,70){\framebox(110,63){
        \begin{picture}(110,63)
          \put(0,49){\makebox(110,3)[cb]{%
                \kanjiskip=0zw plus 0.05zw minus 0.2zw%
              \parfillskip=0pt
                \rightskip=0mm
                \hspace*{5mm}\hbox{\@course}
              }}
          \put(0,40){\makebox(110,3)[cb]{%
                \hbox{\@department}}}
          \put(19,30){
            \makebox(11,3.5){\normalsize\hfilneg{}Student ID\hfilneg}
           }
          \put(32.5,30){\makebox(59,4)[b]{
              \kanjiskip=1.0zw plus 2.0zw minus 1.0zw%
              \large\hbox to 55\unitlength{%
                \parfillskip=0pt
                \leftskip=0pt plus 11em \rightskip=0pt plus 11em%
                \spacefactor=10000\spaceskip=2em plus 1em minus 2.0em
                \hfil\@IDcode\hfil
                }
              }}
%          \put(19.5,20){
%            \makebox(11,3.5){\normalsize\hfilneg{}Name\hfilneg}
%            }
          %\put(32.5,27.0){\line(1,0){59}}
          \put(32.5,19.5){\makebox(59,4)[b]{
              \kanjiskip=1.0zw plus 2.0zw minus 1.0zw%
              \large\hbox to 55\unitlength{%
                \parfillskip=0pt
                \leftskip=0pt plus 11em \rightskip=0pt plus 11em%
                \spacefactor=10000\spaceskip=2em plus 1em minus 2.0em
                \hfil\@author\hfil
                }
              }}
          \put(19.5,10){\makebox(72,4)[lb]{\noindent
              \kanjiskip=0.3zw plus 0.6zw minus 0.4zw
              \parfillskip=0pt
              \leftskip=0pt \rightskip=0pt %
              \spacefactor=10000\spaceskip=5mm plus 1mm minus 5mm
              \large\hbox to 72\unitlength{%
                \hfilneg Date: \@date \hfilneg
                }
              }}
        \end{picture}
}}
  \end{picture}
\end{center}
\thispagestyle{empty}
}
}


%%%%%%%%%%%%%%
%%% Layout %%%
%%%%%%%%%%%%%%
% レイアウト．
\oddsidemargin  = 0.5cm
\evensidemargin = 0.5cm
\marginparwidth = 68pt
\topmargin      = 0pt
\headheight     = 12pt
\headsep        = 25pt
\footskip       = 30pt

\textheight     = 604pt
\textwidth      = 424pt

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Chars in Line and Lines in Page %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% １行の文字数と１ページの行数から
% \jintercharskip, \baselineskip を自動設定する．

% default values.
\gdef\@charsinline{36}
\gdef\@linesinpage{32}

\def\charsinline#1{\gdef\@charsinline{#1}}
\def\linesinpage#1{\gdef\@linesinpage{#1}}

\let\kitesthesis@document=\document
\def\kitesthesis@adjuestmathskips{%
  \abovedisplayskip .6\baselineskip plus .15\baselineskip minus .3\baselineskip
  \belowdisplayskip \abovedisplayskip
  \abovedisplayshortskip \z@ plus .15\baselineskip
  \belowdisplayshortskip .3\baselineskip plus .15\baselineskip minus .15\baselineskip}
\if@NTT
  \def\document{%
    \kitesthesis@document
    \@tempcnta = \@charsinline \advance\@tempcnta \m@ne
    \@tempdima = \textwidth
    \advance\@tempdima - \@charsinline zw \divide\@tempdima by \@tempcnta
    \jintercharskip = \@tempdima plus 0.5\@tempdima minus 0.33333\@tempdima
    \jasciikanjiskip = .24zw plus .12zw minus .08zw
    \jmathkanjiskip = .24zw plus .12zw minus .08zw
    \parindent = 1zw \advance\parindent + \jintercharskip
    \baselineskip = \textheight \divide\baselineskip by \@linesinpage
    \kitesthesis@adjuestmathskips}
\else
  \def\document{%
    \kitesthesis@document
    \@tempcnta = \@charsinline \advance\@tempcnta \m@ne
    \@tempdima = \textwidth
    \advance\@tempdima - \@charsinline zw \divide\@tempdima by \@tempcnta
    \kanjiskip = \@tempdima plus 0.5\@tempdima minus 0.33333\@tempdima
    \xkanjiskip = .25zw plus .15zw minus .1zw
    \parindent = 1zw \advance\parindent + \kanjiskip
    \baselineskip = \textheight \divide\baselineskip by \@linesinpage
    \kitesthesis@adjuestmathskips}
\fi



%%%%%%%%%%%%%%%%%
%%% Maketitle %%%
%%%%%%%%%%%%%%%%%
% 表紙．
\def\professor#1{\gdef\@professor{#1}}
\def\course#1{\gdef\@course{#1}}
\def\department#1{\gdef\@department{#1}}

\def\offset{0.5}
\iffalse
\def\maketitle{%
  \begin{titlepage}%
    \let\footnoterule\relax \setcounter{page}{0}%
    \thispagestyle{empty}%
    \let\figure\kitesthesis@figure
    \begin{figure}
      \center
      \unitlength = 1cm
      \hspace*{0mm}\\
      \begin{picture}(0,0)(\offset,0)
        \put(2.5,8){\makebox(0,0)[b]{\makebox[8cm]{\Huge \@maintitle}}}%
        \put(-2.5,5.5){\makebox(0,0)[r]{\makebox[2cm]{Title}}}%
        \put(2.5,5.5){\makebox(0,0){\parbox{10cm}{\center \LARGE \@title}}}%
        \ifx\@professor\undefined\else
          \put(-2.5,3){\makebox(0,0)[r]{\makebox[2cm]{Supervisor}}}%
          \put(2.5,3){\makebox(0,0){\parbox{8cm}{\center \LARGE \@professor}}}%
        \fi
        \put(2.5,-6.5){\makebox(0,0)[t]{\@course\ \@department}}%
        \put(-0.5,-8.5){\makebox(0,0)[rb]{\makebox[1.5cm]{氏\hfil 名}}}%
        \put(2.5,-8.7){\makebox(0,0)[b]{\LARGE \underline{\@author}}}%
        \put(2.5,-10){\makebox(0,0)[t]{\large \@date}}%
      \end{picture}
    \end{figure}
    \setcounter{footnote}{0}\let\thanks\relax
    \gdef\@thanks{}\gdef\@author{}\gdef\@title{}%
    \gdef\@professor{}\gdef\@course{}\gdef\department{}%
    \let\maketitle\relax
  \end{titlepage}}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Table of Contents %%%
%%%%%%%%%%%%%%%%%%%%%%%%%
% 目次．
% 目次ページの pagestyle は roman．
\def\tableofcontents{%
  %\setcounter{page}{1}
  \bgroup
    \def\thepage{\roman{page}}%
    %\pagestyle{plain}
    \lineskip = \normallineskip
    \@restonecolfalse
    \if@twocolumn\@restonecoltrue\onecolumn\fi
    \chapter*{\contentsname\@mkboth{\contentsname}{\contentsname}}%
    \@starttoc{toc}\if@restonecol\twocolumn\fi
    \newpage
  \egroup
  %\global\c@page = \@ne % これがあるとページ番号がリセットされてしまう. 
}

\def\contentsname{Table of Contents}

\def\ptex@l@chapter#1#2{%
  \pagebreak[3]
%  \setlength\@lnumwidth{4zw}%
  \vskip 1.0em plus 1pt
  \@tempdima 4em
  \begingroup
    \parindent \z@ \rightskip \@pnumwidth \parfillskip -\@pnumwidth
    \bf \leavevmode
    \advance\leftskip\@tempdima \hskip -\leftskip
    #1\nobreak \hfil\nobreak \hbox to\@pnumwidth{\hss #2}\par
  \endgroup}
\def\jtex@l@chapter#1#2{%
  \pagebreak[3] 
  \vskip 1.0em plus 1pt
  \@tempdima 4em
  \begingroup
    \parindent \z@ \rightskip \@pnumwidth \parfillskip -\@pnumwidth 
    \bf \leavevmode 
    \advance\leftskip\@tempdima \hskip -\leftskip
    #1\nobreak \hfil\nobreak \hbox to\@pnumwidth{\hss #2}\par
  \endgroup}
\if@NTT
  \let\l@chapter\jtex@l@chapter
\else
  \let\l@chapter\ptex@l@chapter
\fi

\def\l@section{\@dottedtocline{1}{1.7em}{2.3em}}
\def\l@subsection{\@dottedtocline{2}{4em}{3.2em}}
\def\l@subsubsection{\@dottedtocline{3}{7.2em}{4.1em}}
\def\l@paragraph{\@dottedtocline{4}{10.2em}{5em}}
\def\l@subparagraph{\@dottedtocline{5}{12.2em}{6em}}

%%%%%%%%%%%%%%%
%%% Chapter %%%
%%%%%%%%%%%%%%%
% 章．
% 章題は `第１章 序論' のように．
% 目次の章題も同様に．
\iffalse
\def\ptex@makechapterhead#1{%
  \vspace*{20pt}%
  { \parindent 0pt \raggedright
    \ifnum \c@secnumdepth >\m@ne
      \LARGE \bf
      \setbox\@tempboxa\hbox{\@chapapp{\thechapter}\@chappos\hskip 10pt}%
      \begin{list}{}{%
        \topsep = 0pt \parsep = 0pt
        \labelwidth = \wd\@tempboxa \labelsep = 0pt
        \leftmargin = \labelwidth
      }\item[\box\@tempboxa] #1
      \end{list}%
    \else
      \LARGE \bf #1\par
    \fi
    \nobreak
    \vskip 10pt }}
\def\jtex@makechapterhead#1{%
  \vspace*{20pt}%
  { \parindent 0pt \raggedright
    \ifnum \c@secnumdepth >\m@ne
      \LARGE \bf
      \setbox\@tempboxa\hbox{\@chapapp{\thechapter}\hskip 10pt}%
      \begin{list}{}{%
        \topsep = 0pt \parsep = 0pt
        \labelwidth = \wd\@tempboxa \labelsep = 0pt
        \leftmargin = \labelwidth
      }\item[\box\@tempboxa] #1
      \end{list}%
    \else
      \LARGE \bf #1\par
    \fi
    \nobreak
    \vskip 10pt }}
\if@NTT
  \let\@makechapterhead\jtex@makechapterhead
\else
  \let\@makechapterhead\ptex@makechapterhead
\fi
\def\@makeschapterhead#1{%
  \vspace*{20pt}%
  { \parindent 0pt
    \raggedright
    \LARGE \bf #1\par
    \nobreak
    \vskip 20pt }}

\def\clearfigurepage{%
  \kitesthesis@iwrite{\string\clearpage}}

\def\chapter{%
  \clearpage
  \clearfigurepage
  \global\@topnum\z@ \@afterindenttrue
  \secdef\@chapter\@schapter}
\def\ptex@chapter[#1]#2{%
  \ifnum \c@secnumdepth >\m@ne
    \refstepcounter{chapter}%
    \typeout{\@chapapp{\thechapter}\@chappos.}%
     \addcontentsline{toc}{chapter}{%
      \protect\numberline{\@chapapp{\thechapter}\@chappos}#1
    }%
  \else
    \addcontentsline{toc}{chapter}{#1}%
  \fi
  \chaptermark{#1}%
  \addtocontents{lof}{\protect\addvspace{10pt}}%
  \addtocontents{lot}{\protect\addvspace{10pt}}%
  \if@twocolumn
    \@topnewpage[\@makechapterhead{#2}]
  \else
    \@makechapterhead{#2}%
    \@afterheading
  \fi}
\def\jtex@chapter[#1]#2{%
  \ifnum \c@secnumdepth >\m@ne
    \refstepcounter{chapter}%
    \typeout{\@chapapp{\thechapter}.}%
    \addcontentsline{toc}{chapter}{%
      \protect\numberline{\@chapapp{\thechapter}}#1
    }%
  \else
    \addcontentsline{toc}{chapter}{#1}%
  \fi
  \chaptermark{#1}%
  \addtocontents{lof}{\protect\addvspace{10pt}}%
  \addtocontents{lot}{\protect\addvspace{10pt}}%
  \if@twocolumn
    \@topnewpage[\@makechapterhead{#2}] 
  \else
    \@makechapterhead{#2}%
    \@afterheading
  \fi}
\if@NTT
  \let\@chapter\jtex@chapter
\else
  \let\@chapter\ptex@chapter
\fi
\def\@schapter#1{%
  \if@twocolumn
    \@topnewpage[\@makeschapterhead{#1}]
  \else
    \@makeschapterhead{#1}%
    \@afterheading
  \fi
}
\fi
\if@NTT
\else
\renewcommand\section{%
  \@startsection{section}{1}{\z@}%
		{3.5ex \@plus 1ex \@minus .2ex}%
		{2.3ex \@plus.2ex}%
		{\normalfont\Large\bfseries}}
\renewcommand\subsection{%
  \@startsection{subsection}{2}{\z@}%
                {3.25ex\@plus 1ex \@minus .2ex}%
                {1.5ex \@plus .2ex}%
                {\normalfont\large\bfseries}}
\renewcommand\subsubsection{%
  \@startsection{subsubsection}{3}{\z@}%
                {3.25ex\@plus 1ex \@minus .2ex}%
                {1.5ex \@plus .2ex}%
                {\normalfont\normalsize\bfseries}}
\fi

%%%%%%%%%%%%%%%%
%%% Footnote %%%
%%%%%%%%%%%%%%%%
% 脚注．
% ２行以上になっても左にはみ出さない．
% マークは \newfnsymbol で．
%\def\newfnsymbol#1{\@newfnsymbol{\@nameuse{c@#1}}}
%\def\@newfnsymbol#1{%
%  \ifcase #1
%    \or *\or        **\or               ***%
%   \or \dagger \or  \dagger\dagger\or   \dagger\dagger\dagger
%    \or \ddagger\or \ddagger\ddagger\or \ddagger\ddagger\ddagger
%    \else \@ctrerr
%  \fi
%  \relax
%}

\long\def\@makefntext#1{%
  \begin{list}{}{%
    \topsep = 0pt \partopsep = 0pt \itemsep = 0pt \parsep = 0pt
    \labelwidth = 1.2em \labelsep = 5pt
    \leftmargin = \labelwidth \advance\leftmargin + \labelsep
  }%
    \item[\hss$^{\@thefnmark}$] #1%
  \end{list}%
}
%\def\thefootnote{\newfnsymbol{footnote}}
\def\thefootnote{\fnsymbol{footnote}}

%%%%%%%%%%%%
%%% List %%%
%%%%%%%%%%%%
% リスト・パラメタ．
\def\@listI{%
  \leftmargin \leftmargini
  \topsep .5\baselineskip plus .2\baselineskip minus .3\baselineskip
  \parsep .25\baselineskip plus .125\baselineskip minus .05\baselineskip
  \itemsep \parsep
}
\let\@listi\@listI
\@listi
\def\@listii{%
  \leftmargin \leftmarginii
  \labelwidth \leftmarginii  \advance\labelwidth - \labelsep
  \topsep .25\baselineskip plus .1\baselineskip minus .15\baselineskip
  \parsep .125\baselineskip plus .0625\baselineskip minus .025\baselineskip
  \itemsep \parsep
}
\def\@listiii{%
  \leftmargin \leftmarginiii
  \labelwidth \leftmarginiii  \advance\labelwidth - \labelsep
  \topsep .125\baselineskip plus .0625\baselineskip minus .025\baselineskip
  \parsep \z@
  \partopsep 1pt plus 0pt minus 1pt
  \itemsep \topsep
}
\def\@listiv{\leftmargin\leftmarginiv
  \labelwidth\leftmarginiv\advance\labelwidth-\labelsep}
\def\@listv{\leftmargin\leftmarginv
  \labelwidth\leftmarginv\advance\labelwidth-\labelsep}
\def\@listvi{\leftmargin\leftmarginvi
  \labelwidth\leftmarginvi\advance\labelwidth-\labelsep}

%%%%%%%%%%%%%%%%%%%%%%%%
%%% Acknowledgements %%%
%%%%%%%%%%%%%%%%%%%%%%%%
% 謝辞．
% 目次に載せる．
\def\acknowledgements{%
  \bgroup
    \c@secnumdepth = \m@ne
    \chapter{\ackname\@mkboth{\ackname}{\ackname}}%
  \egroup
  \relax
}

\def\ackname{Acknoledgement}

%%%%%%%%%%%%%%%%%%%%
%%% Bibliography %%%
%%%%%%%%%%%%%%%%%%%%
% 参考文献．
% 目次に載せる．
\def\thebibliography#1{%
  \bgroup
    \c@secnumdepth = \m@ne
    \chapter{\refname\@mkboth{\refname}{\refname}}%
  \egroup
  \list{[\arabic{enumi}]}{%
    \settowidth\labelwidth{[#1]}%
    \leftmargin\labelwidth \advance\leftmargin\labelsep
    \usecounter{enumi}%
  }%
  \def\newblock{\hskip .11em plus .33em minus .07em}%
  \sloppy\sfcode`\.=1000
  \relax
}
\let\endthebibliography=\endlist

\def\@cite#1#2{%
  \nobreak{[#1\if@tempswa , #2\fi]}%
}

\def\refname{References}

%%%%%%%%%%%%%%%%
%%% Appendix %%%
%%%%%%%%%%%%%%%%
\newcount\@kitesthesis@appseq
\let\kitesthesis@appendix\appendix
\def\appendix{%
    \@kitesthesis@appseq=\@kitesthesis@seq
    \global\advance\@kitesthesis@appseq 1\relax
    \kitesthesis@appendix}


%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Figures and Tables %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\kitesthesis@figureandtable{%
  \advance\textwidth + 2\oddsidemargin
  \advance\textheight + \headheight
  \advance\textheight + \headsep
  \oddsidemargin  = 0pt
  \evensidemargin = 0pt
  \headheight     = 0pt
  \headsep        = 0pt
  \@colht         = \textheight
}

\newcommand{\kitesthesisseparator}{\goodbreak}%{\clearpage}
\newwrite\kitesthesis@post
\newcount\@kitesthesis@open
\def\kitesthesis@openpost{%
    \immediate\openout\kitesthesis@post=\jobname.fff\relax
    \global\@kitesthesis@open=1\relax
    \message{(\jobname.fff)}}
\def\kitesthesis@condopen{%
    \ifnum\@kitesthesis@open>0\relax\else\kitesthesis@openpost\fi}
\def\kitesthesis@iwrite#1{%
    \immediate\write\kitesthesis@post{#1}}
\newcommand*{\kitesthesis@makeinnocent}[1]{\catcode`#1=12 }
\let\kitesthesis@figure\figure
\let\kitesthesis@table\table
\let\kitesthesis@float\relax

\newcount\@kitesthesis@seq
\def\kitesthesis@savevalue#1{%
    \expandafter\newcount\csname @kitesthesis\number\@kitesthesis@seq#1\endcsname
    \expandafter\global\csname @kitesthesis\number\@kitesthesis@seq#1\endcsname=\value{#1}\relax}
\def\kitesthesis@store#1{%
    \global\advance\@kitesthesis@seq 1\relax
    \kitesthesis@savevalue{chapter}
    \kitesthesis@savevalue{#1}}

\let\kitesthesis@thechapter\thechapter
\let\kitesthesis@theappendix\relax
\def\kitesthesis@restorevalue#1{%
    \setcounter{#1}{\csname @kitesthesis\number\@kitesthesis@seq#1\endcsname}}
\def\kitesthesis@restore#1{%
    \global\advance\@kitesthesis@seq 1\relax
    \@tempcnta=\c@chapter
    \kitesthesis@restorevalue{chapter}
    \kitesthesis@restorevalue{#1}
    \ifnum\@kitesthesis@seq=\@kitesthesis@appseq
      \global\let\thechapter\kitesthesis@theappendix
    \fi}

\def\kitesthesis@foundend#1{\def\next{\endgroup\end{kitesthesis@float}%
    \kitesthesis@iwrite{\string\end{#1}}%
    \kitesthesis@iwrite{\string\kitesthesisseparator}%
    \kitesthesis@iwrite{ }}}%
\begingroup
\catcode`\^^M=12\relax%
\gdef\kitesthesis@xfloat#1^^M{%
    \edef\@tempa{#1\kitesthesis@xfloat@to@be@detected}%
    \expandafter\kitesthesis@xfloat@linecheck\@tempa\@nil%
    \ifx\@tempa\@empty%
        \kitesthesis@iwrite{#1}%
        \let\next\kitesthesis@xfloat%
    \else%
        \edef\@tempa{\noexpand\kitesthesis@foundend{\kitesthesis@externalenvname}}%
        \@tempa%
    \fi%
    \next}%
\endgroup%
\begingroup
\catcode`\{=12 \catcode`\[=1
\catcode`\}=12 \catcode`\]=2
\catcode`\|=0 \catcode`\\=12
|gdef|kitesthesis@setup[%
    |edef|kitesthesis@xfloat@to@be@detected[\end{|kitesthesis@envname}]%
    |def|@tempa[|def|kitesthesis@xfloat@linecheck####1]%
    |expandafter|@tempa|kitesthesis@xfloat@to@be@detected##2|@nil[|def|@tempa[##2]]]
|endgroup

\@namedef{figure*}{\figure}
\@namedef{table*}{\table}

\newcommand{\processdelayedfloats@hook}{\@empty}
%\def\AtBeginDelayedFloats{\g@addto@macro\processdelayedfloats@hook}

\newcommand{\processotherdelayedfloats}{\@empty}
\renewcommand{\bottomfraction}{1.0}
\renewcommand{\topfraction}{1.0}
\renewcommand{\textfraction}{0.0}
\newcommand{\processdelayedfloats}{{%
  \let\kitesthesis@theappendix\thechapter
  \def\baselinestretch{1}\normalsize
   \global\@kitesthesis@seq=0
   \global\let\thechapter\kitesthesis@thechapter
   \def\figure{\kitesthesis@restore{figure}\kitesthesis@figure}
   \def\table{\kitesthesis@restore{table}\kitesthesis@table}
   \kitesthesis@figureandtable
   \processdelayedfloats@hook
   \ifnum\@kitesthesis@open>0
     \immediate\closeout\kitesthesis@post
     \global\@kitesthesis@open=0
     %\markboth{\uppercase{\figuresection}}{\uppercase{\figuresection}}
     \@input{\jobname.fff}
   \fi}}
%\AtEndDocument{
%   \message{AED kitesthesis: Processing end Figures and Tables}
%   \onecolumn
%   \processdelayedfloats 
%}
\def\figureandtable{%
  \newpage
  \setcounter{page}{1001}%
  \gdef\thechapter{}%
  \setcounter{figure}{0}%
  \setcounter{table}{0}%
  \pagestyle{empty}%
  \advance\textwidth + 2\oddsidemargin
  \advance\textheight + \headheight
  \advance\textheight + \headsep
  \advance\textheight + \footskip
  \oddsidemargin  = 0pt
  \evensidemargin = 0pt
  \headheight     = 0pt
  \headsep        = 0pt
  \footskip       = 0pt
}
\def\figureandtableof#1{%
\pagestyle{empty}
  \clearpage
  \@ifundefined{r@#1}
    {\@warning{Chapter refered by `#1' undefined}}
    {\edef\@tempa{\@nameuse{r@#1}}%
     \xdef\thechapter{\expandafter\@car\@tempa \@nil}}%
  \setcounter{figure}{0}%
  \setcounter{table}{0}%
}


%% 図, 表を混ぜて1ページに納める.  
\newcommand{\figcaption}[1]{\def\@captype{figure}\caption{#1}}
\newcommand{\tblcaption}[1]{\def\@captype{table}\caption{#1}}


