\LoadClass[a4paper,12pt]{exam}
\RequirePackage[body={8in,11in}, vmargin={0mm,35mm},voffset=0pt, top=0mm, tmargin=30mm, footskip=20pt, hmargin={10mm,18mm}, textwidth=170mm, textheight=240mm, headsep=10pt, a4paper]{geometry}

%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage[english]{babel}
 
%%%%%%%%%%%%%%%%%%%%%%%%%
% Packages 的使用
%%%%%%
\RequirePackage{fancybox, lastpage}
\RequirePackage{calc}
\RequirePackage{amsmath, amssymb, amsthm, mathtools}
\RequirePackage{graphicx}
\RequirePackage{textpos}
\RequirePackage{subfigure}
\RequirePackage{caption}
\RequirePackage{verbatim}
\RequirePackage{wrapfig, picinpar,cutwin}
\RequirePackage{hyperref}
\RequirePackage{booktabs}
\RequirePackage{tasks}
\RequirePackage{array}
\RequirePackage{multirow}
\RequirePackage{multicol}
\RequirePackage{color}
\RequirePackage{colortbl} 
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}b{#1}}%表格自訂長度及置中
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}b{#1}}%表格自訂長度及置左
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}b{#1}}%表格自訂長度及置右
\setlength\columnsep{40pt}
\everymath{\displaystyle}

%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\universityCH[1]{\newcommand{\theuniversityCH}{#1}}
\newcommand\instituteCH[1]{\newcommand{\theinstituteCH}{#1}}
\newcommand\category[1]{\newcommand{\thecategory}{#1}}
\newcommand\subject[1]{\newcommand{\thesubject}{#1}}
\newcommand\schoolyear[1]{\newcommand{\theschoolyear}{#1}}
\newcommand\Exammonth[1]{\newcommand{\theExammonth}{#1}}
\newcommand\Examdate[1]{\newcommand{\theExamdate}{#1}}
\newcommand\ExamWeek[1]{\newcommand{\theExamWeek}{#1}}
\newcommand\ExamTime[1]{\newcommand{\theExamTime}{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%
\input{ExamVariables}

%%%%%%%%%%%%%%%%%%%%%%%%%
% fancy header 的設定
%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{framesep}
\newcounter{framesep1}
\newcounter{framesep2}
\newcounter{framesep3}
\newcounter{framesep4}
\newcounter{framesep5}
\newcounter{footsep}
\newcounter{framewidth}
\newcounter{frameheight}
\newcounter{frameheight2}
\newcounter{frameheight3}
\newcounter{frameheight4}
\newcounter{frameheight5}
\newcounter{frameheight6}
\newcounter{frameheight7}
\setcounter{framesep}{\headsep+\fboxsep} 
\setcounter{framesep1}{\headsep+2*\fboxsep+\fboxsep/2} 
\setcounter{framesep2}{\headsep-8*\fboxsep+\fboxsep/2} 
\setcounter{framesep3}{0*\headsep-1*\fboxsep+\headsep/2} 
\setcounter{framesep4}{1*\headsep-1*\fboxsep} 
\setcounter{framesep5}{\headsep-1*\fboxsep/2} 
\setcounter{footsep}{\footskip}
\setcounter{framewidth}{\textwidth+3*\value{framesep}}
\setcounter{frameheight}{\textheight+4*\value{framesep}-\value{framesep}/4}
\setcounter{frameheight2}{\textheight+3*\value{framesep}-\value{framesep}/2-\value{framesep}/12}
\setcounter{frameheight3}{\textheight+3*\value{framesep1}-\value{framesep}/2-1*\value{framesep}/20}
\setcounter{frameheight4}{1*\textheight+4*\value{framesep}}
\setcounter{frameheight5}{\textheight-37*\value{framesep1}-0*\value{framesep}/2-0*\value{framesep}/2+2*\value{framesep}/5}
\setcounter{frameheight6}{1*\textheight+6*\value{framesep}-\value{framesep1}/8}
\setcounter{frameheight7}{\textheight-37*\value{framesep1}-\value{framesep1}/2-\value{framesep1}/4}
\newcommand{\smb}[1]{{\bf \small #1}}

%%%%%%%%%%%%%%%%%%%%%%%%%
\lhead{
{\fontsize{16pt}{14pt}\selectfont \renewcommand{\arraystretch}{1.3}
{\begin{tabular}{C{13.6cm} R{4cm}}
\multicolumn{2}{c}{\theuniversityCH  \theschoolyear 學年度 \thecategory 試題} \\
 &	{\bf \small 第\,\thepage\,頁，共\,\pageref{LastPage}\,頁} 
\end{tabular}}
\\[5pt]
	}
	\setlength{\unitlength}{1 sp}%
  \begin{picture}(0,0)(0,\value{frameheight})
    \linethickness{1.5pt}
	\put(-\value{framesep5},\value{framesep2}){\framebox(\value{framewidth},\value{frameheight6}){}}
	\put(-\value{framesep5},\value{frameheight2}){\linethickness{0.5pt}\line(\value{framewidth},0){\value{framewidth}}}
 	\put(-\value{framesep3},\value{frameheight3}){\renewcommand{\arraystretch}{2.5}{\begin{tabular}{C{2cm}| C{3cm} | C{2cm} | C{3cm} | C{2cm} | C{4.5cm} }
	\textbf{考試科目} 		& 
	\textbf{\thesubject} 			& 				% 科目名稱
	\textbf{系所別} 		& 
	\textbf{\theinstituteCH} 			&				% 系級名稱
	\smb{考試時間} 				& 
	\smb{\theExammonth 月\theExamdate 日(\theExamWeek) 第\theExamTime 節}		
	\end{tabular}}}
	\put(-\value{framesep5},\value{frameheight5}){\linethickness{0.5pt}\line(\value{framewidth},0){\value{framewidth}}}
	\put(-\value{framesep3},\value{frameheight7}){\fontsize{12pt}{14pt}\selectfont \renewcommand{\arraystretch}{2.3}\begin{tabular}{p{2.5cm}| L{14.5cm}}
		%\hline
		\smb{\makebox[2.5cm][s]{備註}} 	&  	{\renewcommand{\arraystretch}{1.0}\tabincell{L{14.5cm}}{一、作答於試題上者，不予計分\\ 二、試題隨卷繳交 }}  \\
		%\hline
		\end{tabular}}
    \end{picture}
	}
\chead{}
\rhead{}
\lfoot{\vskip 0mm{\fontsize{12pt}{14pt}{ \renewcommand{\arraystretch}{1.0}\tabincell{l}{$\ast $ 本份試題已依「命題注意事項」 出題，並未與本校近兩年考古題及當年度該系所期中、期末考題重覆。\\
命題委員(簽名)： \hskip 17em 系所主管(簽名)：}}
}}
\cfoot{}
\rfoot{}
\setlength{\headsep}{25pt}
\setlength{\textheight}{220mm}
\setlength{\footskip}{24mm}