% For author only jml.cls -- For Journal of Machine Learning
%
% This class file is made available for use by authors who wish to
% prepare an article for publication in Journal of Machine
% Learning. The user may not exploit any part of the class file
% commercially.
%
% This class file is provided on an 'as is' basis. Authors are not
% allowed to change this file.
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{jml}[2022/01/02 Journal of Machine Learning]

\RequirePackage{ifthen}

\newboolean{PG@odd}  % set true for first page number is odd
\newboolean{REV@art} % set true for Review Article
\newboolean{DRAFT@copy} % set true for Draft copy
\newboolean{ONE@page} % set true for the first page end at abstract
\newboolean{START@even} % set true for the book first page is even
\newboolean{PAZO@load} % set true for mathpazo load
\newboolean{ON@line} % set oneside in article
\setboolean{PG@odd}{true}
\setboolean{REV@art}{false}
\setboolean{DRAFT@copy}{false}
\setboolean{ONE@page}{false}
\setboolean{START@even}{false}
\setboolean{PAZO@load}{false}
\setboolean{ON@line}{false}
\DeclareOption{odd}{\setboolean{PG@odd}{true}}
\DeclareOption{even}{\setboolean{PG@odd}{false}}
\DeclareOption{review}{\setboolean{REV@art}{true}}
\DeclareOption{draft}{\setboolean{DRAFT@copy}{true}}
\DeclareOption{onepage}{\setboolean{ONE@page}{true}}
\DeclareOption{starteven}{\setboolean{START@even}{true}}
\DeclareOption{mathpazo}{\setboolean{PAZO@load}{true}}
\DeclareOption{online}{\setboolean{ON@line}{true}}

\ProcessOptions

%%% for mathpazo package
\ifthenelse{\boolean{PAZO@load}}{
  \RequirePackage{mathpazo}
}{}
%%% for hardcopy or online version
\ifthenelse{\boolean{ON@line}}{
  \LoadClass[oneside]{article}
%   \RequirePackage[a4paper, total={7in, 10in}]{geometry}%%% for online version
%   \renewcommand{\normalsize}{\fontsize{10pt}{12pt}\selectfont}
% 
  \RequirePackage[a4paper, total={6in, 8in}]{geometry}%%% for online version
  \renewcommand{\normalsize}{\fontsize{11pt}{13pt}\selectfont}
  \date{}
}{
  \LoadClass[twoside]{article}
  % \RequirePackage[a4paper, total={6in, 9in}]{geometry}%%% for hardcopy version
  \RequirePackage[a4paper, total={6in, 8in}]{geometry}%%% for hardcopy version  
  \renewcommand{\normalsize}{\fontsize{11pt}{13pt}\selectfont}
  \date{}
}
%%% for draft
\ifthenelse{\boolean{DRAFT@copy}}{
  %\usepackage{draftcopy}
  %\draftcopyName{JML DRAFT}{144}
  \RequirePackage{lineno}
  \linenumbers
}{}
%%% for misc
\RequirePackage{graphicx}
\RequirePackage{amsfonts,amssymb,amsbsy,amsmath,amsthm}
\RequirePackage{cite}
\RequirePackage{authblk}
\RequirePackage{subfigure}
% \RequirePackage{hyperref}
\RequirePackage[tablewithin=section,figurewithin=section,justification=justified,font={small,sf}]{caption}


%%%%%%%%%%%%%%% for author info %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand\Authsep{, }
\renewcommand\Authand{ and }
\renewcommand\Authands{, and }
\renewcommand\Affilfont{\small}


