\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tmr-tex}
  [2025/11/27 v1.0 Submission to TMR journals]
\LoadClass[10pt,a4paper,twoside]{article}

\RequirePackage{xkeyval}
\RequirePackage{geometry}
\RequirePackage{changepage}
\RequirePackage{stringstrings}
\RequirePackage[absolute]{textpos}
\RequirePackage[table,svgnames]{xcolor}
\RequirePackage{tabularray}
\usepackage[none]{hyphenat}%强制不能出现断词
\sloppy%启用宽松间距排版
\RequirePackage{
	caption,
	floatrow,
	graphicx,
	url,
	mdframed,
	mfirstuc,
	%   footmisc,
	alphalph
}
\urlstyle{same}
\ifcase\@ptsize % 根据基础字号（\@ptsize=0→10pt, 1→11pt, 2→12pt）
% 10pt 基准
\renewcommand{\tiny}{\fontsize{5}{6}\selectfont}
\renewcommand{\scriptsize}{\fontsize{7}{8}\selectfont}
\renewcommand{\footnotesize}{\fontsize{8}{9.5}\selectfont}
\renewcommand{\small}{\fontsize{9}{10.5}\selectfont}
%\renewcommand{\normalsize}{\fontsize{10}{12}\selectfont}
\renewcommand{\normalsize}{\fontsize{8}{9.5}\selectfont}
\renewcommand{\large}{\fontsize{12}{14}\selectfont}
\renewcommand{\Large}{\fontsize{14}{16}\selectfont}
\renewcommand{\LARGE}{\fontsize{17}{20}\selectfont}
\renewcommand{\huge}{\fontsize{20}{23}\selectfont}
\renewcommand{\Huge}{\fontsize{25}{28}\selectfont}



