\LoadClass[a4paper,12pt, oneside]{book}
\PassOptionsToPackage{table,xcdraw}{xcolor}
%===== Language =====
\RequirePackage[english]{babel} 
\RequirePackage[titles,subfigure]{tocloft}
\RequirePackage{preamble/xCJKnumb}

%===== Preamble =====
\RequirePackage{cite}
\RequirePackage[hyphens]{url}
%Verbatim with URL-sensitive line breaks.
%\RequirePackage{hyperref}
\RequirePackage[colorlinks=true,linkcolor=black,citecolor=black,filecolor=blue,urlcolor=blue,unicode,linktocpage]{hyperref}
%The hyperref package is used to handle cross-referencing commands in LaTeX to produce hypertext links in the document. The package provides backends for the \special set defined for HyperTeX DVI processors; for embedded pdfmark commands for processing by Acrobat Distiller (dvips and Y&Y’s dvipsone); for Y&Y’s dviwindo; for PDF control within pdfTeX and dvipdfm; for TeX4ht; and for VTeX’s pdf and HTML backends.
\RequirePackage{verbatim}
%The verbatim environment  simply reproduces every character you input, including all  s p a c e s!
\RequirePackage{color}
%you can set the color of the font of the text, and set the background color of the page.
\RequirePackage[dvipsnames]{xcolor}
%xecolor package is a simple package which defines about 140 different colors by XeTeX's font
\RequirePackage{array}
%The array environment is used to make a table of information, with column alignment (left, center, or right) and optional vertical lines separating the columns.
\RequirePackage{gensymb}
%Provides generic commands \degree, \celsius, \perthousand, \micro and \ohm which work both in text and maths mode.
%\RequirePackage{indentfirst}
%Make the first line of all sections etc., be indented by the usual paragraph indentation. This should work with all the standard document classes. This minimalist package is part of the "tools" bundle in the LaTeX required distribution.
\RequirePackage{algorithm}
\RequirePackage{algpseudocode}
%A suite of tools for typesetting algorithms in pseudo-code. The algorithmicx package provides many possibilities to customize the layout of algorithms. You can use one of the predefined layouts (pseudocode, pascal and c and others), with or without modifications, or you can define a completely new layout for your specific needs.
\RequirePackage{enumitem}
%Control layout of itemize, enumerate, description.  It supersedes both enumerate and mdwlist (providing well- structured replacements for all their funtionality), and in addition provides functions to compute the layout of labels, and to 'clone' the standard environments, to create new environments with counters of their own.
\RequirePackage{mfirstuc}
%\makefirstuc{〈stuff 〉} This makes the first object of 〈stuff 〉 uppercase unless 〈stuff 〉 starts with a con- trol sequence followed by a non-empty group, in which case the first object in the group is converted to uppercase.
\RequirePackage{fancyvrb}
%This package provides very sophisticated facilities for reading and writing ver- batim TEX code.
%\RequirePackage{amsfonts}
%TeX fonts from the American Mathematical Society.
\RequirePackage{ifmtarg}
%If-then-else command for processing potentially empty arguments.
%\RequirePackage{lmodern}%會跟Times New Roman 衝突
%The Latin Modern family of fonts consists of 72 text fonts and 20 mathematics fonts, and is based on the Computer Modern fonts released into public domain by AMS (copyright © 1997 AMS).
\font\lmr="[lmroman10-regular]"

\RequirePackage{listings}
%Typeset source code listings using LaTeX.
\RequirePackage{textcomp}
%provide many text symbols (such as baht, bullet, copyright, musicalnote, onequarter, section, and yen)

\RequirePackage{numprint}
%Print numbers with separators and exponent if necessary.
\npthousandsep{,}
\npthousandthpartsep{}
\npdecimalsign{.}

\RequirePackage{multirow}
%Create tabular cells spanning multiple rows.

\RequirePackage[notbib]{tocbibind}
%Add (or disable) bibliography/index/contents to Table of Contents.
\RequirePackage{rotating}
%Rotation tools, including rotated full-page floats.
\RequirePackage{hhline}
%The command \hhline produces a line like \hline, or a double line like \hline\hline, except for its interaction with vertical lines. The command takes a preamble (rather like the preamble of a tabular environment), and this specifies whether there are to be one or two horizontal lines, and what happens when the horizontal line meets a vertical one. The package is part of the tools bundle in the LaTeX required distribution.
\RequirePackage{wallpaper}
%Easy addition of wallpapers (background images) to LaTeX documents, including tiling.
\RequirePackage{pdfpages}
%Include PDF documents in LaTeX.
\RequirePackage{pst-fractal,pst-exa}
% The package will draw the Julia and Mandelbrot sets, the Sierpinski triangle, Koch flake, and Apollonius Circle as well as fractal trees (which need not be balanced) with a variety of different parameters (including varying numbers of iterations).