%%%%%%%%%%%%%%%% journal and paper information , as well as press%%%%%%%%%%%%%%%
\newcommand\press{Global Science Press}
\newcommand\journalname{Journal of Machine Learning}
\newcommand\journalnameabbrev{J. Mach. Learn.}
\newcommand\journalwebsite{https://www.global-sci.com/jml}
\newcommand\thisnumber{x}
\newcommand\thisyear {YYYY}
\newcommand\thismonth{XX}
\newcommand\thisvolume{x}
\newcommand\originalreceiveddate{99/99/9999}
\newcommand\revisionreceiveddate{DD/MM/YYYY}
\newcommand\acceptdate{99/99/9999}
\newcommand\onlinedate{DD/MM/YYYY}
\newcommand\pagestart{xx}
\newcommand\pageend{xx}
\newcommand\articledoi{doi.org/xx.xxxx/x.xxx.xxxx.xxxx}
\newcommand\ISSNE{2790-2048}
\newcommand\ISSNP{2790-203X}
\newcommand\handler{givenname surname}

%%%%%%%%%%%%%%% for definition, lemma, theorem, proposition %%%%%%%%%%%%%%%%%%%%

\theoremstyle{plain} %%% use italic font 
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{definition}{Definition}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{corollary}{Corollary}[section]
\newtheorem{axiom}{Axiom}[section]

\theoremstyle{definition} %%% use roman font 
\newtheorem{example}{Example}[section]
\newtheorem{remark}{Remark}[section]


\numberwithin{equation}{section}

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

%%%%%%%%%%% Redefine @maketitle, to replace the one in article.cls%%%%%%%%%%%%%%
\renewcommand\maketitle{\par
  \begingroup
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
    \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
    \long\def\@makefntext##1{\parindent 1em\noindent
            \hb@xt@1.8em{%
                \hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
    \if@twocolumn
      \ifnum \col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
      \fi
    \else
      \newpage
      \global\@topnum\z@   % Prevents figures from going at top of page.
      \@maketitle
    \fi
    \thispagestyle{plain}\@thanks
  \endgroup
  \setcounter{footnote}{0}%
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@maketitle\relax
  \thispagestyle{firstpage}
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}


%%%%%%%%%%%%%%%%%%%%% for header and footer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AtBeginDocument{
  \immediate\write\@auxout{\string
  \newlabel{FirstPage}{{}{\thepage}}}
}
\AtEndDocument{
  \clearpage\addtocounter{page}{-1}
  \immediate\write\@auxout{\string
  \newlabel{LastPage}{{}{\thepage}}}
  \addtocounter{page}{1}
}
\def\thispagestart{\pageref{FirstPage}}
\def\thispageend{\pageref{LastPage}}


\ifthenelse{\boolean{ON@line}}{
  \def\ps@firstpage{\ps@empty
    \def\@oddfoot{\footnotesize \journalwebsite \hfil  \press}
    \let\@evenfoot\@oddfoot
    \def\@oddhead{
      \parbox[c]{\textwidth}{{\LARGE \journalname}\hfill\textbf{ISSN}:~\ISSNE(e),~\ISSNP(p)\\{\noindent\rule{\textwidth}{1pt}}}
    }
    \let\@evenhead\@oddhead % in case an article starts on a left-hand page
    \let\@mkboth\@empty
  }
}{
  \def\ps@firstpage{\ps@empty
    \def\@oddfoot{\footnotesize \journalwebsite \hfil  \press}
    \let\@evenfoot\@oddfoot
    \def\@oddhead{
      \parbox[c]{\textwidth}{{\LARGE \journalname}\hfill\textbf{ISSN}:~\ISSNE(e),~\ISSNP(p)\\{\noindent\rule{\textwidth}{1pt}}}
    }
    \let\@evenhead\@oddhead % in case an article starts on a left-hand page
    \let\@mkboth\@empty
  }
}

\def\leftmark{\journalnameabbrev, \thisvolume(\thisnumber):\pagestart-\pageend}
\def\rightmark{\journalnameabbrev, \thisvolume(\thisnumber):\pagestart-\pageend}
\def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
%      \def\@oddhead{\footnotesize \thepage\hfil\leftmark}%
%      \def\@evenhead{\footnotesize \rightmark\hfil\thepage}%
\ifthenelse{\boolean{PG@odd}}
      { \def\@evenhead{\footnotesize \thepage\hfil\leftmark}   % The first page number is odd
        \def\@oddhead{\footnotesize \rightmark\hfil\thepage} } %
      { \def\@oddhead{\footnotesize \thepage\hfil\leftmark}    % The first page number is even
        \def\@evenhead{\footnotesize \rightmark\hfil\thepage} }%
      \let\@mkboth\markboth
}

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

%
% Article titles
%
% Usage: \title[Short title]{Full title}
% [Short title] is optional; use where title is too long
% or contains footnotes, 50 characters maximum
%
\renewcommand*{\title}[2][]{\gdef\shorttitle{#1}\gdef\@title{#2}}
\let\shorttitle=\empty
\def\@settitle{
%  \begin{center}%
  %\baselineskip14\p@\relax
  \begin{titquote}
  \Large  \bfseries
  \ifthenelse{\boolean{REV@art}}
  {  \item[]
     {\LARGE R}{\large EVIEW }{\LARGE A}{\large RTICLE} } % For Review Article
  {}
  \item[]
  \@title
%  \end{center}%
  \end{titquote}
}


%%% for hardcopy or online version
\def\@maketitle{%
  \newpage
  \null
  %\vskip 2em%
  \par
  \let \footnote \thanks
  \noindent{\LARGE \@title \par}%
  \vskip 1em%
  \noindent\@author
  \vskip 0em%
  \noindent\@date%
  \noindent\@setabstract
  \noindent
  % \ifx\@empty\@keywordone\else \@setkeywords\fi~\vrule~ %% the last \vrule give a vertical line
  \ifx\@empty\@keywordone\else \@setkeywords\fi~
  \@setarticleinfo
  \@setarticlehistory
  \par
%%  \hskip 0.75\textwidth\@sethandler
%%  \par
  \vskip 1em}

%%% Define a brandnew abstractbox %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newbox\abstractbox
\renewenvironment{abstract}{%
  \ifx\maketitle\relax
    \ClassWarning{\@classname}{Abstract should precede
      \protect\maketitle\space in AMS documentclasses; reported}%
  \fi
  \global\setbox\abstractbox=\vtop \bgroup
    \normalfont\small
    \list{}{\labelwidth\z@
      \leftmargin0pc %\rightmargin\leftmargin
      \let\rightmargin\leftmargin
       \itemindent\z@
      \parsep\z@ \@plus\p@
      \let\fullwidthdisplay\relax
    }%
    \item[\hskip\labelsep\bfseries\abstractname.]%
}{%
  \endlist\egroup
  \ifx\@setabstract\relax \@setabstracta \fi
}
\def\@setabstract{\@setabstracta \global\let\@setabstract\relax}
\def\@setabstracta{%
  \ifvoid\abstractbox
  \else
  \skip@6\p@ \advance\skip@-\lastskip
  \advance\skip@-\baselineskip \vskip\skip@
  \box\abstractbox
  \prevdepth\z@ % because \abstractbox is a vtop
  \fi
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\keywordone#1{\def\@keywordone{#1}}
\let\@keywordone=\@empty

\def\keywordtwo#1{\def\@keywordtwo{#1}}
\let\@keywordtwo=\@empty

\def\keywordthree#1{\def\@keywordthree{#1}}
\let\@keywordthree=\@empty

\def\keywordfour#1{\def\@keywordfour{#1}}
\let\@keywordfour=\@empty

\def\keywordfive#1{\def\@keywordfive{#1}}
\let\@keywordfive=\@empty

%%% It is not allowed to have more than 5 keywords
% \def\keywordsix#1{\def\@keywordsix{#1}}
% \let\@keywordsix=\@empty

% \def\keywordseven#1{\def\@keywordseven{#1}}
% \let\@keywordseven=\@empty

% \def\keywordeight#1{\def\@keywordeight{#1}}
% \let\@keywordeight=\@empty

% \def\keywordnine#1{\def\@keywordnine{#1}}
% \let\@keywordnine=\@empty

% \def\keywordten#1{\def\@keywordten{#1}}
% \let\@keywordten=\@empty


%%%%%%%%%%%%%%%%%%%%%%%%% for 5 keywords version %%%%%%%%%%%%%%%%%%%%%%%%%
\ifthenelse{\boolean{ON@line}}{
  \def\@setkeywords{  
    \parbox[t]{0.4\textwidth}{
      {\small \bfseries Keywords:}\\{\small
        \begin{tabular}{l}
          \@keywordone\\
          \@keywordtwo\\
          \@keywordthree\\
          \@keywordfour\\
          \@keywordfive
        \end{tabular}
      }
    }
  }
}
{
  \def\@setkeywords{  
    \parbox[t]{0.4\textwidth}{
      {\small \bfseries Keywords:}\\{\small
        \begin{tabular}{l}
          \@keywordone\\
          \@keywordtwo\\
          \@keywordthree\\
          \@keywordfour\\
          \@keywordfive
        \end{tabular}
      }
    }
  }
}


%%%%%%%%%%%%%%%%%%%%%%%%% for 10 keywords version %%%%%%%%%%%%%%%%%%%%%%%%%
% \ifthenelse{\boolean{ON@line}}{
%   \def\@setkeywords{  
%     \parbox[t]{0.44\textwidth}{
%       {\small \bfseries Keywords:}\\{\small
%         \begin{tabular}{ll}
%           \@keywordone&\@keywordsix\\
%           \@keywordtwo&\@keywordseven\\
%           \@keywordthree&\@keywordeight\\
%           \@keywordfour&\@keywordnine\\
%           \@keywordfive&\@keywordten
%         \end{tabular}
%       }
%     }
%   }
% }
% {
%   \def\@setkeywords{  
%     \parbox[t]{0.5\textwidth}{
%       {\small \bfseries Keywords:}\\{\small
%         \begin{tabular}{ll}
%           \@keywordone&\@keywordsix\\
%           \@keywordtwo&\@keywordseven\\
%           \@keywordthree&\@keywordeight\\
%           \@keywordfour&\@keywordnine\\
%           \@keywordfive&\@keywordten
%         \end{tabular}
%       }
%     }
%   }
% }

%%%%%%%%%%%%%%%%%%%%%%%%% for article information %%%%%%%%%%%%%%%%%%%%%%%%%
\ifthenelse{\boolean{ON@line}}{
  \def\@setarticleinfo{
    \parbox[t]{0.35\textwidth}{
      {\small \bfseries Article Info.:}\\{\small
        \begin{tabular}{l}
          Volume: \thisvolume\\
          Number: \thisnumber\\
          Pages: \pagestart- \pageend\\
          Date: \thismonth/\thisyear\\
          \articledoi
        \end{tabular}
      }        
    }
  }
}{
  \def\@setarticleinfo{
    \parbox[t]{0.35\textwidth}{
      {\small \bfseries Article Info.:}\\{\small
        \begin{tabular}{l}        
          Volume: \thisvolume\\
          Number: \thisnumber\\
          Pages: \pagestart- \pageend\\
          Date: \thismonth/\thisyear\\
          \articledoi
        \end{tabular}
      }
    }
  }
}

%%%%%%%%%%%%%%%%%%%%%%%%% for article history %%%%%%%%%%%%%%%%%%%%%%%%%
\ifthenelse{\boolean{ON@line}}{  
  \def\@setarticlehistory{
    \parbox[t]{0.25\textwidth}{
      {\small \bfseries Article History:}\\{\small
        \begin{tabular}{l}
          Received: \originalreceiveddate\\
          %Revision: \revisionreceiveddate\\
          Accepted: \acceptdate\\
          %Online: \onlinedate
        \end{tabular}
      }
      \vskip 1em
      {\small \bfseries Communicated by:}\\{\small
        \begin{tabular}{l}
          \handler\\
        \end{tabular}
      }            
    }
  }
}{
  \def\@setarticlehistory{
    \parbox[t]{0.25\textwidth}{
      {\small \bfseries Article History:}\\{\small
        \begin{tabular}{l}
          Received: \originalreceiveddate\\
          %Revision: \revisionreceiveddate\\
          Accepted: \acceptdate\\
          %Online: \onlinedate
        \end{tabular}
      }
      \vskip 1em
      {\small \bfseries Handler:}\\{\small
        \begin{tabular}{l}
          \handler\\
        \end{tabular}
      }      
    }
  }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\pagestyle{headings}
\pagenumbering{arabic}

%%%%%%%%%%%%%%%%%
%% end of file
%%%%%%%%%%%%%%%%%
