\ProvidesExplPackage{profile/page}{2021-09-11}{0.6.0}{NJU Thesis page layout} 

% 本科生页眉页脚 
\fancypagestyle{njuplain}{%
   \fancyhead{}               
   \fancyfoot[C]{\zihao{5}\thepage} % 页脚居中 五号新罗马体数字
}

% TODO: 研究生页眉页脚 
\fancypagestyle{njuheadings}{%
   \fancyhead{}               
   \fancyfoot[C]{\zihao{5}\thepage}        
}

\str_if_eq:NNTF {\nju_degree} { ug } 
{
  % the header line
  \tl_set:Nn \headrulewidth {0pt}
  % the footer line
  \tl_set:Nn \footrulewidth {0pt}
  
  \AtBeginDocument{\pagestyle{njuplain}} % 本科无页眉页脚
}
{
  % the header line
  % \tl_set:Nn \headrulewidth {1pt}

  \AtBeginDocument{\pagestyle{headings}} % 研究生有页眉页脚
}

% ctex格式设置
% 目录标题 三号宋体加粗
% 各部分标题 四号黑体
\ctexset{
    contentsname = \songti\bfseries\zihao{3}目\hspace{2em} 录,
    chapter/format = \zihao{4}\heiti\centering,
    section/format = \zihao{4}\heiti\raggedright,
    subsection/format = \zihao{4}\heiti\raggedright,
    subsubsection/format = \zihao{4}\heiti\raggedright
}

% 重定义目录中章节标题样式
% 目录内容中章的标题 四号黑体
% 目录中其他内容 小四号宋体
\titlecontents{chapter}% 标题级别
                [5em]% 标题左间距
                {\heiti\zihao{4}\vspace{10pt}}% 标题格式
                {\contentslabel{4em}}% 标题标志
                {\hspace*{-4em}}% 无序号标题
                {~\titlerule*[0.6pc]{$.$}~\contentspage}% 指引线与页码

\titlecontents{section}
                [5em]
                {\zihao{-4}\vspace{0pt}}
                {\contentslabel{2.5em}}
                {\hspace*{-4em}}
                {~\titlerule*[0.6pc]{$.$}~\contentspage}

\titlecontents{subsection}
                [8em]
                {\zihao{-4}\vspace{0pt}}
                {\contentslabel{3em}}
                {\hspace*{-4em}}
                {~\titlerule*[0.6pc]{$.$}~\contentspage}

% 将目录页插入pdf书签
\let\savedtableofcontents\tableofcontents
\renewcommand{\tableofcontents}{%
  \pdfbookmark{目录}{目录}
  \savedtableofcontents}