\RequirePackage{scalerel}
\RequirePackage{tabstackengine}
\RequirePackage{enumitem}

%%grffile
\makeatletter
\def\Gread@@xetex#1{%
	\IfFileExists{"\Gin@base".bb}%
	{\Gread@eps{\Gin@base.bb}}%
	{\Gread@@xetex@aux#1}%
}
\makeatother

%Define \XeTeX \XeLaTeX command
\def\reflect#1{{\setbox0=\hbox{#1}\rlap{\kern0.5\wd0
			\special{x:gsave}\special{x:scale -1 1}}\box0 \special{x:grestore}}}
\def\XeLaTeX{\leavevmode
	\setbox0=\hbox{X\lower.5ex\hbox{\kern-.15em\reflect{E}}\kern-.08em\LaTeX}%
	\dp0=0pt\ht0=0pt\box0}
\def\XeTeX{\leavevmode
	\setbox0=\hbox{X\lower.5ex\hbox{\kern-.15em\reflect{E}}\kern-.08em\TeX}%
	\dp0=0pt\ht0=0pt\box0}

% \RequirePackage[none]{hyphenat}  %hyphenation package

%===== Fonts =====
\RequirePackage{amsfonts,amssymb,amsbsy,latexsym}
%\RequirePackage{palatino,mathpazo}%會跟Times New Roman 衝突
\RequirePackage{siunitx, pifont}
%===== End of Fonts ===== 

%=====
\RequirePackage{amsmath,amsthm,amscd,bm}
%功能更為強大，也保留amsmath所有命令並加入許多設定、符號以及環境
\RequirePackage{mathtools,stmaryrd}%其實有mathtools，就不需要amsmath
\RequirePackage{indentfirst} % indent the first par after section
\RequirePackage{geometry,type1cm,fancyhdr,graphicx,tabularx}
%=====


\theoremstyle{plain}
%===== 全名 Theorem environment =====
\newtheorem{theorem}{Theorem}[section]%Theorem 獨立編號
\newtheorem*{theorem*}{Theorem}%Theorem 不編號
\newtheorem{definition}[theorem]{Definition}%Definition 與 Theorem 共用編號
\newtheorem*{definition*}{Definition}%Definition 不編號
\newtheorem{proposition}[theorem]{Proposition}%Proposition 與 Theorem 共用編號
\newtheorem*{proposition*}{Proposition}%Proposition 不編號
\newtheorem{lemma}[theorem]{Lemma}%Lemma 與 theorem 共用編號
\newtheorem*{lemma*}{Lemma}%Lemma 不編號
\newtheorem{corollary}[theorem]{Corollary}% Corollary 與 Theorem 共用編號
\newtheorem*{corollary*}{Corollary}%Corollary 不編號
\newtheorem{conjecture}[theorem]{Conjecture}%Conjecture 與 Theorem 共用編號
\newtheorem*{conjecture*}{Conjecture}%Conjecture 不編號
\newtheorem{remark}[theorem]{Remark}%Remark與 Theorem 共用編號
\newtheorem{remarks}[theorem]{Remark}%Remark與 Theorem 共用編號
\newtheorem*{remark*}{Remark}%Remark 不編號
\newtheorem{example}[theorem]{Example}%Example 獨立編號
\newtheorem*{example*}{Example}%Example 不編號
\numberwithin{equation}{section}
\newtheorem{claim}{Claim}
\newtheorem*{claim*}{Claim}
\newtheorem{case}{Case}
\newtheorem*{case*}{Case}
\newtheorem{problem}[theorem]{Problem}

%===== 縮寫 Theorem environment =====
\newtheorem{thm}{Theorem}[section]%Theorem 獨立編號
\newtheorem*{thm*}{Theorem}%Theorem 不編號
\newtheorem{defn}[thm]{Definition}%Definition 與 Theorem 共用編號
\newtheorem*{defn*}{Definition}%Definition 不編號
\newtheorem{prop}[thm]{Proposition}%Proposition 與 Theorem 共用編號
\newtheorem*{prop*}{Proposition}%Proposition 不編號
\newtheorem{lem}[thm]{Lemma}%Lemma 與 theorem 共用編號
\newtheorem*{lem*}{Lemma}%Lemma 不編號
\newtheorem{cor}[thm]{Corollary}% Corollary 與 Theorem 共用編號
\newtheorem*{cor*}{Corollary}%Corollary 不編號
\newtheorem{conj}[thm]{Conjecture}%Conjecture 與 Theorem 共用編號
\newtheorem*{conj*}{Conjecture}%Conjecture 不編號
\newtheorem{rmk}[thm]{Remark}%Remark與 Theorem 共用編號
\newtheorem*{rmk*}{Remark}%Remark 不編號
\newtheorem{eg}[thm]{Example}%Example 獨立編號
\newtheorem*{eg*}{Example}%Example 不編號

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\theoremstyle{remark} 
\newtheorem*{pf}{Proof} 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage[all]{xy}
%\RequirePackage{diagram}%會跟remark衝突
%
\RequirePackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\RequirePackage{tikz-cd}