\definecolor{contentblue}{RGB}{0, 130, 170}
\newcommand*\contentBlue[1]{%
	\textcolor{contentblue}{#1}%
}
\or
%% 11pt 基准（按需添加）
%\renewcommand{\normalsize}{\fontsize{11}{13}\selectfont}
%\or
%% 12pt 基准（按需添加）
%\renewcommand{\normalsize}{\fontsize{12}{14}\selectfont}
\fi

%%自定义方法
\newcommand*\cup@warning{\ClassWarning{tmr-tex}}

\newcommand*\cup@ifundefined[1]{%
	\begingroup\expandafter\expandafter\expandafter\endgroup
	\expandafter\ifx\csname #1\endcsname\relax
	\expandafter\@firstoftwo
	\else
	\expandafter\@secondoftwo
	\fi
}

\newcommand*\cup@keyval@bool[2]{%
	\cup@ifundefined{cup@#1#2}{%
		\cup@warning{Unknown option `#2' for key #1}%
	}{%
		\@nameuse{cup@#1#2}%
	}%
}

%%定义变量
\newif\ifcup@abbreviations
\newif\ifcup@jel
\newif\ifcup@msc
\newif\ifcup@dates
\newif\ifcup@articletitle
\newif\ifcup@chaptertitle
\newif\ifcup@email
\newif\ifcup@hyperref
\newif\ifcup@super
\newif\ifcup@simfonts
\define@key{cup}{abbreviations}[true]{%
	\cup@keyval@bool{abbreviations}{#1}%
}
\define@key{cup}{jel}[true]{%
	\cup@keyval@bool{jel}{#1}%
}
\define@key{cup}{msc}[true]{%
	\cup@keyval@bool{msc}{#1}%
}
\define@key{cup}{suppmat}[true]{%
	\cup@keyval@bool{suppmat}{#1}%
}
\define@key{cup}{suppdata}[true]{%
	\cup@keyval@bool{suppdata}{#1}%
}
\define@key{cup}{orcid}[true]{%
	\cup@keyval@bool{orcid}{#1}%
}
\define@key{cup}{ack}[true]{%
	\cup@keyval@bool{ack}{#1}%
}
\define@key{cup}{contrib}[true]{%
	\cup@keyval@bool{contrib}{#1}%
}
\define@key{cup}{financial}[true]{%
	\cup@keyval@bool{financial}{#1}%
}
\define@key{cup}{conflicts}[true]{%
	\cup@keyval@bool{conflicts}{#1}%
}
\define@key{cup}{ethics}[true]{%
	\cup@keyval@bool{ethics}{#1}%
}
\define@key{cup}{dates}[true]{%
	\cup@keyval@bool{dates}{#1}%
}
\define@key{cup}{articletitle}[true]{%
	\cup@keyval@bool{articletitle}{#1}%
}
\define@key{cup}{chaptertitle}[true]{%
	\cup@keyval@bool{chaptertitle}{#1}%
}
\define@key{cup}{email}[true]{%
	\cup@keyval@bool{email}{#1}%
}
\define@key{cup}{hyperref}[true]{%
	\cup@keyval@bool{hyperref}{#1}%
}
\define@key{cup}{super}[true]{%
	\cup@keyval@bool{super}{#1}%
}
\define@key{cup}{usetitle}[true]{%
	\cup@keyval@bool{articletitle}{#1}%
}
\define@key{cup}{simfonts}[true]{%
	\cup@keyval@bool{simfonts}{#1}%
}
\newcommand*\cup@journal{Traditional Medicine Research}
\newcommand*\cup@doi{\cup@warning{No DOI provided}}
\newcommand*\cup@layout{largetwo}
\newcommand*\cup@manuscript{article}
\newcommand*\cup@year{\cup@warning{No year provided}}
\newcommand*\cup@vol{\cup@warning{No volume provided}}
\newcommand*\cup@maxauthors{15}
\newcommand*\cup@articletype{ARTICLE}
\newcommand*\cup@journalweb{\cup@warning{No journal website}}
\newcommand*\cup@authorcon{\cup@warning{No Author contributions}}
\newcommand*\cup@competing{\cup@warning{No Competing interests}}
\newcommand*\cup@Acknowledgments{\cup@warning{No Acknowledgments}}
\newcommand*\cup@Peerreviewinformation{\cup@warning{no Peer review information}}
\newcommand*\cup@Abbreviations{\cup@warning{no Abbreviations}}
\newcommand*\cup@Citation{\cup@warning{no Citation}}
\newcommand*\cup@keywords{\cup@warning{no keywords}}
\newcommand*\cup@Executiveeditor{\cup@warning{no Executive editor}}
\newcommand*\cup@EditorialAdvisoryBoard{\cup@warning{no Editorial Advisory Board}}
\newcommand*\cup@Correspondence{\cup@warning{no Correspondence}}
%\newcommand*\cup@no{\cup@warning{no journal number}}
\newcommand*\cup@no{}
\newcommand*\cup@page{\cup@warning{no article page}}
\newcommand*\cup@journalname{\cup@warning{no jorunal name}}
\newcommand*\cup@copyright{© \cup@year By Author(s). Published by TMR Publishing Group Limited. This is an open access article under the CC-BY license. (https://creativecommons.org/licenses/by/4.0/)}
\define@key{cup}{journal}{%
	\def\cup@journal{#1}%
}
\define@key{cup}{layout}{%
	\def\cup@layout{#1}%
}
\define@key{cup}{journalname}{%
	\def\cup@journalname{#1}%
}
\define@key{cup}{no}{%
	\def\cup@no{#1}%
}
\define@key{cup}{page}{%
	\def\cup@page{#1}%
}
\define@key{cup}{manuscript}{%
	\AtBeginDocument{\def\cup@manuscript{#1}}%
}
\define@key{cup}{EditorialAdvisoryBoard}{%
	\def\cup@EditorialAdvisoryBoard{#1}%
}
\define@key{cup}{year}{%
	\def\cup@year{#1}%
}
\define@key{cup}{volume}{%
	\def\cup@vol{#1}%
}
\define@key{cup}{articletype}{%
	\def\cup@articletype{#1}%
}
\define@key{cup}{journalweb}{
	\def\cup@journalweb{#1}
}
\define@key{cup}{authorcon}{
	\def\cup@authorcon{#1}
}
\define@key{cup}{competing}{
	\def\cup@competing{#1}
}
\define@key{cup}{Acknowledgments}{
	\def\cup@Acknowledgments{#1}
}
\define@key{cup}{Peerreviewinformation}{
	\def\cup@Peerreviewinformation{#1}
}
\define@key{cup}{Abbreviations}{
	\def\cup@Abbreviations{#1}
}
\define@key{cup}{Citation}{
	\def\cup@Citation{#1}
}
\define@key{cup}{Executiveeditor}{
	\def\cup@Executiveeditor{#1}
}
\define@key{cup}{copyright}{
	\def\cup@copyright{#1}
}
\define@key{cup}{keywords}{
	\def\cup@keywords{#1}
}
\define@key{cup}{Correspondence}{
	\def\cup@Correspondence{#1}
}

\ProcessOptionsX*<cup>
\let\@unusedoptionlist\@empty
\newcommand*\cup@manuscript@communication{communication}
\newcommand*\cup@manuscript@letter{letter}
\newcommand*\cup@manuscript@note{note}
\newcommand*\cup@manuscript@review{review}
\newcommand*\cup@manuscript@suppinfo{suppinfo}
\setkeys{cup}{
	articletitle,
	super,
	% dates,
	% copyright,
	abbreviations,
	jel,
	msc,
	simfonts
}


%定义变量并暂存
\newcommand*\doi[1]{\gdef\cup@doi{#1}}
\@onlypreamble\doi
\newcommand*\received[1] {\gdef\cup@recvd{#1}}
\newcommand*\revised[1]  {\gdef\cup@revd{#1}}
\newcommand*\accepted[1] {\gdef\cup@accptd{#1}}
\newcommand*\Availableonline[1]{\gdef\cup@Availableonline{#1}}
\newcommand*\published[1]{\gdef\cup@publd{#1}}
\newcommand*\articletype[1]{\gdef\cup@articletype{#1}}
\newcommand*\journalweb[1]{\gdef\cup@journalweb{#1}}
\newcommand*\authorcontributions[1]{\gdef\cup@authorcon{#1}}
\newcommand*\competinginterests[1]{\gdef\cup@competing{#1}}
\newcommand*\Acknowledgments[1]{\gdef\cup@Acknowledgments{#1}}
\newcommand*\Peerreviewinformation[1]{\gdef\cup@Peerreviewinformation{#1}}
\newcommand*\Abbreviations[1]{\gdef\cup@Abbreviations{#1}}
\newcommand*\Citation[1]{\gdef\cup@Citation{#1}}
\newcommand*\Executiveeditor[1]{\gdef\cup@Executiveeditor{#1}}
\newcommand*\EditorialAdvisoryBoard[1]{\gdef\cup@EditorialAdvisoryBoard{#1}}
\newcommand*\tmrabstract[1]{\gdef\cup@tmrabstract{#1}}
\newcommand*\keywords[1]{\gdef\cup@keywords{#1}}
\newcommand*\KeywordImage[1]{\gdef\cup@KeywordImage{#1}}
\newcommand*\Correspondence[1]{\gdef\cup@Correspondence{#1}}
% 设置字体sourcesanspro，这是一套全局字体样式的组合

\RequirePackage{fontspec}
\newcommand{\simfonts}{%
%	\newfontface\bodyfont{Charis SIL}[Contextuals={WordInitial,WordFinal}]
	\newfontfamily\bodyfont{Charis SIL}[
		BoldFont={Charis SIL Bold},    % 显式指定加粗字体（Windows 系统默认名称）
		ItalicFont={Charis SIL Italic},% 可选：指定斜体字体
		BoldItalicFont={Charis SIL Bold Italic} % 可选：指定加粗斜体字体
	]
	\newfontfamily\showfont{Calibri}[
		BoldFont={Calibri Bold},    % 显式指定加粗字体（Windows 系统默认名称）
		ItalicFont={Calibri Italic},% 可选：指定斜体字体
		BoldItalicFont={Calibri Bold Italic} % 可选：指定加粗斜体字体
	]
	\RequirePackage{sansmath}
	\RequirePackage[italic,eulergreek]{mathastext}
	\RequirePackage{unicode-math}
	\setmathfont{Latin Modern Math}
}

\newlength\cup@space@pre@title
\setlength\cup@space@pre@title{1em}
\newlength\cup@space@post@title
\setlength\cup@space@post@title{1em}
\newlength\cup@space@post@author
\setlength\cup@space@post@author{0.5em}
\newlength\cup@space@post@address
\setlength\cup@space@post@address{0pt}
\newlength\cup@space@post@email
\setlength\cup@space@post@email{1.5em}
\newlength\cup@space@post@date
\setlength\cup@space@post@date{0.5em}
\newlength\cup@space@inter@extra
\setlength\cup@space@inter@extra{0.5em}
\newlength\cup@space@left@content
\setlength\cup@space@left@content{0.6em}
\newlength\cup@space@left@title
\setlength\cup@space@left@title{0.1em}
\newlength\cup@maketitle@width
\setlength\cup@maketitle@width{\textwidth}
\newcommand*\affilsize{\footnotesize}
\newcommand*\authorsize{\normalsize}
\newcommand*\emailsize{\footnotesize}
\newcommand*\datesize{\footnotesize}
\newcommand*\firstheadsize{\scriptsize}
\newcommand*\affilfont{\bodyfont}
\newcommand*\authorfont{\bodyfont\bfseries}
\newcommand*\emailfont{\footnotesize}
\newcommand*\emailsymbol{*}
%\newcommand*\emailme{#}
\newcommand*\firstsymbol{\#}
\newcommand*\titlesize{\Large}
\newcommand*\titlefont{\sffamily\bfseries\color{structure@color}}
\newcommand*\datefont{\footnotesize}
\newcommand*\extrasfont{\footnotesize}
\newcommand*\abstractfont{\small}
\newcommand*\journalnamefont{\itshape}
\newcommand*\volumefont{\bfseries}
\newcommand*\cup@etal{\emph{et al.}}



%%设置首页内容
\usepackage{ragged2e}
\RequirePackage{lastpage}
\def\@maketitle{%
	\setlength\parindent{\z@}
	\ifnum\cup@author@cnt<\z@\relax
	\cup@warning{No authors defined: At least one author is required}%
	\fi
	\newpage
	\vspace*{\dimexpr-\headsep-\headheight + 6pt\relax}
	\includegraphics[width=18mm]{tmr-logo.pdf}% 你的Logo路径
	\hfill
	\parbox[b]{150mm}{%
		\raggedleft
		{\showfont\large\textbf{\color[HTML]{002060} \cup@articletype}}\par
		\vspace{0.8pt}
		{\bodyfont\footnotesize{\itshape\textbf{\cup@journal@name}}\ \cup@year;\cup@vol\ifx\cup@no\empty\else(\cup@no)\fi:\cup@page.\ https://doi.org/\cup@doi}\par
	}\par
	\vspace*{1.5em}
	{%输出的标题部分
		\titlefont
		\titlesize
		\let\@fnsymbol\cup@author@fnsymbol
		\let\footnote@org\footnote
		\let\footnote\cup@title@footnote
		\cup@maketitle@suppinfo \@title
		\cup@title@footnote@check
		\global\cup@footnote@cnt\c@footnote
		\@maketitle@title@hook
		\par
	}
	\vspace*{1.5em}%
	{%作者信息部分
		\authorsize
		\authorfont
		\frenchspacing
		\cup@author@list
		\par
	}%
	\vspace*{1.5em}%
	{%作者机构信息显示
		\affilsize
		\affilfont
		\cup@address@list
		\par
	}%
	\vspace*{1.5em}%
	{%
		\affilsize
		\affilfont
		\cup@author@firstOverTwo
		\par
	}%
	{%
		\affilsize
		\affilfont
		\textsuperscript{\color[HTML]{057cca}*}{\textbf{Correspondence to: }}\cup@Correspondence\par
	}%
	\vspace*{1.5em}
	{%
		\footnotesize
		\bodyfont
		\raggedright
		\begin{minipage}[t]{0.38\textwidth}
			\showfont
			%Author contributions
			{\itshape\textbf{Author contributions}}\par
			\cup@authorcon\par
			%Competing interests
			{\itshape\textbf{Competing interests}}\par
			\cup@competing\par
			%Acknowledgments
			{\itshape\textbf{Acknowledgments}}\par
			\cup@Acknowledgments\par
			%Abbreviations
			{\itshape\textbf{Abbreviations}}\par
			\cup@Abbreviations\par
			%Citation
			{\itshape\textbf{Citation}}\par
			\contentBlue{\cup@Citation}\par
			\vspace{1em}
			%Peer review information
			{\itshape\textbf{Peer review information}}\par
			\cup@Peerreviewinformation\par
			%Executive editor-----copyright
			{\textbf{Editorial Advisory Board:}}\ \cup@EditorialAdvisoryBoard \par
			{\textbf{Executive editor:}}\ \cup@Executiveeditor.\par
			{\textbf{Received:}}\ \cup@recvd ; {\textbf{Revised:}}\ \cup@revd ; {\textbf{Accepted:}}\ \cup@accptd ; {\textbf{Available online:}}\ \cup@Availableonline \par
			\cup@copyright
			
			
		\end{minipage}
		\hfill
		\begin{minipage}[t]{0.6\textwidth}
			{\fontsize{12pt}{14.4pt}\itshape\textbf{Abstract}}\par
			\vspace{\cup@space@left@title}
			\cup@tmrabstract\par
			\vspace{1em}
			{\textbf{Keywords:}}\ \cup@keywords
			
			
			\ifx\cup@KeywordImage\empty  
			\else
			\vspace{1em}
			% 插入图片：宽度适配 minipage（0.6\textwidth），高度自动按比例缩放
			\includegraphics[
			width=\linewidth,  % 图片宽度=minipage宽度（避免超出）
%			height=auto,       % 高度自动适配，保持比例
			keepaspectratio    % 强制保持宽高比（防止拉伸变形）
			]{\cup@KeywordImage}
			\fi
			
		\end{minipage}
	}%
	\vfill
	{%
		\sffamily
		{\footnotesize\fontspec{Charis SIL}\color[HTML]{002060} {Submit a manuscript:\ \cup@journalweb} }
		\hfill
		\thepage
	}%
}

\newcommand*\@maketitle@title@hook{}
\newcommand*\cup@maketitle@suppinfo{%
	\ifx\cup@manuscript\cup@manuscript@suppinfo
	Supporting Information:\\
	\fi
}
\newcommand*\cup@title@footnote[1]{%
	\footnotemark
	\g@addto@macro\@thanks{\footnotetext{#1}}%
}
\newcommand\cup@title@footnote@check{%
	\ifx\@thanks\@empty
	\else
	\begingroup
	\toks@=\expandafter{\@thanks}%
	\xdef\@thanks{%
		\begingroup
		\let\noexpand\@fnsymbol\noexpand\cup@author@fnsymbol
		\the\toks@
		\endgroup
	}%
	\endgroup
	\fi
}
%\newcommand*\cup@contact@details{%
%	{ \emailsymbol{}Corresponding author. Email: \cup@email@list}%
%	\cup@number@list
%}
%\let\@thanks\@empty 
%\renewcommand*{\title}[2][]{%
%	\gdef\cup@title@short{#1}%
%	\gdef\@title{#2}%
%	\ifx\cup@title@short\@empty
%	\global\let\cup@title@short\@title
%	\fi
%}
%\@onlypreamble\title



%%作者相关
%定义作者相关
\newcount\cup@author@cnt%作者数量
\newcount\cup@affil@cnt%作者机构数量
\newcount\cup@affil@alt@cnt
\newcount\cup@footnote@cnt%偏移量，很奇妙的东西貌似这里没有实际生效
\newcount\cup@affil@marker@cnt%
\newcount\cup@first@cnt%第一作者的数量
\def\author#1{%定义方法
	\global\advance\cup@author@cnt\@ne\relax%作者数自加1
	\expandafter\gdef\csname @author@\@roman\cup@author@cnt\endcsname{#1}
	\begingroup
		\advance\cup@affil@cnt\@ne
		\expandafter\xdef\csname @author@affil@\@roman\cup@author@cnt\endcsname{\the\cup@affil@cnt}%
	\endgroup
}
\@onlypreamble\author%只在导言区生效，这段结束后   @author@1  是作者的名字    ；  @author@affil@1 是第一个机构的编号比如1


\newcommand*\affiliation[2][\relax]{%两个参数
	\ifnum\cup@author@cnt>\z@\relax%如果作者数小于0那么就报错
		\cup@affil@ifdup{#2}{%检查机构是否已存在
			\cup@affil@swap{#2}%
		}{%如果不存在执行这些
			\global\advance\cup@affil@cnt\@ne\relax
			\expandafter\gdef\csname @address@\@roman\cup@affil@cnt\endcsname%address@1存进去实际的作者单位
			{#2}%
			\ifx\relax#1\relax
				\expandafter\gdef\csname @affil@\@roman\cup@affil@cnt\endcsname{#2}%如果第一个参数为空，就把机构全称存到@affil@1 中
			\else
				\expandafter\gdef\csname @affil@\@roman\cup@affil@cnt\endcsname{#1}%如果第一个参数不为空，就把第一个参数即简称存到 @affil@1中
			\fi
		}%
	\else
		\cup@warning{Affiliation with no author}%
	\fi
}
\@onlypreamble\affiliation


\newcommand*\cup@affil@ifdup[1]{%判断某个作者单位，是否已存在address@数组中 如果存在执行第一个{}如果没有执行第二个{}
	\begingroup
		\def\@tempa{#1}%
		\@tempswafalse%设置tempswa的值是false
		\@tempcnta\z@\relax%设置tempcnta的值是0
		\cup@affil@ifdup@aux
		\if@tempswa
			\aftergroup\@firstoftwo
		\else
			\aftergroup\@secondoftwo
		\fi
	\endgroup
}


\newcommand*\cup@affil@ifdup@aux{%判断是否存在的核心方法
	\advance\@tempcnta\@ne\relax
	\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter\@tempb\expandafter\expandafter\expandafter{\csname @address@\@roman\@tempcnta\endcsname}%
	\ifx\@tempa\@tempb
		\expandafter\@tempswatrue
	\else
		\ifnum\@tempcnta<\cup@affil@cnt\relax%如果目前判断的这个aff还不是最后一个，那就需要继续遍历下一个
			\expandafter\expandafter\expandafter\cup@affil@ifdup@aux
		\fi
	\fi
}


\newcommand*\cup@affil@swap[1]{%如果已经存在了，那执行这个
	\begingroup
		\def\@tempa{#1}%
		\@tempcnta\z@\relax
		\@tempcntb\z@\relax
		\cup@affil@ifdup@aux
		\advance\cup@affil@cnt\@ne\relax
		\cup@affil@swap@aux
	\endgroup
}


\newcommand*\cup@affil@swap@aux{%让用户的单位指向，指向这个单位
	\advance\@tempcntb\@ne\relax
	\expandafter\ifnum\csname @author@affil@\@roman\@tempcntb\endcsname
	= \cup@affil@cnt\relax
	\expandafter\xdef\csname @author@affil@\@roman\@tempcntb\endcsname{%
		\the\@tempcnta
	}%
	\fi
	\ifnum\@tempcntb<\cup@author@cnt\relax
	\expandafter\cup@affil@swap@aux
	\fi
}

\newcommand*\alsoaffiliation[2][\relax]{%第二个单位
	\ifnum\cup@author@cnt>\z@\relax%cup@author@cnt这个是当前的作者的数字号
	\cup@affil@ifdup{#2}{%是否存在这个单位了
		\cup@alsoaffil@find{#2}%如果存在的话
	}{%
		\global\advance\cup@affil@cnt\@ne\relax
		\@tempcnta\cup@affil@cnt\relax
		\expandafter\gdef\csname @address@\@roman\cup@affil@cnt\endcsname
		{#2}%
		\ifx\relax#1\relax
		\expandafter\gdef\csname @affil@\@roman\cup@affil@cnt\endcsname
		{#2}%
		\else
		\expandafter\gdef\csname @affil@\@roman\cup@affil@cnt\endcsname
		{#1}%
		\fi
	}%
	\@ifundefined{@author@alsoaffil@\@roman\cup@author@cnt}{%
		\expandafter\xdef\csname @author@alsoaffil@\@roman\cup@author@cnt
		\endcsname{\the\@tempcnta}%
	}{%
		\expandafter\xdef\csname @author@alsoaffil@\@roman\cup@author@cnt
		\endcsname{%
			\csname @author@alsoaffil@\@roman\cup@author@cnt\endcsname
			,\the\@tempcnta
		}%
	}%
	\else
	\cup@warning{Affiliation with no author}%
	\fi
}
%%定义第一作者
\newcommand*\firstauthor[1][\relax]{%
	\global\advance\cup@first@cnt\@ne\relax
	\ifnum\cup@author@cnt>\z@\relax
	\expandafter\gdef\csname @firstauthor@\@roman\cup@author@cnt\endcsname
	{#1}%
	\else
	\cup@warning{first author with no author}%
	\fi
}
\@onlypreamble\firstauthor

\newcommand*\orcid[1]{%
	\ifnum\cup@author@cnt>\z@\relax
		\expandafter\gdef\csname @orcid@\@roman\cup@author@cnt\endcsname
		{#1}%
	\else
		\cup@warning{orcid with no author}%
	\fi%
}%
\@onlypreamble\orcid

\newcommand*\cup@alsoaffil@find[1]{%
	\begingroup
	\def\@tempa{#1}%定义@tempa是单位具体内容
	\@tempcnta\z@\relax%定义a是0
	\@tempcntb\z@\relax%定义b是0
	\cup@affil@ifdup@aux
	\expandafter\endgroup
	\expandafter\@tempcnta\the\@tempcnta\relax
}
\newcommand*\altaffiliation[1]{%
	\ifnum\cup@author@cnt>\z@\relax
	\begingroup
	\cup@altaffil@ifdup{#1}{%
		\expandafter\xdef\csname @author@altaffil@\\cup@author@cnt
		\endcsname{\the\@tempcnta}%
	}{%
		\global\advance\cup@affil@alt@cnt\@ne\relax
		\expandafter\gdef\csname @altaffil@\\cup@affil@alt@cnt
		\endcsname{#1}%
		\expandafter\xdef\csname @author@altaffil@\@roman\cup@author@cnt
		\endcsname{\the\cup@affil@alt@cnt}%
	}%
	\endgroup
	\else
	\cup@warning{Affiliation with no author}%
	\fi
}
\@onlypreamble\altaffiliation
\newcommand*\cup@altaffil@ifdup[1]{%
	\def\@tempa{#1}%
	\@tempswafalse
	\@tempcnta\z@\relax
	\ifnum\cup@affil@alt@cnt>\z@\relax
	\expandafter\cup@altaffil@ifdup@aux
	\fi
	\if@tempswa
	\expandafter\@firstoftwo
	\else
	\expandafter\@secondoftwo
	\fi
}
\newcommand*\cup@altaffil@ifdup@aux{%
	\advance\@tempcnta\@ne\relax
	\expandafter\expandafter\expandafter\def\expandafter\expandafter
	\expandafter\@tempb\expandafter\expandafter\expandafter
	{\csname @altaffil@\@roman\@tempcnta\endcsname}%
	\ifx\@tempa\@tempb
	\expandafter\@tempswatrue
	\else
	\ifnum\@tempcnta<\cup@affil@alt@cnt\relax
	\expandafter\expandafter\expandafter\cup@altaffil@ifdup@aux
	\fi
	\fi
}
\newcommand*\email[2][]{%
	\ifnum\cup@author@cnt>\z@\relax
	\cup@emailtrue%
	\expandafter\gdef\csname @emailname@\@roman\cup@author@cnt\endcsname
	{#1}%
	\expandafter\gdef\csname @email@\@roman\cup@author@cnt\endcsname
	{#2}%
	\else
	\cup@warning{E-mail with no author}%
	\fi
}
\@onlypreamble\email
\newcommand*\fax[1]{%
	\ifnum\cup@author@cnt>\z@\relax
	\expandafter\gdef\csname @fax@\@roman\cup@author@cnt\endcsname
	{#1}%
	\else
	\cup@warning{Fax number with no author}%
	\fi
}
\@onlypreamble\fax
\newcommand*\phone[1]{%
	\ifnum\cup@author@cnt>\z@\relax
	\expandafter\gdef\csname @phone@\@roman\cup@author@cnt\endcsname
	{#1}%
	\else
	\cup@warning{Phone number with no author}%
	\fi
}
\@onlypreamble\phone
\newcommand*\abbreviations[1]{%
	\gdef\@abbreviations{#1}%
}
\newcommand*\@abbreviations{}
\@onlypreamble\abbreviations
%\newcommand*\keywords[1]{%
%	\gdef\@keywords{#1}%
%}
%\newcommand*\@keywords{}
%\@onlypreamble\keywords
\newcommand*\cup@abbreviations@print{%
	\ifx\@abbreviations\@empty\else
	{\noindent\bfseries Abbreviations: }
	\@abbreviations
	\par
	\fi
}
\newcommand*\jel[1]{%
	\gdef\@jel{#1}%
}
\newcommand*\@jel{}
\@onlypreamble\jel
\newcommand*\cup@jel@print{%
	\ifx\@jel\@empty\else
	{\noindent\bfseries JEL classification: }
	\@jel
	\par
	\fi
}
\newcommand*\msc[1]{%
	\gdef\@msc{#1}%
}
\newcommand*\@msc{}
\@onlypreamble\msc
\newcommand*\cup@msc@print{%
	\ifx\@msc\@empty\else
	{\noindent\bfseries MSC Codes: }
	\@msc
	\par
	\fi
}

\newcommand*\cup@author@list{%
	\@tempcnta\z@\relax%从0开始遍历作者
	\ifnum\cup@author@cnt=\z@\relax\else
	\expandafter\cup@author@list@main
	\fi
}
\newcommand*\cup@author@footnotes{}
\newcommand*\cup@author@list@main{%
	\advance\@tempcnta\@ne\relax
	\def\cup@author@footnotes{}%清空上一个的标记
	\cup@author@list@mycomma%作者和作者之间要加逗号
	\space%空格
	\@nameuse{@author@\@roman\@tempcnta}%显示姓名
	\cup@author@affil
	\cup@author@affil@also
	\cup@author@firstauthor
	\cup@author@star
	\ifx\@empty\cup@author@footnotes\else
		\textsuperscript{\color[HTML]{057cca}\cup@author@footnotes}%实际的显示
	\fi
	%%解决orcid
	\cup@author@orcid
	\ifnum\@tempcnta<\cup@author@cnt\relax
		\expandafter\cup@author@list@main
	\fi
}
\newcommand*\cup@author@list@and{%最后一个作者增加and字符串
	\ifnum\cup@author@cnt=\@ne\relax\else
	\ifnum\@tempcnta=\cup@author@cnt\relax
	\space and%
	\fi
	\fi
}
\newcommand*\cup@author@list@comma{%
	\ifnum\cup@author@cnt>\tw@\relax
	\ifnum\@tempcnta<\cup@author@cnt\relax
	,%
	\fi
	\fi
}


\newcommand*\cup@author@list@mycomma{%
	\ifnum\@tempcnta>1\relax
	\ifnum\@tempcnta>\cup@author@cnt\relax
	\else
	,
	\fi
	\fi
}


\newcommand*\cup@author@star{%如果定义了@email@roman，那么就要给footnotes加上型号标识
	\cup@ifundefined{@email@\@roman\@tempcnta}{}{%
		\cup@author@star@aux
	}%
}
\newcommand*\cup@author@star@aux{%
	\protected@edef\cup@author@footnotes{%
		\cup@author@footnotes
		% \cup@author@fnsymbol{\z@}%
		\emailsymbol%
%		\ifnum\cup@affil@cnt>\@ne\relax
%			,
%		\else
%			\ifnum\cup@affil@alt@cnt>\z@\relax
%				,
%			\fi
%		\fi
	}% 
}

\RequirePackage[hidelinks]{hyperref}



% 1. 定义引用自定义颜色
\definecolor{refColor}{RGB}{0, 130, 170} % 自定义RGB值
% 2. 配置hyperref（移除hidelinks，添加颜色）
%\RequirePackage[colorlinks=true, linkcolor=refColor]{hyperref}
% 3. 重定义\ref/\autoref确保颜色生效
\let\originalRef\ref
\renewcommand{\ref}[1]{\textcolor{refColor}{\originalRef{#1}}}
\let\originalAutoref\autoref
\renewcommand{\autoref}[1]{\textcolor{refColor}{\originalAutoref{#1}}}




\newcommand*\cup@author@orcid{%
	\cup@ifundefined{@orcid@\@roman\@tempcnta}{}{%
		\href{https://orcid.org/\csname @orcid@\@roman\@tempcnta\endcsname}{%
			\includegraphics[height=0.8em]{orcid_icon.png}% 确保orcid_icon.png在路径中
		}
	}%
}

\newcommand*\cup@author@firstOverTwo{
	\ifnum\cup@first@cnt>1\relax
		\textsuperscript{\color[HTML]{057cca}\#}These authors contributed equally to this work and are co-first authors for this paper.
	\fi
}


\newcommand*\cup@author@firstauthor{%
	\cup@ifundefined{@firstauthor@\@roman\@tempcnta}{}{%
		\cup@author@firstauthor@aux
	}%
}
\newcommand*\cup@author@firstauthor@aux{%
	\protected@edef\cup@author@footnotes{%
		\cup@author@footnotes
		\expandafter\firstsymbol\relax%
	}%
}

\newcommand*\cup@author@affil{%
	\cup@ifundefined{%
		@affil@\@roman\csname @author@affil@\@roman\@tempcnta\endcsname
	}{%没有找到这个机构则发出警告
		\cup@warning{%
			No affiliation given for author\MessageBreak
			\@nameuse{@author@\@roman\@tempcnta}%
		}%
	}{%找到了就要执行后续操作
		\cup@author@affil@aux
	}%
}
\newcommand*\cup@author@affil@aux{%
	\ifnum\cup@affil@cnt>\@ne\relax%机构总计数大于1
		\expandafter\cup@affil@marker@cnt\csname @author@affil@\@roman\@tempcnta\endcsname\relax
		\advance\cup@affil@marker@cnt\cup@footnote@cnt\relax
		\protected@edef\cup@author@footnotes{%
%			\cup@author@footnotes
			\cup@author@fnsymbol{\cup@affil@marker@cnt}%
		}%
	\else%机构总计数等于1
		\ifnum\cup@affil@cnt>\z@\relax%这里做过修改原来是\ifnum\cup@affil@alt@cnt>\z@\relax
			\cup@affil@marker@cnt\@ne\relax
			\advance\cup@affil@marker@cnt\cup@footnote@cnt\relax
			\protected@edef\cup@author@footnotes{%
%				\cup@author@footnotes
				\cup@author@fnsymbol{\cup@affil@marker@cnt}%
			}%
		\fi
	\fi
}
\newcommand*\cup@author@affil@also{%
	\cup@ifundefined{@author@alsoaffil@\@roman\@tempcnta}{}{%
		\cup@author@affil@also@aux
	}%
}
\newcommand*\cup@author@affil@also@aux{%
	\expandafter\@for\expandafter\@tempa\expandafter:\expandafter
	=\csname @author@alsoaffil@\@roman\@tempcnta\endcsname\do{%
		\cup@affil@marker@cnt\@tempa\relax
		\advance\cup@affil@marker@cnt\cup@footnote@cnt\relax
		\protected@edef\cup@author@footnotes{%
			\cup@author@footnotes
				,
			\cup@author@fnsymbol{\cup@affil@marker@cnt}%
		}%
	}%
}
\newcommand*\cup@author@affil@alt{%
	\cup@ifundefined{@author@altaffil@\@roman\@tempcnta}{}{%
		\cup@author@affil@alt@aux
	}%
}
\newcommand*\cup@author@affil@alt@aux{%
	\expandafter\cup@affil@marker@cnt
	\csname @author@altaffil@\@roman\@tempcnta\endcsname\relax
	\advance\cup@affil@marker@cnt\cup@affil@cnt\relax
	\advance\cup@affil@marker@cnt\cup@footnote@cnt\relax
	\protected@edef\cup@author@footnotes{%
		\cup@author@footnotes
		%,%
		\cup@author@fnsymbol{\cup@affil@marker@cnt}%
	}%
}
\newcommand*{\cup@author@fnsymbol}[1]{%
	\ensuremath{%
		\expandafter\cup@author@fnsymbol@aux\expandafter{\number#1}%
	}%
}
\newcommand*{\cup@author@fnsymbol@aux}[1]{%此方法被重写了，直接返回数字
	\ifnum#1>10 %
	\expandafter\cup@author@fnsymbol@loop
	\else
	\expandafter\cup@author@fnsymbol@symbol
	\fi
	{#1}%
}
\newcommand*{\cup@author@fnsymbol@loop}[1]{%
	\cup@author@fnsymbol@loop@aux@i#1%
}
\newcommand*{\cup@author@fnsymbol@loop@aux@i}[2]{%
	\cup@author@fnsymbol@symbol{\ifnum#2=0 10\else #2\fi}%
	\expandafter\cup@author@fnsymbol@loop@aux@ii\romannumeral #1000Q{}%
	{\cup@author@fnsymbol@symbol{\ifnum#2=0 10\else #2\fi}}%
}
\newcommand*{\cup@author@fnsymbol@loop@aux@ii}[1]{%
	\@nameuse{cup@author@fnsymbol@loop@aux@#1}%
}
\def\cup@author@fnsymbol@loop@aux@m#1Q#2#3{%
	\cup@author@fnsymbol@loop@aux@ii#1Q{#2#3}{#3}%
}
\newcommand*{\cup@author@fnsymbol@loop@aux@Q}[2]{#1}
\newcommand*{\cup@author@fnsymbol@symbol}[1]{%
	\ifcase #1 *\or
	\dagger\or
	\ddagger\or
	\P\or
	\S\or
	\|\or
	\bot\or
	\#\or
	@\or
	\triangle\or
	\nabla
	\fi
}
\newcommand*\cup@address@list{%
	\ifnum\cup@affil@cnt>\z@
	\expandafter\cup@address@list@auxi
	\else
	\cup@warning{No affiliations: at least one affiliation is needed}%
	\fi
}
\newcommand*\cup@address@list@auxi{%
%	\ifnum0%
%	\ifnum\cup@affil@cnt>\@ne    1\fi
%	\ifnum\cup@affil@alt@cnt>\z@ 1\fi
%	>\z@
	\expandafter\cup@address@list@auxii
%	\else
%	\@address@i\par
%	\fi
}
\newcommand*\cup@address@list@auxii{%
	\@tempcnta\z@
	\cup@affil@marker@cnt\cup@footnote@cnt
	\loop\ifnum\@tempcnta<\cup@affil@cnt
	\advance\@tempcnta\@ne
	\advance\cup@affil@marker@cnt\@ne
	{\color[HTML]{057cca}\textsuperscript{\cup@author@fnsymbol{\cup@affil@marker@cnt}}}%
	\@nameuse{@address@\@roman\@tempcnta}\par% and % TODO handle multiples
	\repeat
	\@tempcnta\z@
	\loop\ifnum\@tempcnta<\cup@affil@cnt
	\advance\@tempcnta\@ne
	\advance\cup@affil@marker@cnt\@ne
	\cup@ifundefined{@altaffil@\@roman\@tempcnta}
	{}
	{%
		{\color[HTML]{057cca}\textsuperscript{\cup@author@fnsymbol{\cup@affil@marker@cnt}}}%
		\@nameuse{@altaffil@\@roman\@tempcnta}\par
	}%
	\repeat
}
\newcommand*\cup@fnsymbol@org{}
\newcommand*\cup@affil@list{%
	\let\cup@fnsymbol@org\@fnsymbol
	\let\@fnsymbol\cup@author@fnsymbol
	\@tempcnta\z@\relax
	\@tempcntb\z@\relax
	\ifnum\cup@affil@cnt>\@ne\relax
	\expandafter\cup@affil@list@aux
	\else
	\ifnum\cup@affil@alt@cnt>\z@\relax
	\cup@affil@marker@cnt\@ne\relax
	\advance\cup@affil@marker@cnt\cup@footnote@cnt\relax
	\footnotetext[^\cup@affil@marker@cnt]{\@affil@i}%
	\@tempcnta\@ne\relax
	\fi
	\fi
	\ifnum\cup@affil@alt@cnt>\z@\relax
	\expandafter\cup@affil@alt@list
	\fi
	\let\@fnsymbol\cup@fnsymbol@org
}
\newcommand*\cup@affil@list@aux{%
	\advance\@tempcnta\@ne\relax
	\cup@affil@marker@cnt\@tempcnta\relax
	\advance\cup@affil@marker@cnt\cup@footnote@cnt\relax
	\footnotetext[\cup@affil@marker@cnt]{%
		\@nameuse{@affil@\@roman\@tempcnta}%
	}%
	
	\ifnum\@tempcnta<\cup@affil@cnt\relax
	\expandafter\cup@affil@list@aux
	\fi
}
\newcommand*\cup@affil@alt@list{%
	\advance\@tempcntb\@ne\relax
	\cup@ifundefined{@altaffil@\@roman\@tempcntb}{}{%
		\cup@altaffil@foot@aux
	}
	\ifnum\@tempcntb<\cup@author@cnt\relax
	\expandafter\cup@affil@alt@list
	\fi
}
\newcommand*\cup@altaffil@foot@aux{%
	\advance\@tempcnta\@ne\relax
	\cup@affil@marker@cnt\@tempcnta\relax
	\advance\cup@affil@marker@cnt\cup@footnote@cnt\relax
	\footnotetext[\cup@affil@marker@cnt]{%
		\@nameuse{@altaffil@\@roman\@tempcntb}%
	}%
}
\newcommand*\cup@email@list@font{}
\newcommand*\cup@email@list{%
	\begingroup
	\def\UrlFont{\cup@email@list@font}%
	\@tempcnta\z@\relax
	\@tempcntb\z@\relax
	\cup@email@list@aux
	\ifnum\@tempcntb=\z@\relax
	\cup@warning{%
		No e-mail given:\MessageBreak
		at lest one author must have a contact e-mail%
	}%
	\fi
	\endgroup
}
\newcommand*\cup@email@list@aux{%
	\advance\@tempcnta\@ne\relax
	\ifnum\@tempcnta>\cup@author@cnt\relax\else
	\cup@ifundefined{@email@\@roman\@tempcnta}{}{%
		\advance\@tempcntb\@ne\relax
		\ifnum\@tempcntb>\@ne\relax
		;
		\fi
		\expandafter\expandafter\expandafter\url\expandafter
		\expandafter\expandafter{%
			\csname @email@\@roman\@tempcnta\endcsname
		}%
	}%
	\expandafter\cup@email@list@aux
	\fi
}
\newcommand*\cup@number@list{%
	\begingroup
	\cup@number@list@aux@i{phone}%
	\let\@tempb\@tempa
	\cup@number@list@aux@i{fax}%
	\ifx\@tempa\@empty
	\let\@tempa\@tempb
	\else
	\ifx\@tempb\@empty\else
	\protected@edef\@tempa{%
		\@tempb.\space\@tempa
	}%
	\fi
	\fi
	\ifx\@tempa\@empty\else
	\par
	\@tempa
	\fi
	\endgroup
}
\newcommand*\cup@number@list@aux@i[1]{%
	\def\@tempa{}%
	\@tempcnta\z@\relax
	\def\cup@number@list@aux@ii{%
		\advance\@tempcnta\@ne\relax
		\ifnum\@tempcnta>\cup@author@cnt\relax\else
		\cup@ifundefined{@#1@\@roman\@tempcnta}{}{%
			\cup@ifundefined{@email@\@roman\@tempcnta}{}{%
				\ifx\@tempa\@empty
				\edef\@tempa{%
					\@nameuse{@#1@\@roman\@tempcnta}%
				}%
				\else
				\edef\@tempa{%
					\@tempa
					;
					\@nameuse{@#1@\@roman\@tempcnta}%
				}%
				\fi
			}%
		}%
		\expandafter\cup@number@list@aux@ii
		\fi
	}%
	\cup@number@list@aux@ii
	\ifx\@tempa\@empty\else
	\protected@edef\@tempa{%
		\MakeUppercase#1: \@tempa
	}%
	\fi
}
\newcommand*\cup@number@list@aux@ii{}


%%处理作者标记的方式
\newcommand*\acksize{\normalsize}
\newcommand*\suppsize{\normalsize}
\newcommand*\patch@numeric@authors{%
	\renewcommand{\cup@author@fnsymbol@aux}[1]{##1}
	\pretocmd{\cup@author@fnsymbol}{\let\ensuremath\relax}{}{}
}

%%对maketitle的配置
\newcommand*\cup@maketitle@extras{%
	\cup@maketitle@extras@hook
}
\newcommand*\cup@maketitle@extras@hook{}
\g@addto@macro{\maketitle}{\cup@maketitle@extras\thispagestyle{empty}}
\g@addto@macro{\document}{\maketitle}



%%正文内容
%设置全局图片和表格的字体等元素的样式
\captionsetup{
	font={
		footnotesize,
		sf,
		%    sansmath
	},
	labelfont=bf,
	labelsep=period
}
\floatsetup{
	font={
		sf,
		%    sansmath,
		footnotesize
	}
}
\definecolor{figerTitleColor}{RGB}{210,90,90}
\DeclareCaptionFormat{tmrcalibriCaption}{%
	\bodyfont          % 设置Calibri字体
	\footnotesize      % 字号+加粗
	#1 #2#3                  % 保留caption原有结构（编号+内容）
}



\captionsetup[figure]{
	format=tmrcalibriCaption,
	labelfont={bf,color=figerTitleColor},
	labelsep=space,
	justification=raggedright,
}
\captionsetup[figure*]{
	format=tmrcalibriCaption,
	labelfont={bf,color=figerTitleColor},
	labelsep=space,
	justification=raggedright,
}

\colorlet{structure@color}{black}%设置一个全局颜色，并指定为黑色

%列表样式
\RequirePackage{enumitem} % For list styling
\setlist{noitemsep,leftmargin=\parindent}

%%表格注释的定义
\RequirePackage[online]{threeparttable} 
\let\TPTnoteSettingsOrig\TPTnoteSettings
\def\TPTnoteSettings{\TPTnoteSettingsOrig\scriptsize}
\RequirePackage{endnotes}
\newcommand*{\printendnotes}{%
	\def\enoteformat{\rightskip=0pt \leftskip=0pt \parindent=0pt \makeenmark}
	\def\makeenmark{\bgroup\bfseries\theenmark\enspace\egroup}
	\theendnotes
}

%浮动体的新定义
%\newfloat{scheme}{htbp}{los}
%\floatname{scheme}{Scheme}
%\newfloat{chart}{htbp}{loc}
%\floatname{chart}{Chart}
%\newfloat{graph}{htbp}{loh}
%\floatname{graph}{Graph}
%\newcommand*\schemename{Scheme}
%\newcommand*\chartname{Chart}
%\newcommand*\graphname{Graph}
%\floatplacement{table}{htbp}
%\floatplacement{figure}{htbp}
\floatstyle{plaintop}
\restylefloat{table}
%\let\cup@floatboxreset\@floatboxreset
%\def\@floatboxreset{%
%	\centering
%	\cup@floatboxreset
%}

\definecolor{tmrTableColorBase}{RGB}{250,231,232}

%%%表格设置
%\AtEndOfClass{%
%	\colorlet{tbrowcolor}{structure@color!10}
%	\colorlet{tbheadcolor}{structure@color!30}
%	\colorlet{tmrTableColor}{tmrTableColorBase!60}
%	\arrayrulecolor{structure@color}
%}
%%% From https://tex.stackexchange.com/a/32366/226
%\newcommand*{\trfiller}{%
%	\arrayrulecolor{tbrowcolor}% change to cell colour
%	\specialrule{\heavyrulewidth}{0pt}{-\heavyrulewidth}% "invisible" rule
%	\arrayrulecolor{structure@color}% revert to regular line colour
%}
%\newcommand*{\thfiller}{%
%	\arrayrulecolor{tmrTableColor}% change to cell colour
%	\specialrule{\heavyrulewidth}{0pt}{-\heavyrulewidth}% "invisible" rule
%	\arrayrulecolor{structure@color}% revert to regular line colour
%}
%\newcommand{\headrow}{\rowcolor{tmrTableColor}}
%\newcommand{\patchCUPtables}{%
%	\rowcolors*{1}{}{tmrTableColor}%
%	\setlength{\aboverulesep}{0pt}%
%	\setlength{\belowrulesep}{0pt}%
%	\setlength{\extrarowheight}{.75ex}%
%}
%\AtBeginEnvironment{table}{\patchCUPtables}
%\AtBeginEnvironment{table*}{\patchCUPtables}



% 先定义需要的颜色（如果未定义）
\definecolor{evenRowColor}{RGB}{250,231,232}

\newenvironment{tmrtable}[5]{%
	\begin{table}[htb!]
	\centering
	\caption{#1}
	\label{tab:#2}
	\def\tablenote{#5}
	\edef\tableroweven{\the\numexpr #4 + 1 \relax}
	% 环境开始时执行的代码
	\begin{tblr}{
			% 优化列宽：调整比例，适配长文本自动换行
			colspec={#3},
			% 三线表样式
			hline{1}={1.5pt},    
			hline{2}={0.75pt},   
			hline{Z}={1.5pt},    
			% 表头样式：背景为白色
			row{#4}={font=\bfseries, bg=white}, 
			% 偶数行变色（第2行起）
			row{even[\tableroweven]}={bg=evenRowColor},
%			row{even}={
%				bg={\ifnum\rownum>\startEvenRow-1 evenRowColor\else white\fi}
%			},
			% 合并单元格强制白色背景
			cell{*}{*}={merge={bg=white}},
			% 紧凑间距+自动换行
			rowsep=3pt,
			colsep=3pt,
			vlines={0pt}, 
			% 自动换行：所有单元格左对齐，自动换行
			cell{*}{*}={cmd=\raggedright},
		}%
	}{%
	\end{tblr}%
	\vspace{0.5em}
	\par\small\noindent{\tablenote}%
%	\par{#6}%
	\end{table}%
}

% ========== 修复版：跨栏表格环境 tmrtable* ==========
% 使用方式：\begin{tmrtable*}{列格式}{表头行} 表格内容 \end{tmrtable*}
\newenvironment{tmrtable*}[5]{%
	% 环境开始时执行的代码
	\begin{table*}[htb!]
		\centering
		\caption{#1}
		\label{#2}
		\def\tablenote{#5}
		\edef\tableroweven{\the\numexpr #4 + 1 \relax}
		\centering % 跨栏表格居中
		\begin{tblr}{
				% 优化列宽：调整比例，适配长文本自动换行
				colspec={#3},
				% 三线表样式
				hline{1}={1.5pt},    
				hline{2}={0.75pt},   
				hline{Z}={1.5pt},    
				% 表头样式：背景为白色
				row{#4}={font=\bfseries, bg=white}, 
				% 偶数行变色（第2行起）
				row{even[2]}={bg=evenRowColor},
				% 合并单元格强制白色背景
				cell{*}{*}={merge={bg=white}},
				% 紧凑间距+自动换行
				rowsep=3pt,
				colsep=3pt,
				vlines={0pt}, 
				% 自动换行：所有单元格左对齐，自动换行
				cell{*}{*}={cmd=\raggedright},
			}%
		}{%
			% 环境结束时执行的代码
		\end{tblr}
		\vspace{0.5em}
		\par\small\noindent{\tablenote}%
	\end{table*}%
}



%自定义 \appendix 命令，使得附录部分的章节编号从 0 开始，并将章节格式设置为“Appendix 1”样式
\renewcommand\appendix{\par
	\setcounter{section}{0}
	\setcounter{subsection}{0}
	\gdef\thesection{Appendix \@arabic\c@section}
}


%定义超链接的样式
%\ifcup@hyperref
%\expandafter\RequirePackage
%\else
%\expandafter\@gobble
%\fi
%{hyperref}


\usepackage{mdframed}    % 高亮背景容器
\usepackage{enumitem}    % 优化列表排版（解决默认列表间距问题）

\definecolor{hilight-bg}{RGB}{222,235,247} 
\NewDocumentEnvironment{highlight}{+b}{%
	% 1. 外层高亮容器
	\begin{mdframed}[
		backgroundcolor=hilight-bg,    % 整体背景
		hidealllines=true,
		%		linecolor=hilight-border,      % 边框颜色
		%		linewidth=0.5pt,               % 边框宽度
		roundcorner=4pt,               % 圆角（可选，增强美观）
		leftmargin=3mm,                % 容器左外边距
		rightmargin=3mm,               % 容器右外边距
		innertopmargin=5mm,            % 容器内顶部间距
		innerbottommargin=3mm,         % 容器内底部间距
		innerleftmargin=3mm,           % 容器内左侧间距
		innerrightmargin=3mm,          % 容器内右侧间距
		]
		
		% 2. 内部列表环境（承载多个 \item{title}{content}）
		\begin{itemize}[
			leftmargin=0pt,                % 取消列表默认左缩进
			label={},                      % 隐藏列表默认项目符号
			itemsep=6mm,                   % 条目之间的垂直间距（可调整）
			topsep=0pt,                    % 列表顶部无额外间距
			partopsep=0pt
			]
			#1  % 接收环境内的所有 \item 内容
		\end{itemize}
		
	\end{mdframed}
}{}

\NewDocumentCommand{\highlightitem}{mm}{%
	\item[{}]  % 空标签，避免默认列表符号
	\showfont\textbf{\itshape #1}\\[1mm]  % 标题换行，1.5mm间距
	\begin{flushright}
		\vspace{-2.1em}% 取消顶部额外间距
		\begin{minipage}[t]{\dimexpr\linewidth - 1em}  % 宽度可调整
			\footnotesize#2
		\end{minipage}
		\vspace{0pt}% 取消底部额外间距
	\end{flushright}
}




%%章节的基本调整
\RequirePackage{xcolor}  % 引入 xcolor 宏包以支持颜色
\RequirePackage{tikz}

\definecolor{mycolor}{rgb}{0.87, 0.93, 0.97}
\definecolor{sectioncolor}{HTML}{D25A5A}
\renewcommand\section{\@startsection {section}{1}{\z@}%
	{-3.5ex \@plus -1ex \@minus -.2ex}% 上间距
	{1.2ex \@plus.2ex}% 下间距
	{% 关键：添加 \noindent 取消标题缩进，避免右移
		\bodyfont\sffamily\bfseries\noindent\@mysection}}

\def\@mysection#1{%
	\tikz[baseline]{%
		\node[fill=mycolor,
		text=sectioncolor,
		rounded corners=3pt,
		inner sep=5pt,
		minimum width=\linewidth,  % 占全行宽度
		align=left,                % 文字左对齐
		anchor=west]               % 节点锚点设为左边界（核心修正）
		{#1};
	}%
}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {0.2ex \@plus .2ex}%
  {\large\bodyfont\sffamily\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {0.2ex \@plus .2ex}%
  {\bodyfont\sffamily\bfseries}} 
%\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
%  {3.25ex \@plus1ex \@minus.2ex}%
%  {-1em}%
%  {\bodyfont\sffamily}}
%\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
%  {3.25ex \@plus1ex \@minus .2ex}%
%  {-1em}%
%  {\bodyfont\sffamily}}
  
%%这一命令用于文本的悬挂缩进或特定格式化
%\def\@hangfrom#1{\setbox\@tempboxa\hbox{{#1}}%
 % \hangindent 0pt%\wd\@tempboxa
  %\noindent\box\@tempboxa}

%章节格式
\def\@seccntformat#1{\@ifundefined{#1@cntformat}%
   {\csname the#1\endcsname\quad}%  default
   {\csname #1@cntformat\endcsname}% individual control
   }
   \def\section@cntformat{\thesection.\quad}
   
   
\def\section@cntformat{}%第一级标题不显示编号
\def\subsection@cntformat{}%
\def\subsubsection@cntformat{}%
%章节格式
\newcommand*\cup@section{}
\let\cup@section\section
\newcommand*\cup@subsection{}
\let\cup@subsection\subsection
\newcommand*\cup@subsubsection{}
\let\cup@subsubsection\subsubsection
\newcommand*\cup@startsection@orig{}
\let\cup@startsection@orig\@startsection
\newcommand\cup@startsection[6]{%
	\if@noskipsec \leavevmode \fi
	\par \@tempskipa #4\relax
	\@afterindenttrue
	\ifdim \@tempskipa <\z@ \@tempskipa -\@tempskipa \@afterindentfalse\fi
	\if@nobreak \everypar{}\else
	\addpenalty\@secpenalty\addvspace\@tempskipa\fi
	\@ifstar{\@dblarg{\@sect{#1}{\@m}{#3}{#4}{#5}{#6}}}%
	{\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}%
}
\let\@startsection\cup@startsection
\newcommand*\cup@startsection@alt[6]{%
	\if@noskipsec \leavevmode \fi
	\par \@tempskipa #4\relax
	\@afterindenttrue
	\ifdim \@tempskipa <\z@ \@tempskipa -\@tempskipa \@afterindentfalse\fi
	\if@nobreak \everypar{}\else
	\addpenalty\@secpenalty\addvspace\@tempskipa\fi
	\@ifstar{\@ssect{#3}{#4}{#5}{#6}}
	{\@ssect{#3}{#4}{#5}{#6}}%
}
\newcommand*\cup@sections@none{%
	\@ifstar{%
		\cup@sections@none@aux
	}{%
		\cup@sections@none@aux
	}%
}
\newcommand*\cup@sections@none@aux[2][]{%
	\cup@warning{%
		(Sub)section `#2' ignored%
	}%
}
\patchcmd{\@ssect}{#4}{\color{structure@color}#4}{}{}
\patchcmd{\@sect}{#6}{\color{structure@color}#6}{}{}
\newcommand*\SectionNumbersOff{%
	\let\@startsection\cup@startsection@alt
}
\@onlypreamble\SectionNumbersOff
\newcommand*\SectionNumbersOn{%
	\let\@startsection\cup@startsection
}
\@onlypreamble\SectionNumbersOn
\newcommand*\SectionsOff{%
	\let\section\cup@sections@none
	\let\subsection\cup@sections@none
	\let\subsubsection\cup@sections@none
}
\@onlypreamble\SectionsOff
\newcommand*\SectionsOn{%
	\let\section\cup@section
	\let\subsection\cup@subsection
	\let\subsubsection\cup@subsubsection
}
\@onlypreamble\SectionsOn
\begingroup
\toks@=\expandafter{\tableofcontents}
\xdef\tableofcontents{%
	\begingroup
	\let\noexpand\@startsection\noexpand\cup@startsection@orig
	\the\toks@
	\endgroup
}
\endgroup


%%定义两个小的引用短句acknowledgement，suppinfoname
\newenvironment{acknowledgement}{%
	\cup@section*{\acknowledgementname}%
}{}
\newenvironment{suppinfo}{%
	\cup@section*{\suppinfoname}%
}{}
\newcommand*\acknowledgementname{Acknowledgement}


%%？？？？？？？？？？？？？？？？这里存在的意义是什么？
\AtEndOfClass{%
	\def\bibsection{%
		\cup@section*{\refname}%
	}%
}
\newcommand*\suppinfoname{Supporting Information Available}


%%对于整体largetwo的整体设置，十分重要
\newcommand*\cup@layout@largetwo{%
  \ifcup@simfonts\simfonts\fi
  \geometry{paperwidth=210mm,paperheight=297mm,
      left=1.4cm,top=2.3cm,bottom=1.7cm,right=1cm,
      columnsep=1.5em,headsep=1cm
      }
  \appto{\authorfont}{\sffamily}
  \appto{\affilfont}{\sffamily}
  \appto{\datesize}{\sffamily}
  \appto{\emailfont}{\sffamily}
  \def\ps@plain{
		\renewcommand{\@oddhead}{
			\sffamily
			\hfill
			\parbox[t]{150mm}{
				\raggedleft
				{\showfont\large\textbf{\color[HTML]{002060} \cup@articletype}}\par
				\vspace{1pt}
				{\bodyfont\footnotesize {\journalnamefont\textbf{\cup@journal@name}}\ \cup@year;\cup@vol\ifx\cup@no\empty\else(\cup@no)\fi:\cup@page.\ https://doi.org/\cup@doi}\par
			}%
		}
		\renewcommand{\@evenhead}{\@oddhead}
		\renewcommand{\@evenfoot}{
			\sffamily
			{\bodyfont\footnotesize\color[HTML]{002060} {Submit a manuscript:\ \cup@journalweb} }
			\hfill
			\thepage
		}
		\renewcommand{\@oddfoot}{\@evenfoot}% 奇数页页脚 = 偶数页页脚（统一样式，不分奇偶）
    }
  \pagestyle{plain}
}


% Journal Definitions
\def\cup@jnl@default{%
  \def\cup@journal@name{Default Journal}
  \cup@layout@largetwo
}%

\def\cup@jnl@tmr{%
	\edef\cup@journal@name{\cup@journalname}
	\cup@layout@largetwo
	\patch@numeric@authors
	\let\endnote\footnote
	\let\printendnotes\relax
	\renewcommand{\thefootnote}{\alphalph{\value{footnote}}}
	\renewcommand\footnoterule{}
	\advance\skip\footins 4\p@\@plus2\p@\relax
}%




%启动
\ifcsname cup@jnl@\cup@journal\endcsname%
	\csname cup@jnl@\cup@journal\endcsname%
\else%
	\cup@warning{%
		Unknown journal `\cup@journal':\MessageBreak
		using default configuration%
	}%
	\cup@jnl@default%
\fi%

\RequirePackage{xpatch}
\RequirePackage{xstring}
%%定义参考文献的样式
\providecommand*\cup@reference@code{% AMA格式配置（基于BibLaTeX原生numeric样式）
	\RequirePackage[%
	style=numeric,       % 核心：数字引用样式（AMA是数字上标）
	backend=biber,       % 文献处理后端（必须用Biber）
	sorting=none,        % 关键：按引用顺序排序（AMA要求，非字母顺序）
	maxnames=3,          % 作者最多显示6位，超过用et al.（AMA规范）
	minnames=3,          % 最少显示1位作者
	giveninits=false,     % 作者名：名首字母缩写（如Zhang SD，AMA要求）
	natbib=true,         % 兼容natbib命令（\citet/\citep）
	url=false,%            % 全局禁用URL（AMA优先显示DOI，可手动开启）
	doi=true,
	citestyle=numeric-comp,
	]{biblatex}
	
	\definecolor{citecolor}{RGB}{45, 144, 203}
	\let\oldparencite\parencite%
	\renewcommand{\parencite}[1]{%
		\textcolor{citecolor}{\oldparencite{##1}}%
	}
	\DeclareFieldFormat{labelnumberwidth}{%
		 ##1.\thinspace%
	}
	\DeclareFieldFormat{title}{##1}%
	\DeclareFieldFormat[article]{title}{##1}% 期刊文章
	\DeclareFieldFormat[book]{title}{##1}% 图书
	\DeclareFieldFormat[incollection]{title}{##1}% 论文集中的文章
	\DeclareFieldFormat[report]{title}{##1}% 研究报告
	\DeclareFieldFormat[thesis]{title}{##1}% 学位论文
	\DeclareFieldFormat{year}{##1}
	\ExecuteBibliographyOptions{date=year}
	\DeclareFieldFormat{volume}{##1}
	\DeclareFieldFormat{number}{(##1)}
	\DeclareFieldFormat{pages}{##1}
	
	\DeclareBibliographyDriver{article}{%
		\usebibmacro{bibindex}%
		\usebibmacro{begentry}%
		\usebibmacro{author}%
		\setunit{\labelnamepunct}\newblock%
		\usebibmacro{title}%
		\newunit{\labelnamepunct}\newblock%
		\usebibmacro{journal}%
		\setunit{\labelnamepunct}%
		\printfield{year}%
		\setunit{\addsemicolon}% 年份后直接加英文分号（无空格）
		\iffieldundef{volume}{% 无卷时不显示期
		}{%
			\printfield{volume}% 打印卷
		}%
		\iffieldundef{number}{}{%
			(\printfield{number})%
		}%
		\setunit{\addcolon}%
		\printfield{pages}
		\newunit\newblock%
		\usebibmacro{doi+eprint+url}%
		\newunit\newblock%
		\usebibmacro{finentry}%
	}
	
	\DeclareBibliographyDriver{misc}{%
		\usebibmacro{bibindex}% 索引（保持和article一致）
		\usebibmacro{begentry}% 条目开始（保持格式统一）
		\usebibmacro{title}% 核心：直接展示title字段（优先级最高）
		\newunit\newblock%
		\usebibmacro{finentry}% 条目结束（保持格式统一）
	}
	
	
	\DeclareBibliographyDriver{book}{%
		\usebibmacro{bibindex}% 索引
		\usebibmacro{begentry}% 条目开始
		\usebibmacro{author}% 可选：显示作者（无则跳过）
		\setunit{\labelnamepunct}\newblock% 作者与标题的分隔符
		\usebibmacro{title}% 核心：必显title字段
		\newunit{\labelnamepunct}\newblock% 年份与出版商的分隔符
		\iffieldundef{publisher}{}{% 仅当填写publisher时显示
			\printfield{publisher}% book类型核心：展示出版商
		}%
		\newunit\newblock%
		\usebibmacro{finentry}% 条目结束
	}
	
	
	\renewcommand*{\finalnamedelim}{\addcomma\space}%最后两个作者之间的分隔符：移除and，改为逗号+空格（或仅空格）
	\DeclareFieldFormat{doi}{Available at:\newline\hspace{2em}\textcolor[HTML]{0082AA}{\url{https://doi.org/##1}}\nopunct}%
	\DeclareNameAlias{sortname}{family-given}
	\renewrobustcmd*{\bibinitdelim}{}% 名缩写无逗号分隔（Zhang SD而非Zhang, S. D.）
	\renewrobustcmd*{\bibinitperiod}{} % 取消缩写点（SD而非S.D.）
	\renewcommand*{\bibfont}{\bodyfont\footnotesize}
}

\cup@reference@code
%\cup@type@check
%\ifx\cup@manuscript\cup@manuscript@note
%  \SectionsOff
%\fi
%\ifx\cup@manuscript\cup@manuscript@review
%  \SectionsOn
%  \SectionNumbersOn
%\fi
%\ifx\cup@manuscript\cup@manuscript@suppinfo
%  \setkeys{cup}{maxauthors = 0}
%  \def\thepage{S-\arabic{page}}
%  \renewcommand*\thefigure{S\@arabic\c@figure}
%  \renewcommand*\thescheme{S\@arabic\c@scheme}
%  \renewcommand*\thetable{S\@arabic\c@table}
%  \AtBeginDocument
%    {%
%      \renewcommand*\citenumfont[1]{S#1}%
%      \renewcommand*\bibnumfmt[1]{(S#1)}%
%    }
%\fi
\SectionNumbersOn