\newcounter{時間表始}
\newcounter{時間表終}
\newcounter{始}
\newcounter{終}
\newcounter{時間}
\newcounter{日}
\newcounter{時}
\newcounter{分}
\newcounter{期日}
\newcounter{部屋}
\newcounter{高}
\newcounter{幅}
\newcounter{縦}
\newcounter{横}
\newcounter{回}
\newcounter{室}
\newcounter{番号}
\newcounter{卒件数} \setcounter{卒件数}{0}
\newcounter{修件数} \setcounter{修件数}{0}
\newcounter{セ件数} \setcounter{セ件数}{0}
\newcounter{卒人数} \setcounter{卒人数}{0}
\newcounter{修人数} \setcounter{修人数}{0}
\newcounter{セ人数} \setcounter{セ人数}{0}

\newcounter{UNIT}\setcounter{UNIT}{0}

\def\@RBOX#1[#2]#3{%
\@tempdima=#1\relax%
\setbox\@tempboxa=\hbox{#3}%
\ifdim\wd\@tempboxa<\@tempdima%
	\makebox[#1][#2]{\usebox{\@tempboxa}}%
\else%
	\resizebox{\@tempdima}{\height}{\usebox{\@tempboxa}}%
\fi%
}
\def\RBOX#1{\@ifnextchar[{\@RBOX{#1}}{\@RBOX{#1}[c]}}

\def\minute#1{\ifnum \csname c@#1\endcsname < 10 0\arabic{#1}\else \arabic{#1}\fi}

\def\memo#1{\@ifnextchar[{\memolabel{#1}}{\memoref{#1}}}
\def\memoref#1{\ref{#1}}
\def\memolabel#1[#2]{\@bsphack\if@filesw {\let\thepage\relax
 \def\protect{\noexpand\noexpand\noexpand}%
 \xdef\@gtempa{\write\@auxout{\string \newlabel{#1}{{#2}{\thepage}{}}}}}\@gtempa \if@nobreak \ifvmode\nobreak\fi\fi\fi\@esphack%
}

\def\TtoM{15}

\def\期日#1{\@ifnextchar[{\@期日def{#1}}{\@期日{#1}}}
\def\@期日def#1[#2]{\@namedef{期日#1}{#2}}
\def\@期日#1{\@nameuse{期日#1}}

\def\今年{\@ifnextchar[{\@今年def}{\@今年}}
\def\@今年def[#1]{\@namedef{今年}{#1}}
\def\@今年{\@nameuse{今年}}

\def\今年度{\@ifnextchar[{\@今年度def}{\@今年度}}
\def\@今年度def[#1]{\@namedef{今年度}{#1}}
\def\@今年度{\@nameuse{今年度}}

\newcounter{部屋数}\setcounter{部屋数}{0}
\def\部屋名#1{\@ifnextchar[{\@部屋名def{#1}}{\@部屋名{#1}}}
\def\@部屋名def#1[#2]{\@namedef{部屋名#1}{#2}\ifnum#1>\c@部屋数\relax\setcounter{部屋数}{#1}\fi}
\def\@部屋名#1{\@nameuse{部屋名#1}}

\def\時刻#1{%
 \c@時=#1\relax%
 \divide\c@時 60\relax%
 \c@分=\c@時\relax%
 \multiply\c@分 60\relax%
 \c@分=-\c@分\relax%
 \advance \c@分 #1\relax%
 \the\c@時:\minute{分}%
}

\newcounter{presentation}

\def\@nameedef#1#2{\expandafter\edef\csname#1\endcsname{#2}}

\def\UNIT日#1:#2:#3:#4:#5:#6:#7:#8□{#1}
\def\UNIT室#1:#2:#3:#4:#5:#6:#7:#8□{#2}
\def\UNIT始#1:#2:#3:#4:#5:#6:#7:#8□{#3}
\def\UNIT終#1:#2:#3:#4:#5:#6:#7:#8□{#4}
\def\UNIT種#1:#2:#3:#4:#5:#6:#7:#8□{#5}
\def\UNIT間#1:#2:#3:#4:#5:#6:#7:#8□{#6}
\def\UNIT名#1:#2:#3:#4:#5:#6:#7:#8□{#7}
\def\UNIT人#1:#2:#3:#4:#5:#6:#7:#8□{#8}
\def\UNIT表示{
	\@tempcnta\z@\@whilenum\@tempcnta<\c@UNIT \do {\advance\@tempcnta\@ne\relax
		\edef\XXXX{\@nameuse{UNIT:\the\@tempcnta}□}
		\typeout{
			\expandafter\UNIT日\XXXX:
			\expandafter\UNIT室\XXXX:
			\expandafter\UNIT始\XXXX:
			\expandafter\UNIT終\XXXX:
			\expandafter\UNIT種\XXXX:
			\expandafter\UNIT間\XXXX:
			\expandafter\UNIT名\XXXX:
			\expandafter\UNIT人\XXXX:
		}
}}

\gdef\@UNIT名{}

\def\UNIT登録#1#2#3#4#5{%
\edef\始{#1}%
\def\@UN{#3:#4:#5}\ifx\@UNIT名\@UN%
	\edef\XXXX{\@nameuse{UNIT:\the\c@UNIT}□}%
	\edef\始{\expandafter\UNIT始\XXXX}%
	\@tempcntb=\expandafter\UNIT人\XXXX\relax%
	\advance\@tempcntb\@ne\relax%
\else%
	\addtocounter{UNIT}{1}%
	\gdef\@UNIT名{#3:#4:#5}%
	\@tempcntb\@ne\relax%
\fi%
\global\@nameedef{UNIT:\the\c@UNIT}{\the\c@期日:\the\c@部屋:\始:#2:#3:#4:#5:\the\@tempcntb}%
}

\def\発表#1#2#3#4#5{%
	\global\c@終=\c@始\relax\global\advance \c@終 #2\relax%
	\UNIT登録{\the\c@始}{\the\c@終}{#1}{#2}{#3}%
	{\footnotesize\global\advance \c@番号 1\relax\arabic{番号}}	&
	{\scriptsize\em\raisebox{.2em}{\時刻{\c@始}}}	&
	{\scriptsize\em\raisebox{-.1em}{\時刻{\c@終}}}	&
	\refstepcounter{presentation}%
	\pdfbookmark{#4}{\arabic{presentation}}%
	{\RBOX{7em}{\small{\bfseries#4}}}	&%
	{\RBOX{3.5em}{\footnotesize#3}}	&%
	{\RBOX{0.99\hsize}[l]{\small#5}}%
	\global\c@始=\c@終\relax	\\
	\hline
}

\def\修論発表#1#2#3{\global\advance\c@修件数\@ne\relax\global\advance\c@修人数\@ne\relax\発表{修論}{25}{#1}{#2}{#3}}
\def\卒論発表#1#2#3{\global\advance\c@卒件数\@ne\relax\global\advance\c@卒人数\@ne\relax\発表{卒論}{15}{#1}{#2}{#3}}
\def\卒論２発表#1#2#3{\global\advance\c@卒件数\@ne\relax\global\advance\c@卒人数2\relax\発表{卒論}{25}{#1}{#2}{#3}}
\def\セミナー発表#1#2#3{\global\advance\c@セ件数\@ne\relax\global\advance\c@セ人数\@ne\relax\発表{セミナ}{15}{#1}{#2}{#3}}

\def\休憩#1{\par\vspace{1ex}　　休　憩　（#1分）\gdef\@UNIT名{}\global\advance \c@始 #1\relax\vspace{1ex}\par}

\def\日時設定#1#2#3{
\global\c@日=#1\relax
\global\c@時=#2\relax
\global\c@分=#3\relax
\global\c@始=\c@時\global\multiply\c@始 60 \global\advance \c@始 \c@分
}

\newenvironment{セッション}[4]{
\def\休憩##1{\multicolumn{6}{|l|}{　休　憩　（##1分）\gdef\@UNIT名{}\global\advance \c@始 ##1\relax}\\\hline}
\c@部屋=#1\relax
\c@期日=#2\relax
\def\sessionID{session:\@部屋名{#1}:#2:#3}
\global\c@番号=0
 \c@時=\c@始\relax\divide\c@時 60\relax\c@分=\c@時\relax%
 \multiply\c@分 60\relax\c@分=-\c@分\relax\advance \c@分 \c@始\relax%
\memo{\sessionID:始}[\arabic{時}:\minute{分}]
\tabcolsep3pt
\renewcommand{\arraystretch}{1.3}
\noindent\begin{tabular}{|c|r@{$\,$--$\,$}r|l|c|p{0.6\hsize}|}
\multicolumn{6}{l}{\@部屋名{#1}【\今年\期日{#2}，#4，\memo{\sessionID:始}$\sim$\memo{\sessionID:終}】}	\\
\hline
\multicolumn{1}{|c|}{\RBOX{1.5em}{\footnotesize\sffamily No.}}	&
\multicolumn{2}{c|}{\footnotesize 時　間}	&
\multicolumn{1}{c|}{\footnotesize 発表者氏名}	&
\multicolumn{1}{c|}{\footnotesize 研究室}	&
\multicolumn{1}{c|}{\footnotesize 論　　文　　題　　目}	\\
\hline
}{
\end{tabular}
\par
 \c@時=\c@終\relax\divide\c@時 60\relax\c@分=\c@時\relax%
 \multiply\c@分 60\relax\c@分=-\c@分\relax\advance \c@分 \c@始\relax%
\memo{\sessionID:終}[\arabic{時}:\minute{分}]
}

\definecolor{修論背}{rgb}{1.0,.95,.8}
\definecolor{修論枠}{rgb}{.8,.3,.1}
\def\修論文字{\footnotesize\bfseries}
\def\修論枠幅{\thicklines}

\definecolor{卒論背}{rgb}{.95,1.0,.9}
\definecolor{卒論枠}{rgb}{.2,.6,.1}
\def\卒論文字{\footnotesize}
\def\卒論枠幅{\thinlines}

\definecolor{セミナ背}{rgb}{.95,1.0,.9}
\definecolor{セミナ枠}{rgb}{.2,.6,.1}
\def\セミナ文字{\scriptsize}
\def\セミナ枠幅{\thinlines}

\definecolor{夜間}{rgb}{.9,.9,.9}

\def\@時間表部屋全体幅{13500}
\def\@部屋位置計算#1{%
	\@tempcntb=#1\relax\advance\@tempcntb\m@ne\relax%
	\c@横=\@時間表部屋全体幅\relax\divide\c@横 by \c@部屋数\relax\multiply\c@横 by \@tempcntb\relax%
}
\def\@部屋幅計算{\c@幅=\@時間表部屋全体幅\relax\divide\c@幅 by \c@部屋数\relax}

\def\@時間枠#1#2#3#4#5#6#7{%
 \c@室=#1\relax%
 \c@始=#2\relax%
 \c@終=#3\relax%
 \@部屋位置計算{\c@室}\advance \c@横 100\relax%
 \@部屋幅計算\advance \c@幅 -200\relax%
 \ifnum \c@始 < \c@時間表始\relax%
 \else\ifnum \c@終 > \c@時間表終\relax%
 \else%
  \c@高=\c@終\advance\c@高 -\c@始\multiply\c@高 \TtoM\relax%
  \c@縦=\c@時間表終\advance\c@縦 -\c@終\multiply\c@縦 \TtoM\relax%
  \advance\c@始 -\c@時間表終\relax\multiply\c@始 \TtoM\relax%
  \advance\c@終 -\c@時間表終\relax\multiply\c@終 \TtoM\relax%
  \begin{color}{#7}%
  \@tempdima\c@幅 mm\divide\@tempdima 100\relax%
  \@tempdimb\c@高 mm\divide\@tempdimb 100\relax%
  \edef\@W{\the\@tempdima}\edef\@H{\the\@tempdimb}%
  \put(\c@横,-\c@終){\rule{\@W}{\@H}}%
  \begin{color}{#6}%
%  \put(\c@横,-\c@始){\line(1,0){\c@幅}}%
%  \put(\c@横,-\c@終){\line(1,0){\c@幅}}%
%  \put(\c@横,-\c@終){\line(0,1){\c@高}}%
%  \advance\c@横 \c@幅 \put(\c@横,-\c@終){\line(0,1){\c@高}}%
     \put(\c@横,-\c@終){\framebox(\c@幅,\c@高){}}
  \end{color}%
  \end{color}%
  \begin{color}{black}%
  \advance \c@横 100\relax%
  \advance \c@幅 -200\relax%
  \@tempdima=\c@幅 mm\divide\@tempdima 100\relax%
  \edef\@W{\the\@tempdima}%
  \put(\c@横,\c@縦){\makebox(\c@幅,\c@高){#4\RBOX{\@W}[c]{\shortstack[l]{#5}}}}%
  \end{color}%
 \fi\fi%
}

\def\@時間表枠X#1{%
\ifnum #1=\z@ 0
\else\ifnum #1=-2 -3500
\else\ifnum #1=-1 -1000
\else\ifcase #1\or 0\or 2700\or 5400\or 8100\or 10800\or 13500\fi
\fi\fi\fi}

\def\@時間表枠W#1{
\ifnum #1=\z@ 17000
\else\ifnum #1=-2 2500
\else\ifnum #1=-1 1000
\else 2700
\fi\fi\fi}

\def\時間表表示#1#2#3#4#5{%
\begin{center}
\small
 \c@時間表始=#2\multiply \c@時間表始 60 \advance \c@時間表始 #3
 \c@時間表終=#4 \multiply \c@時間表終 60 \advance \c@時間表終 #5
 \c@時間=\c@時間表終 \advance \c@時間 -\c@時間表始
 \c@高=\c@時間 \multiply\c@高 \TtoM
 \advance \c@高 500
 \c@幅=\@時間表枠W{0}
 \unitlength.01mm
 \begin{picture}(\c@幅,\c@高)(\@時間表枠X{-2},0)
%
  \begin{color}{夜間}
  \c@始=18\multiply\c@始 60
  \c@終=\c@時間表終\advance\c@終 -\c@始
  \c@高=\c@始\advance\c@高 -\c@時間表始
  \multiply \c@終 \TtoM\relax
  \multiply \c@高 \TtoM\relax
  \c@高= -1440\relax\multiply\c@高 by #1\relax\advance\c@高 1440\relax%
  \advance\c@高\c@時間表終\relax\advance\c@高 -1080\relax%
  \multiply \c@高 \TtoM\divide\c@高100\relax
  \ifnum\c@高>0
	\c@幅=\@時間表部屋全体幅\relax\advance\c@幅\@時間表枠W{-1}\relax\divide\c@幅100\relax
	\@tempdima=\c@幅 mm\relax
	\@tempdimb=\c@高 mm\relax
	\edef\@W{\the\@tempdima}
	\edef\@H{\the\@tempdimb}
	\typeout{夜間(\@W, \@H)}
	\put(\@時間表枠X{-1},0){\rule{\@W}{\@H}}%
  \fi
  \end{color}
%
 \put(\@時間表枠X{-2},0){\framebox(\c@幅,\c@高){}}
 \put(\@時間表枠X{-1},0){\line(0,1){\c@高}}
 \@tempcnta=\z@\relax\@whilenum\@tempcnta<\c@部屋数 \do {\advance\@tempcnta\@ne\relax%
	\@部屋位置計算{\the\@tempcnta}%
	\put(\c@横,0){\line(0,1){\c@高}}%
 }
 \advance \c@高 -500
 \put(\@時間表枠X{-2},\c@高){\line(1,0){\c@幅}}
 \put(\@時間表枠X{-2},\c@高){\makebox(\@時間表枠W{-2},500){期日（曜日）}}
 \put(\@時間表枠X{-1},\c@高){\makebox(\@時間表枠W{-1},500){時間帯}}
 \@tempcnta=\z@\relax\@whilenum\@tempcnta<\c@部屋数 \do {\advance\@tempcnta\@ne\relax%
	\@部屋位置計算{\the\@tempcnta}\@部屋幅計算%
	\put(\c@横,\c@高){\makebox(\c@幅,500){\@部屋名{\the\@tempcnta}}}
  }
 \c@終=\c@時間表始 \advance \c@終 29 \divide \c@終 30  \multiply \c@終 30
 \@whilenum \c@終 < \c@時間表終 \do {
  \c@始=\c@終 \divide \c@始 60 \multiply \c@始 60 \advance \c@始 -\c@終
  \ifnum \c@始=\z@
   \c@始=\c@終 \advance \c@始 -\c@時間表終
   \multiply\c@始 \TtoM
   \c@回=\@時間表部屋全体幅\divide\c@回 100\relax\multiput(\@時間表枠X{1},-\c@始)(100,0){\c@回}{\line(1,0){67}}
   \put(\@時間表枠X{1},-\c@始){\line(-1,0){100}}
  \fi
  \c@始=\c@終
%  \advance \c@始 30
  \advance \c@始 -\c@時間表終 \multiply \c@始 \TtoM
  \c@高=25 \multiply \c@高 \TtoM
  \put(\@時間表枠X{-1},-\c@始){\makebox(\@時間表枠W{-1},0)[r]{\scriptsize\em\時刻{\c@終}\ \ }}
  \advance \c@終 30
 }
 \ifnum #1=\@ne
  \c@始=18\multiply\c@始 60\relax
  \c@終=\c@時間表終\advance\c@終 -\c@始\relax
  \c@高=\c@始\advance\c@高 -\c@時間表始\relax
  \multiply \c@終 \TtoM\relax
  \multiply \c@高 \TtoM\relax
  \put(\@時間表枠X{-2},\c@終){\makebox(\@時間表枠W{-2},\c@高)[c]{\期日{#1}}}
%   \multiput(\@時間表枠X{-2},\c@終)(100,0){50}{\line(1,0){25}}
%  \put(\@時間表枠X{-2},0){\makebox(\@時間表枠W{-2},\c@終)[c]{\shortstack{電気電子工学\\セミナー\\（夜間主コース）}}}
 \else
  \c@高=\c@時間表終\advance\c@高 -\c@時間表始\relax
  \multiply \c@高 \TtoM\relax
   \c@回=\@時間表枠W{-2}\divide\c@回 100\relax
  \put(\@時間表枠X{-2},0){\makebox(\@時間表枠W{-2},\c@高)[c]{\期日{#1}}}
 \fi
%
 \@tempcnta\z@\@whilenum\@tempcnta<\c@UNIT \do {\advance\@tempcnta\@ne\relax%
  \edef\XXXX{\@nameuse{UNIT:\the\@tempcnta}□}%
  \ifnum #1=\expandafter\UNIT日\XXXX\relax%
   \c@始=\expandafter\UNIT始\XXXX\relax%
   \c@終=\expandafter\UNIT終\XXXX\relax%
   \edef\@KIND{\expandafter\UNIT種\XXXX}%
   \csname\@KIND 枠幅\endcsname%
   \@時間枠{\expandafter\UNIT室\XXXX}{\c@始}{\c@終}{\csname\@KIND 文字\endcsname}{\expandafter\UNIT名\XXXX{\mdseries （{\expandafter\UNIT人\XXXX}）}}{\@KIND 枠}{\@KIND 背}%
 \fi%
 }
 \end{picture}
\end{center}
}

\pagestyle{empty}

