\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{JKICS}[2023/03/23 JKICS Template]

\newcommand{\headlinecolor}{\normalcolor}
\RequirePackage{xcolor}
\definecolor{slcolor}{HTML}{882B21}

\newcommand{\authorrefmark}[1]{\footnotemark[#1]}

%\DeclareOption{onecolumn}{\OptionNotUsed}
%\DeclareOption{green}{\renewcommand{\headlinecolor}{\color{green}}}
%\DeclareOption{red}{\renewcommand{\headlinecolor}{\color{slcolor}}}
%\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
%\ProcessOptions\relax
\LoadClass[a4paper,twoside]{article}

\usepackage[a4paper,showframe = false]{geometry}
\usepackage{indentfirst}
\usepackage{fontspec}
\usepackage{fancyhdr}
\usepackage{ifthen}
\usepackage{amssymb}
\usepackage{kotex}
\usepackage[backend=biber, style=ieee]{biblatex}
\usepackage{mathptmx}
\usepackage{titlesec}
\usepackage[labelsep=period]{caption}
%\captionsetup{labelsep=period}

% custom author mark
\newcommand{\firstauthormark}{$\blacklozenge$} % first author mark \firstauthormark
\newcommand{\corresauthormark}{$\circ$} % corresponding author mark \corresauthormark
\newcommand{\authormark}[1]{\ensuremath{#1}} % author mark \authormark{SYM}

% custom superscript author mark, to be used at author part, after paper title
\newcommand{\firstauthormarksuper}{\textsuperscript{$\blacklozenge$}} % first author mark \firstauthormarksuper
\newcommand{\corresauthormarksuper}{\textsuperscript{$\circ$}} % corresponding author mark \corresauthormarksuper
\newcommand{\authormarksuper}[1]{\textsuperscript{\ensuremath{#1}}} % author mark \authormarksuper{SYM}

% custome command for footnote
% \customfootnotetext{SYM}{FOOTNOTE}
\newcommand{\customfootnotetext}[2]{{% Group to localize change to footnote
  \renewcommand{\thefootnote}{\fontsize{8.5pt}{11pt}\selectfont #1 \hspace*{\fill}}% Update footnote counter representation
  \footnotetext[0]{\fontsize{8.5pt}{11pt}\selectfont #2}}}% Print footnote tex

% custom command for footnote without mark
% \customfootnotetext{FOOTNOTE}
\newcommand{\customfootnotetextnomark}[1]{\customfootnotetext{\phantom{$*$}}{#1}}

% custom affiliation command for 
% first author: \firstauthoraffil{AFFIL}
% corresponding author: \corresauthoraffil{AFFIL}
% author: \authoraffil{SYM}{AFFIL}
\newcommand{\firstauthoraffil}[1]{\customfootnotetext{\firstauthormark}{#1}}
\newcommand{\corresauthoraffil}[1]{\customfootnotetext{\corresauthormark}{#1}}
\newcommand{\authoraffil}[2]{\customfootnotetext{#1}{#2}}


% author mark symbol
\def\@fnsymbol#1{\ensuremath{\ifcase#1\or \blacklozenge\or \dagger\or \ddagger\or
   \mathsection\or \mathparagraph\or \|\or **\or \dagger\dagger
   \or \ddagger\ddagger \or $\textreferencemark$ \else\@ctrerr\fi}}

% font settings
\setmainfont{Times New Roman}
\setromanfont{Times New Roman}
\setsansfont{Arial}
\setmonofont[Color={0019D4}]{Courier New}
%\setmainfont{Tulip.ttf}
%\newfontfamily\tulipfont[Path=./koreanfont/]{tulip.ttf}
%\newfontfamily\tulipfont{tulip.ttf}
\newfontfamily\SandollGothicLFont[Path=./koreanfont/]{SandollGothicNeo1L.otf}
\newfontfamily\SandollGothicMFont[Path=./koreanfont/]{SandollGothicNeo1M.otf}
\newfontfamily\SandollMyeongjoL[Path=./koreanfont/]{SandollMyeongjoL.otf}
\newfontfamily\NotoSerifKRSBFont[Path=./koreanfont/]{NotoSerifKRSemiBold.otf}
\newfontfamily\NotoSerifKRMFont[Path=./koreanfont/]{NotoSerifKRMedium.otf}
\newfontfamily\NotoSerifKRRFont[Path=./koreanfont/]{NotoSerifKRRegular.otf}
\newfontfamily\UniversalisRFont[Path=./koreanfont/]{UniversalisR.otf}
%\newfontfamily\TimesNewRomanFont[Path=./koreanfont/]{TimesNewRoman.ttf}



% abstract title 
\def\abstractname{\fontsize{10.5}{16.8}\SandollGothicLFont\selectfont ABSTRACT}

\setlength\parindent{0.14in}

% footnote margin setting
\renewcommand{\footnoterule}{% Kerns avoid vertical space
  \kern 2.5pt                         % This -3 is negative
  \hrule width \textwidth height 0.5pt % of the sum of this 1
  \kern 2pt}                         % and this 2



% paper margin
\geometry{
    %total = {6.53in,10.31in},
    top = 0.55in,
    bottom = 0.55in,
    left = 0.77in,
    right = 0.77in,
    %headheight = 0.39in,
    }

% custom \maketitle command
\renewcommand{\maketitle}{%
    \setmainfont{Times New Roman}
    \vspace*{13pt}
    % print title
    \begin{center}
        \fontsize{17.5}{16.8}\fontseries{m}%
        \selectfont
        \@title\\%
        \medskip
    \end{center}

    % print authors
    \begin{center}
        \fontsize{11.5}{16.8}%
        \selectfont
        \@author
        \medskip
    \end{center}  
    
    % print funding ack at first page footnote
    % 10 is code for reference mark symbol, for funding ack
    \footnotetext[10]{\funding} 
}


% redefine abstract environment
\renewenvironment{abstract}{
    \begin{center}
    \abstractname
    \end{center}
        \setlength{\leftmargin}{0pt}%
        \setlength{\rightmargin}{\leftmargin}%
    \fontsize{10pt}{1.33pc}\selectfont 
    
    } 


% numbering settings for section title, subsection title, and subsubsction title
\renewcommand\thesection{{\NotoSerifKRRFont\Roman{section}}}
\renewcommand\thesubsection{\arabic{section}.\arabic{subsection}}
\renewcommand\thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}

% section title setting
%\renewcommand{\section}{%
%    \@startsection
%    {section}{1}{0pt}{15pt plus 1ex  minus .5ex}%
%    {15pt plus 1ex}{\centering\fontsize{11.5pt}{15pt}\SandollGothicMFont\selectfont}%

%}

% sbsection title setting
%\renewcommand{\subsection}{%
%    \@startsection
%    {subsection}{2}{0pt}{12pt plus 1ex minus .5ex}%
%    {12pt plus 1ex}{\fontsize{10.5pt}{15pt}\SandollGothicMFont\selectfont}%
%}

% subsubsection title setting
%\renewcommand{\subsubsection}{%
%    \@startsection
%    {subsubsection}{3}{0pt}{1ex plus .5ex minus .5ex}%
%    {1ex plus .5ex}{\fontsize{10pt}{15pt}\SandollGothicMFont\selectfont}%
%}

\titleformat{\section}
{\centering\fontsize{11.5pt}{15pt}\SandollGothicMFont\selectfont}{\thesection \ . }{1ex}{ }[]
%\titleformat*{\section}{\centering\fontsize{11.5pt}{15pt}\SandollGothicMFont\selectfont}
\titleformat*{\subsection}{\fontsize{10.5pt}{15pt}\SandollGothicMFont\selectfont}
\titleformat*{\subsubsection}{\fontsize{10pt}{15pt}\SandollGothicMFont\selectfont}

% text font setting
\renewcommand{\normalsize}{\fontsize{10.5pt}{15pt}\selectfont}

% keyword setting
\newcommand{\keywords}[1]
{
    \fontsize{9.5pt}{15pt}\selectfont 
    {\SandollGothicMFont Key Words: }{\SandollGothicLFont #1}%
    
    \normalsize % force main body font to be Times New Roman
     
}

\renewcommand{\figurename}{{\fontsize{9.5pt}{10pt}\SandollGothicLFont\selectfont Fig.}}
\renewcommand{\thefigure}{{\fontsize{9.5pt}{10pt}\SandollGothicLFont\selectfont\arabic{figure}}}
\renewcommand{\tablename}{{\fontsize{9.5pt}{10pt}\SandollGothicLFont\selectfont Table}}
\renewcommand{\thetable}{{\fontsize{9.5pt}{10pt}\SandollGothicLFont\selectfont\arabic{table}}}

% set header and footer
    \pagestyle{fancy}
    % header at odd page number
    \fancyhead[LO]{\ifthenelse{\value{page}=1}{\fontsize{9.5}{0.9pc}\SandollMyeongjoL\selectfont \phantom{x}\\논문~ \textrm{\pubyear-\pubvol-\pubiss-\artidx}\\ }{}} % left--odd page header
    \fancyhead[CO]{} % center--odd page header
    \fancyhead[RO]{\ifthenelse{\value{page}=1}{\fontsize{9}{0.9pc}\selectfont \phantom{x}\\The~Journal~of Korean~Institute~of~Communications~and~Information~Sciences~’\pubyear-\pubmonth~Vol~\pubvol~No.~\pubiss\\https://doi.org/xx.xxxx/kics.xxxx.xx.x.x}{\fontsize{9}{0.9pc}\SandollMyeongjoL\selectfont \phantom{x}\\논문 \textrm{/ \@title}}} % right--odd page header
    % header at even page number    
    \fancyhead[LE]{\fontsize{9}{0.9pc}\selectfont \phantom{x}\\The~Journal~of Korean~Institute~of~Communications~and~Information~Sciences~’\pubyear-\pubmonth~Vol~\pubvol~No.~\pubiss} % left--even page header
    \fancyhead[CE]{} % center--even page header
    \fancyhead[RE]{} % right--even page header
    % footer at odd page number
    \fancyfoot[LO]{} % left--odd page footer
    \fancyfoot[CO]{} % center--odd page footer
    \fancyfoot[RO]{\fontsize{10.5}{8pt}\UniversalisRFont\selectfont\thepage} % right--odd page footer
    % footer at even page number
    \fancyfoot[LE]{\fontsize{10.5}{8pt}\UniversalisRFont\selectfont\thepage} % left--even page footer
    \fancyfoot[CE]{} % center--even page footer
    \fancyfoot[RE]{} % right--even page footer