\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{gemplate}[2024/07/13]

\RequirePackage{import}
\RequirePackage{graphicx}
\RequirePackage{xcolor}
\RequirePackage[hyphens,nobiblatex]{xurl} % break url in the middle to fit in the space

\RequirePackage{subfiles}


% tabularray
\RequirePackage{tabularray}
\UseTblrLibrary{booktabs}
% set tblr caption same as table enviro
\ExplSyntaxOn
\prg_generate_conditional_variant:Nnn \tl_if_empty:n { e } { TF }
\let \IfTokenListEmpty = \tl_if_empty:eTF
\ExplSyntaxOff
% modifying the captions of tabularray
\DefTblrTemplate{firsthead}{default}{%
  \addtocounter{table}{-1}%
  \IfTokenListEmpty{\InsertTblrText{entry}}{%
    \captionof{table}{\InsertTblrText{caption}}%
  }{%
    \captionof{table}[\InsertTblrText{entry}]{\InsertTblrText{caption}}%
  }%
}

\SetTblrTemplate{caption-lot}{empty}

% remove captions at continuing pages in long table 
\DefTblrTemplate{capcont}{default}{} 
 % remove row gaps to make it compact
\SetTblrInner{rowsep=0pt}




\RequirePackage{bookmark}
\RequirePackage{booktabs}
\RequirePackage{csquotes}
\RequirePackage{titling} % multiple \maketitle within a document
\RequirePackage{longtable}
\RequirePackage[normalem]{ulem} % better underline
\RequirePackage{tabu} % long table formatting
\RequirePackage{rotating} % table rotating
\RequirePackage{makecell} % text line breaks in the tabular env
\RequirePackage{setspace} % line spacing
\RequirePackage{multirow}
\RequirePackage[margin=2.5cm,nohead]{geometry}
%\RequirePackage{minted} % source code highlighting
\RequirePackage[toc, title]{appendix}
\RequirePackage{nicefrac}       % compact symbols for 1/2, etc.
\RequirePackage{microtype}      % microtypography
\RequirePackage[margin=15pt,font=small,labelfont={bf,sf}]{caption}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{enumitem}
% \RequirePackage[symbol*]{footmisc}


\RequirePackage[american]{babel}
\RequirePackage[backend=biber,style=apa,uniquename=false,uniquelist=false,citetracker=true,maxcitenames=2,doi=false,annotation=false,natbib=true]{biblatex}
% first cite use full author list, all others use `et al'
\AtEveryCitekey{\ifciteseen{}{\defcounter{maxnames}{99}}}
% remove the letter (2021a, 2021b) following same first author surname
\AtEveryCitekey{\clearfield{extradate}}
\AtEveryBibitem{\clearfield{extradate}}



% fonts
\usepackage[T1]{fontenc}

\usepackage{crimson}

\usepackage{eulervm} % maths font







% document layout
\linespread{1.5}
\usepackage{indentfirst} % indent first sentence of a new section

% but do not indent abstract
\usepackage{etoolbox}
\ifundef{\abstract}{}{\patchcmd{\abstract}%
    {\quotation}{\quotation\noindent\ignorespaces}{}{}}

% add chapter functionality in article class
\newcounter{Chapcounter}
\newcommand\showmycounter{\addtocounter{Chapcounter}{1}\themycounter}
\newcommand{\chapter}[1] 
{ {\centering          
  \addtocounter{Chapcounter}{1} \Large \textbf{~#1}}   
  \addcontentsline{toc}{section}{~#1}    
} 

% table numbering in appendices (e.g., Table A.1)
% not working properly
%\setcounter{table}{0}
%\renewcommand\thetable{\Alph{section}.\arabic{table}}

% align table cells with large amount of text (using \makecell{})
\renewcommand{\cellalign}{tl}

% increase space between rows in table
\renewcommand{\arraystretch}{1.5}


% definitions
\definecolor{monashblue}{HTML}{006DAE}
\definecolor{darkred}{rgb}{100,0,0}

\RequirePackage{hyperref}
\hypersetup{
    colorlinks=true,
    urlcolor=monashblue,
    linkcolor=monashblue,
    citecolor=monashblue}


% define the use of \thanks{} symbol
\def\@fnsymbol#1{\ensuremath{\ifcase#1\or \mathsection\or \dagger\or
            \mathparagraph\or \ddagger\or \|\or **\or \dagger\dagger
        \or \ddagger\ddagger \else\@ctrerr\fi}}



% new commands
\newcommand{\mc}{\multicolumn} % multicolumn in tables
\newcommand{\red}{\textcolor{red}} % command for red text
\newcommand*\diff{\mathop{}\!\mathrm{d}} % `d` in differentials 