%%%%%%%%%圖
%多圖並排
\makeatletter
\let\c@lofdepth\relax
\let\c@lotdepth\relax
\makeatother
\RequirePackage{subfigure}%與subcaption衝突。還有跟tocloft套件中的lofdepth這個名稱重複定義，所以要加上面四句

%圖標題設定
\RequirePackage{caption}%與floatrow、chemscheme衝突
\RequirePackage{capt-of}% or 其實\RequirePackage{caption}就夠用了，一樣與floatrow、chemscheme衝突

%假如原始圖檔名稱有空格或多個點號，就需要用到這個套件
\RequirePackage{grffile}

%顯示原始指令或程式碼
\RequirePackage{verbatim}

%文繞圖
\RequirePackage{wrapfig, picinpar,cutwin}

%隨機亂文，在做範例可以用，正式論文可不用
\RequirePackage{lipsum}

\usepackage{lscape}

\RequirePackage[normalem]{ulem}

\RequirePackage{pdfpages}

\RequirePackage{booktabs}
\RequirePackage[online]{threeparttable}
\newcommand{\tabincell}[2]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
\RequirePackage{float}

\RequirePackage{makecell}
\newcolumntype{"}{!{\vrule width1.5mm}}%粗線

\RequirePackage{pifont}%特殊符號
\RequirePackage{hhline}
\RequirePackage{setspace}
\RequirePackage{listings}
\RequirePackage{ragged2e}
\RequirePackage{ifthen}
\RequirePackage{xstring,xifthen}
\RequirePackage[bottom,flushmargin]{footmisc}%頁尾與本文距離
\RequirePackage[title,titletoc]{appendix}%附錄

%%%%%%%%%%%%%%%%%
\usetikzlibrary{matrix, decorations.pathreplacing, calc, positioning, arrows, fit, backgrounds}
\pgfdeclarelayer{myback}
\pgfsetlayers{myback,background,main}
\RequirePackage{longtable}
\RequirePackage{tabu}
\RequirePackage{colortbl}

%%%%%%%%%%%%%%


%%%%註解行列
\newcommand\coolover[2]{\mathrlap{\smash{% 
			\overbrace{\phantom{\begin{matrix} #2 %
			\end{matrix}}}^{\mbox{$#1$}}}}#2}

\newcommand\coolunder[2]{\mathclap{\smash {%底中
			\underbrace{\phantom{\begin{matrix} #2 %
			\end{matrix}}}_{\mbox{ $#1$}}}}#2}
\newcommand\coolunderl[2]{\mathllap{\smash {%底左
			\underbrace{\phantom{\begin{matrix} #2 %
			\end{matrix}}}_{\mbox{ $#1$}}}}#2}
\newcommand\coolunderr[2]{\mathrlap{\smash {%底右
			\underbrace{\phantom{\begin{matrix} #2 %
			\end{matrix}}}_{\mbox{ $#1$}}}}#2}

\newcommand\coolleftbrace[2]{%
	#1\left\{\vphantom{\begin{matrix}%
			#2 \end{matrix}}\right.}

\newcommand\coolGVrightbrace[2]{%右
	\left.\vphantom{\begin{matrix}%
			#1 \end{matrix}}\right\}#2}
\newcommand\coolGPrightbrace[2]{%右
	\left.\phantom{\begin{matrix}%
			#1 \end{matrix}}\right\}#2}
%%%%
%%%%%highlight
\tikzset{ highlight/.style={draw, rectangle,rounded corners,fill=blue!15,fill opacity=0.2,thick,inner sep=0.5pt} }
\newcommand{\tikzmark}[2]{\tikz[overlay,remember picture,baseline=(#1.base)] \node (#1) {$#2$};}
%
\newcommand{\Highlight}[1][submatrix]{%
	\tikz[overlay,remember picture]{
		\node[highlight,fit=(left.north west) (right.south east)] (#1) {};}
}

%%%guava highlight%%%%
\newcommand{\guavaoverlay}[2][]{\tikz[overlay, remember picture, #1]{#2} } 
\tikzset{ highlightGuava/.style = { draw, rectangle, rounded corners, inner sep =1.5 pt, fill = green!15, fill opacity = 0.2 } } 
\newcommand{\guavahighlight}[1]{ \guavaoverlay{ \node [fit = (left.north west) (right.south east), highlightGuava] (#1) {}; } } 
\newcommand{\guavamark}[2]{\guavaoverlay[baseline=(#1.base)] {\node (#1) {$#2$};}}


%%%%%%%%%%%matrix block%%%%%%%%%
\RequirePackage{blkarray}

%%%%color highlight
\newcommand{\DoTikzmark}[1]{%
	\tikz[remember picture] \coordinate[shift={(0,.7ex)}](#1);%
}
\newcommand{\colrow}[3][]{%
	\tikz[overlay,remember picture, line width=10pt]
	\draw[shorten >=-.1em, shorten <=-.1em, #1] (#2)--(#3);
}

%%%%%%%%方框
\newcommand{\Glight}[3]{%
	\tikz[overlay,remember picture]{
		\node[highlight=#3,fit=(#1.north west) (#2.south east)]  {};}
}
%%%%%%%%%%%%%%%%%%%%%%
% Tikz drawing settings====================
\RequirePackage[customcolors]{hf-tikz}

% command to typeset the highlighted area in green
\newcommand{\usegreen}{
	\hfsetbordercolor{green!75!black}
	\hfsetfillcolor{green!10}
}
% command to typeset the highlighted area in red
\newcommand{\usered}{
	\hfsetbordercolor{red!75!black}
	\hfsetfillcolor{red!10}
}

%row text color%%%%%%%%%%%%%%%%%%
\newcommand*{\rowstyle}[1]{% sets the style of the next row
	\gdef\@rowstyle{#1}%
	\@rowstyle\ignorespaces%
}
\newcolumntype{=}{% resets the row style
	>{\gdef\@rowstyle{}}%
}

\newcolumntype{+}{% adds the current row style to the next column
	>{\@rowstyle}%
}
\def\zapcolorreset{\let\reset@color\relax\ignorespaces}
\def\colorrows#1{\noalign{\aftergroup\zapcolorreset#1}\ignorespaces}
%%%%%%%%%%%%%%%%%%%%%%
\usetikzlibrary{matrix}

\newcommand{\guavamatrix}[2]{
	\global\expandafter\def\csname guavamatrixnamed#1\endcsname{#2}
	\left [ \begin{tikzpicture}[baseline=-0.5ex]
	\matrix[matrix of math nodes, ampersand replacement= \&] { \csname guavamatrixnamed#1\endcsname };
	\end{tikzpicture} \right ]
}

\newcommand{\guavatrans}[1]{
	\left [ \rotatebox[origin=c]{90}{\reflectbox{ \begin{tikzpicture}[baseline=-0.5ex]
			\matrix[matrix of math nodes, ampersand replacement= \&, nodes={rotate=90,xscale=-1}] { \csname guavamatrixnamed#1\endcsname };
			\end{tikzpicture} }} \right ]
}

%%%array 自訂行寬與對齊
\RequirePackage{booktabs}
\RequirePackage{array}
\RequirePackage{multirow}%表格跨行或跨列
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
%表格自訂長度及置中
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}m{#1}}
%表格自訂長度及置左
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}
%表格自訂長度及置右
\RequirePackage{color}%引入色彩，可以給圖、表格和文字等設置顏色。
\RequirePackage{colortbl}%表格中加入灰階與色彩，需要先引入array 和 color 


\setlength{\arraycolsep}{15pt}%array的列距

\renewcommand{\arraystretch}{1.5}%array的行距

\RequirePackage{stackengine}%tabular單一列高


%\newcolumntype{W}[1]{>{\centering\arraybackslash\hspace{0pt}}p{#1}}

\RequirePackage{xparse}

\makeatletter
\ExplSyntaxOn
% #1=height, #2=depth. They should be dimexpr.
\NewExpandableDocumentCommand \setarstrut { m m }
{ \mytab_set_array_strut:nn {#1} {#2} }
\NewExpandableDocumentCommand \restorearstrut { }
{ \mytab_restore_array_strut: }

\box_new:N \l__mytab_old_arstrut_box

\cs_new:Npn \mytab_set_array_strut:nn #1#2
{
	\tex_noalign:D
	{
		\group_begin:
		% Store the old strutbox
		\box_gset_eq:NN \l__mytab_old_arstrut_box \@arstrutbox
		% Change the dimension of \@arstrutbox
		\hbox_set_to_wd:Nnn \l_tmpa_box { \c_zero_dim } { }
		\box_set_ht:Nn \l_tmpa_box {#1}
		\box_set_dp:Nn \l_tmpa_box {#2}
		\hbox_gset:Nn \@arstrutbox { \box_use:N \l_tmpa_box }
		\group_end:
	}
}
\cs_new:Npn \mytab_restore_array_strut:
{
	\tex_noalign:D
	{ \box_gset_eq:NN \@arstrutbox \l__mytab_old_arstrut_box }
}
\ExplSyntaxOff
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\universityCH[1]{\newcommand{\theuniversityCH}{#1}}
\newcommand\universityEN[1]{\newcommand{\theuniversityEN}{#1}}
\newcommand\instituteCH[1]{\newcommand{\theinstituteCH}{#1}}
\newcommand\instituteEN[1]{\newcommand{\theinstituteEN}{#1}}
\newcommand\titleEN[1]{\newcommand{\thetitleEN}{#1}}
\newcommand\titleCH[1]{\newcommand{\thetitleCH}{#1}}
\newcommand\authorCH[1]{\newcommand{\theauthorCH}{#1}}
\newcommand\authorEN[1]{\newcommand{\theauthorEN}{#1}}
\newcommand\studentID[1]{\newcommand{\thestudentID}{#1}}
\newcommand\degreeCH[1]{\newcommand{\thedegreeCH}{#1}}
%\newcommand\thesisCH[1]{\newcommand{\thethesisCH}{#1}}
\newcommand\authorGrade[1]{\newcommand{\theauthorGrade}{#1}}
\newcommand\authorcontact[1]{\newcommand{\theauthorcontact}{#1}}
\newcommand\draft[1]{\newcommand{\thedraft}{#1}}
%%%%%%%%%%%%%%%%
\newcommand\advisorALN[1]{\newcommand{\theadvisorALN}{#1}}
\newcommand\advisorAFN[1]{\newcommand{\theadvisorAFN}{#1}}
\newcommand\advisorDegreeA[1]{\newcommand{\theadvisorDegreeA}{#1}}
\newcommand\adschoolA[1]{\newcommand{\theadschoolA}{#1}}
\newcommand\adTitleA[1]{\newcommand{\theadTitleA}{#1}}
\newcommand\facultyA[1]{\newcommand{\thefacultyA}{#1}}
\newcommand\nonfacultyA[1]{\newcommand{\thenonfacultyA}{#1}}
\newcommand\TeaCerA[1]{\newcommand{\theTeaCerA}{#1}}
\newcommand\advisorAEN[1]{\newcommand{\theadvisorAEN}{#1}}
\newcommand\advisorADE[1]{\newcommand{\theadvisorADE}{#1}}
%%
\newcommand\advisorBLN[1]{\newcommand{\theadvisorBLN}{#1}}
\newcommand\advisorBFN[1]{\newcommand{\theadvisorBFN}{#1}}
\newcommand\advisorDegreeB[1]{\newcommand{\theadvisorDegreeB}{#1}}
\newcommand\adschoolB[1]{\newcommand{\theadschoolB}{#1}}
\newcommand\adTitleB[1]{\newcommand{\theadTitleB}{#1}}
\newcommand\advisorBEN[1]{\newcommand{\theadvisorBEN}{#1}}
\newcommand\advisorBDE[1]{\newcommand{\theadvisorBDE}{#1}}
%%
\newcommand\advisorDBLN[1]{\newcommand{\theadvisorDBLN}{#1}}
\newcommand\advisorDBFN[1]{\newcommand{\theadvisorDBFN}{#1}}
\newcommand\adschoolDB[1]{\newcommand{\theadschoolDB}{#1}}
\newcommand\adTitleDB[1]{\newcommand{\theadTitleDB}{#1}}
\newcommand\facultyB[1]{\newcommand{\thefacultyB}{#1}}
\newcommand\nonfacultyB[1]{\newcommand{\thenonfacultyB}{#1}}
\newcommand\TeaCerB[1]{\newcommand{\theTeaCerB}{#1}}
%%
\newcommand\advisorCLN[1]{\newcommand{\theadvisorCLN}{#1}}
\newcommand\advisorCFN[1]{\newcommand{\theadvisorCFN}{#1}}
\newcommand\adschoolC[1]{\newcommand{\theadschoolC}{#1}}
\newcommand\adTitleC[1]{\newcommand{\theadTitleC}{#1}}
\newcommand\facultyC[1]{\newcommand{\thefacultyC}{#1}}
\newcommand\nonfacultyC[1]{\newcommand{\thenonfacultyC}{#1}}
\newcommand\TeaCerC[1]{\newcommand{\theTeaCerC}{#1}}
%%
\newcommand\advisorDLN[1]{\newcommand{\theadvisorDLN}{#1}}
\newcommand\advisorDFN[1]{\newcommand{\theadvisorDFN}{#1}}
\newcommand\adschoolD[1]{\newcommand{\theadschoolD}{#1}}
\newcommand\adTitleD[1]{\newcommand{\theadTitleD}{#1}}
\newcommand\facultyD[1]{\newcommand{\thefacultyD}{#1}}
\newcommand\nonfacultyD[1]{\newcommand{\thenonfacultyD}{#1}}
\newcommand\TeaCerD[1]{\newcommand{\theTeaCerD}{#1}}
%%
\newcommand\advisorELN[1]{\newcommand{\theadvisorELN}{#1}}
\newcommand\advisorEFN[1]{\newcommand{\theadvisorEFN}{#1}}
\newcommand\adschoolE[1]{\newcommand{\theadschoolE}{#1}}
\newcommand\adTitleE[1]{\newcommand{\theadTitleE}{#1}}
\newcommand\facultyE[1]{\newcommand{\thefacultyE}{#1}}
\newcommand\nonfacultyE[1]{\newcommand{\thenonfacultyE}{#1}}
\newcommand\TeaCerE[1]{\newcommand{\theTeaCerE}{#1}}
%%
\newcommand\advisorFLN[1]{\newcommand{\theadvisorFLN}{#1}}
\newcommand\advisorFFN[1]{\newcommand{\theadvisorFFN}{#1}}
\newcommand\adschoolF[1]{\newcommand{\theadschoolF}{#1}}
\newcommand\adTitleF[1]{\newcommand{\theadTitleF}{#1}}
\newcommand\facultyF[1]{\newcommand{\thefacultyF}{#1}}
\newcommand\nonfacultyF[1]{\newcommand{\thenonfacultyF}{#1}}
\newcommand\TeaCerF[1]{\newcommand{\theTeaCerF}{#1}}
%%
\newcommand\advisorGLN[1]{\newcommand{\theadvisorGLN}{#1}}
\newcommand\advisorGFN[1]{\newcommand{\theadvisorGFN}{#1}}
\newcommand\adschoolG[1]{\newcommand{\theadschoolG}{#1}}
\newcommand\adTitleG[1]{\newcommand{\theadTitleG}{#1}}
\newcommand\facultyG[1]{\newcommand{\thefacultyG}{#1}}
\newcommand\nonfacultyG[1]{\newcommand{\thenonfacultyG}{#1}}
\newcommand\TeaCerG[1]{\newcommand{\theTeaCerG}{#1}}
%%
\newcommand\advisorHLN[1]{\newcommand{\theadvisorHLN}{#1}}
\newcommand\advisorHFN[1]{\newcommand{\theadvisorHFN}{#1}}
\newcommand\adschoolH[1]{\newcommand{\theadschoolH}{#1}}
\newcommand\adTitleH[1]{\newcommand{\theadTitleH}{#1}}
\newcommand\facultyH[1]{\newcommand{\thefacultyH}{#1}}
\newcommand\nonfacultyH[1]{\newcommand{\thenonfacultyH}{#1}}
\newcommand\TeaCerH[1]{\newcommand{\theTeaCerH}{#1}}
%%
\newcommand\advisorILN[1]{\newcommand{\theadvisorILN}{#1}}
\newcommand\advisorIFN[1]{\newcommand{\theadvisorIFN}{#1}}
\newcommand\adschoolI[1]{\newcommand{\theadschoolI}{#1}}
\newcommand\adTitleI[1]{\newcommand{\theadTitleI}{#1}}
\newcommand\facultyI[1]{\newcommand{\thefacultyI}{#1}}
\newcommand\nonfacultyI[1]{\newcommand{\thenonfacultyI}{#1}}
\newcommand\TeaCerI[1]{\newcommand{\theTeaCerI}{#1}}
%%
\newcommand\advisortitleCH[1]{\newcommand{\theadvisortitleCH}{#1}}
\newcommand\datetitleCH[1]{\newcommand{\thedatetitleCH}{#1}}
\newcommand\yeartitleCH[1]{\newcommand{\theyeartitleCH}{#1}}
\newcommand\monthtitleCH[1]{\newcommand{\themonthtitleCH}{#1}}
\newcommand\writtenCH[1]{\newcommand{\thewrittenCH}{#1}}
\newcommand\abstractnameEN[1]{\newcommand{\theabstractnameEN}{#1}}
\newcommand\abstractnameCH[1]{\newcommand{\theabstractnameCH}{#1}}
\newcommand\acknowledgementsnameEN[1]{\newcommand{\theacknowledgementsnameEN}{#1}}
\newcommand\acknowledgementsnameCH[1]{\newcommand{\theacknowledgementsnameCH}{#1}}
\newcommand\schoolyearCH[1]{\newcommand{\theschoolyearCH}{#1}}
\newcommand\semester[1]{\newcommand{\thesemester}{#1}}
\newcommand\yearCH[1]{\newcommand{\theyearCH}{#1}}
\newcommand\yearEN[1]{\newcommand{\theyearEN}{#1}}
\newcommand\monthCH[1]{\newcommand{\themonthCH}{#1}}
\newcommand\monthEN[1]{\newcommand{\themonthEN}{#1}}
\newcommand\dateCH[1]{\newcommand{\thedateCH}{#1}}
\newcommand\DWeek[1]{\newcommand{\theDWeek}{#1}}
\newcommand\DTime[1]{\newcommand{\theDTime}{#1}}
\newcommand\DPlace[1]{\newcommand{\theDPlace}{#1}}
\newcommand\OStaffer[1]{\newcommand{\theOStaffer}{#1}}
\newcommand\OSemail[1]{\newcommand{\theOSemail}{#1}}
\newcommand\OSphone[1]{\newcommand{\theOSphone}{#1}}
%%%%%%%%%%%%%%%%
\newcommand{\ctoday}{\number\year / \number\month / \number\day }
\newcommand{\twtoday}{\number\year 年 \number\month 月 \number\day 日}
%%%%%%%%%%%%%%%%
\def\CJKmovesymbol#1{\raise.35em\hbox{#1}}
\def\CJKmove{\let\CJKsymbol\CJKmovesymbol
	\let\CJKpunctsymbol\CJKsymbol}


%%%%%%%%%%%%%%%%中文標題章節設定%%%%%%%%%%%%%%%%
\usepackage[compact]{titlesec}
\usepackage{titletoc}

\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{12pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}

\usepackage{etoolbox, apptools}
%圖標題設定
%\RequirePackage{caption}%與floatrow、chemscheme衝突
%\RequirePackage{capt-of}% or 其實\RequirePackage{caption}就夠用了，一樣與floatrow、chemscheme衝突

% ===
\setcounter{secnumdepth}{3}			%　設定計數到 subsubsection
\renewcommand{\thesection}{\arabic{section}} 	% 改 section 為 1, 2, 3 非 1.1, 1.2, 1.3
\renewcommand{\thesubsection}{\arabic{subsection}} % subsection 也改一改
\renewcommand{\thesubsubsection}{\arabic{subsubsection}} % subsubsection 也改一改

% === 自訂指令 ===
\AtBeginDocument{
\renewcommand\contentsname{目錄}
\renewcommand\listfigurename{圖目錄}
\renewcommand\listtablename{表目錄}
}

%%%以下附錄設定
\newcommand\guavaappname{附錄}
% ===
\AtBeginEnvironment{appendices}{\appendixtrue}
\newenvironment{appendA} 
{\setcounter{secnumdepth}{3}			%　設定計數到 subsubsection
%
%\renewcommand{\thechapter}{\guavaappname~{\thecontentslabel}}%A,...
%\setcounter{chapter}{0}
\titleformat{\chapter}{\Huge\bfseries}{\guavaappname ~{\thechapter}}{1em} {}
%目錄
\titlecontents{chapter}[0em]{}{\bf \guavaappname ~{\thecontentslabel}\quad}{}{\titlerule*{.} \contentspage}
%%%%%%%%%%%%%%%%
%
\renewcommand{\thesection}{\thechapter.\arabic{section}}
\setcounter{section}{0}
\titleformat{\section}[block]
  {\normalfont\bfseries\filright}{\IfAppendix{\large \bfseries }{\relax}\thesection\IfAppendix{ }{}}{1em}{}
%{\normalfont\bfseries\filcenter}{\IfAppendix{\appendixname~}{\relax}\thesection\IfAppendix{: }{}}{1em}{B-}
%目錄
\titlecontents{section}[1em]{}{{\thecontentslabel}\quad}{}{\titlerule*{.} \contentspage}
%%%%%%%%%%%%%%%%
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}%A.1, A.2, ..., B.1,...
%附錄裡的subsection樣式
\titleformat{\subsection}
  {\normalfont\bfseries}{\thesubsection}{1em}{}
%subsection 目錄
\titlecontents{subsection}[2em]{}{{\thecontentslabel}\quad}{}{\titlerule*{.} \contentspage}
%%%
\renewcommand{\thesubsubsection}{\thesection.\arabic{subsection}.\arabic{subsubsection}}%A.1.1, ..., B.1.1,...
\titleformat{\subsubsection}
  {\normalfont\itshape}{\thesubsubsection}{1em}{}
%
} 
%%以上附錄設定 

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% === 目錄標題 (配合 titletoc) ===
\titlecontents{chapter}
[0em]
{}
{\bf {第\xCJKnumber{\thecontentslabel}章~~}}
{}{\titlerule*{.}\contentspage}
%
\titlecontents{section}
[1em]
{}
{第\xCJKnumber{\thecontentslabel}節\quad}
{}{\titlerule*{.} \contentspage}
%
\titlecontents{subsection}
[2em]
{}
{\xCJKnumber{\thecontentslabel}、}
{}{\titlerule*{.} \contentspage}
%

% === 章節標題 (配合 titlesec) ===
\titleformat{\chapter}{\Huge\bfseries}{第\,\xCJKnumber{\thechapter}\,章}{1em} {}%中文章節，“display“可以讓標題在第＊章下方。
%
\titleformat{\section}{\Large\bfseries}{第\xCJKnumber{\thesection}節}{1em}{}
%
\titleformat{\subsection}{\large\bfseries}{\xCJKnumber{\thesubsection}、}{0.5em}{}
%
\titleformat{\subsubsection}{\bfseries}{(\xCJKnumber{\thesubsubsection})}{0.5em}{}
\titlespacing{\subsubsection}{0pt}{5pt}{-10pt}

%%%%%%%%%%%%% 命名設定%%%%%%%%%%%%%%%%%%%%
\newcommand{\NameCont}{目錄}
\newcommand{\NameLoT}{表目錄}
\newcommand{\NameToF}{圖目錄}
\newcommand{\NameRef}{參考文獻}
\AtBeginDocument{
\renewcommand{\lstlistingname}{列表} % 在文章中 listing caption 會以「列表 x」表示
}
\newcommand{\loflabel}{圖}
\newcommand{\lotlabel}{表}
\RequirePackage[tablename=表,figurename=圖,labelsep=quad,labelfont=bf]{caption}
\setcounter{figure}{0}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{section}.\arabic{figure}}
\setcounter{table}{0} 
\renewcommand{\thetable}{\arabic{chapter}.\arabic{section}.\arabic{table}}

%
\newenvironment{symbols}
{\begin{onecol}{符號說明}}
{\end{onecol}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Command to generate the certification page
\newcommand{\makecertification}{ {
		\input{certificate}
} }

% Environment to generate the english abstract page.
\newenvironment{abstractEN} % {{{
{\chapter*{\centerline{\theabstractnameEN}}%
	\addcontentsline{toc}{chapter}{\bf \theabstractnameEN}%
	\quotation}
{\endquotation\newpage} % }}}

% Environment to generate the chinese abstract page.
\newenvironment{abstractCH} % {{{
{ %
	\chapter*{\centerline{\theabstractnameCH}}%
	\addcontentsline{toc}{chapter}{\bf \theabstractnameCH}%
	\quotation}
{\endquotation\newpage} % }}}

% Environment to generate the english acknowledgements page.
\newenvironment{acknowledgementsEN} % {{{
{\chapter*{\centerline{\theacknowledgementsnameEN}}%
	\addcontentsline{toc}{chapter}{\bf \theacknowledgementsnameEN}%
	\quotation}
{\endquotation\newpage} % }}}

% Environment to generate the chinese acknowledgements page.
\newenvironment{acknowledgementsCH} % {{{
{%
	\chapter*{\centerline{\theacknowledgementsnameCH}}%
	\addcontentsline{toc}{chapter}{\bf \theacknowledgementsnameCH}%
	\quotation}
{\endquotation\newpage} % }}}

\input{nccuvars}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%斷字
\hyphenpenalty=10000
\tolerance=2000

\RequirePackage{stackengine}
%===== Language =====
\RequirePackage[english]{babel} %設定全篇使用 english 為默認

%%%%%%邊界尺寸設定
\textheight24cm
\textwidth16cm
\voffset=-1cm
\hoffset=-0.25cm

\RequirePackage{makecell}
\def\tblframewidth{1pt}

\RequirePackage{setspace}
%Set space between lines.
\parindent 2em % 段落縮排兩個字
\linespread{1.5}%行距

\RequirePackage[absolute]{textpos}
%Place boxes at arbitrary positions on the LaTeX page.
\lstdefinestyle{nonumbers}{numbers=none}
\textblockorigin{0mm}{0mm}

\setcounter{tocdepth}{2}

\pagestyle{plain}
