diff options
Diffstat (limited to 'macros/xetex/latex/hduthesis/doc/cha/source')
-rw-r--r-- | macros/xetex/latex/hduthesis/doc/cha/source/a1.tex | 224 | ||||
-rw-r--r-- | macros/xetex/latex/hduthesis/doc/cha/source/a2.tex | 88 | ||||
-rw-r--r-- | macros/xetex/latex/hduthesis/doc/cha/source/a3.tex | 231 | ||||
-rw-r--r-- | macros/xetex/latex/hduthesis/doc/cha/source/a4.tex | 4 | ||||
-rw-r--r-- | macros/xetex/latex/hduthesis/doc/cha/source/a5.tex | 4 | ||||
-rw-r--r-- | macros/xetex/latex/hduthesis/doc/cha/source/a6.tex | 28 | ||||
-rw-r--r-- | macros/xetex/latex/hduthesis/doc/cha/source/a7.tex | 35 |
7 files changed, 614 insertions, 0 deletions
diff --git a/macros/xetex/latex/hduthesis/doc/cha/source/a1.tex b/macros/xetex/latex/hduthesis/doc/cha/source/a1.tex new file mode 100644 index 0000000000..4bb5fd10be --- /dev/null +++ b/macros/xetex/latex/hduthesis/doc/cha/source/a1.tex @@ -0,0 +1,224 @@ +\subsection{\file{hduthesis.cls} 的实现} + +文档类日期/版本号/开发者id +\begin{minted} [ linenos, bgcolor = bg, breaklines ] {tex} + \def\hduthesis@date{2024/12/23} + \def\hduthesis@version{0.5.0} + \def\hduthesis@maintainerid{myhsia} +\end{minted} + +调用 \pkg{etoolbox} 宏包用于给命令打补丁 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \RequirePackage{etoolbox} +\end{minted} + +提供 \cls{hduthesis} 文档类,设置文档类日期、版本号 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \ProvidesExplClass{hduthesis} {\hduthesis@date} {\hduthesis@version} + {LaTeX Class for Thesis at Hangzhou Dianzi University} +\end{minted} + +兼容 \hologo{TeX} Live 2022 及之后的版本. 当对应命令不存在时,在已有命令基础上新增变体 + +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_if_exist:NF \seq_set_split:Nne + { \cs_generate_variant:Nn \seq_set_split:Nnn { Nne } } + \cs_if_exist:NF \seq_set_split:Nee + { \cs_generate_variant:Nn \seq_set_split:Nnn { Nee } } + \cs_if_exist:NF \tl_set:Ne + { \cs_generate_variant:Nn \tl_set:Nn { Ne } } + \cs_if_exist:NF \tl_gset:Ne + { \cs_generate_variant:Nn \tl_gset:Nn { Ne } } +\end{minted} + +定义新命令 \cs{hduthesis_msg_new:nn} 和 \cs{hduthesis_msg_error:nn} 用于新增错误消息和将错误消息广播到 Workspace +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_new_protected:Npn \hduthesis_msg_new:nn #1#2 + { \msg_new:nnn { hduthesis } {#1} {#2} } + \cs_new_protected:Npn \hduthesis_msg_error:nn #1#2 + { \msg_error:nnn { hduthesis } {#1} {#2} } +\end{minted} + +新增错误消息:用户协议 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \hduthesis_msg_new:nn { 用户协议 } + { \exp_not:n + { + hduThesiS~ 编译受阻.~ + 使用模板前请认真阅读模板说明文档封面上的「用户协议」~ + 模板作者不对使用本模板产生的格式审查问题负责~ + 添加选项 `agreed'[\documentclass[agreed]{hduthesis}]~ + 即可顺利编译并默认代表您已同意本协议.~ 祝君科研顺利!~ + 如遇问题,可邮件反馈至 xiamyphys@gmail.com. + } + } +\end{minted} + +对命令 \cs{hduthesis_msg_error:nn} 新增 \cmd{nx} 变体 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_generate_variant:Nn \hduthesis_msg_error:nn { nx } +\end{minted} + +新增错误消息:未找到模块 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \hduthesis_msg_new:nn { not found module } + { The~hduthesis~module~`#1'~not~found. } +\end{minted} + +定义命令 \cs{hduthesis_load_module:n} 用于加载模块,若模块不存在则输出错误消息 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_new_protected_nopar:Npn \hduthesis_load_module:n #1 + { + \file_if_exist_input:nF { hduthesis-##1-module.code.tex } + { \hduthesis_msg_error:nn { not found module } {##1} } + } +\end{minted} + +定义命令 \cs{hduthesis_provide_module:n} 用于提供模块 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_new_protected_nopar:Npn \hduthesis_provide_module:n #1 + { + \ProvidesExplFile{hduthesis-#1-module.code.tex} + {\hduthesis@date}{\hduthesis@version} + {hduThesiS~ \text_titlecase:n {#1} ~Module} + } +\end{minted} + +定义新数组 \cs{g__hdu_base_class_options_clist},用于存储文档类选项 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \clist_new:N \g__hdu_base_class_options_clist +\end{minted} + +定义文档类选项的键: +\begin{enumerate} + \item 布尔(Bool)值 \keys{\cmdmac~ agreed}:用户是否同意用户协议,初始值 \cmd{false}. 一旦输入 \cmd{agreed} 选项,则将 \cmd{agreed} 设置为 \cmd{true},即 \cmd{agreed} 等价于 \cmd{agreed = true} + \item 布尔(Bool)值 \keys{\cmdmac~ l3doc}:是否启用 \cls{l3doc} 文档类,初始值 \cmd{false}. 一旦输入 \cmd{l3doc} 选项,则将 \cmd{l3doc} 设置为 \cmd{true},即 \cmd{l3doc} 等价于 \cmd{l3doc = true} + \item 布尔(Bool)值 \keys{\cmdmac~ stationery}:是否启用 \cls{letter} 文档类,初始值 \cmd{false}. 一旦输入 \cmd{stationery} 选项,则将 \cmd{stationery} 设置为 \cmd{true},即 \cmd{stationery} 等价于 \cmd{stationery = true} + \item 令牌(token list)\keys{\cmdmac~ math-font}:数学字体 + \item 令牌(token list) \keys{\cmdmac~ CJKmain-font}:中文主字体 + \item 令牌(token list) \keys{\cmdmac~ CJKsans-font}:中文无衬线字体 + \item 令牌(token list) \keys{\cmdmac~ CJKmono-font}:中文等宽字体 + \item 未知选项 \keys{\cmdmac~ unknown}:将未知选项交给 \cs{__hduthesis_unknown_option:n} 处理 +\end{enumerate} +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \keys_define:nn { hduthesis / classoption } + { + agreed .bool_set:N = \g__hduthesis_agreement_bool, + agreed .initial:n = false, + agreed .default:n = true, + l3doc .bool_set:N = \g__hduthesis_doc_bool, + l3doc .initial:n = false, + l3doc .default:n = true, + stationery .bool_set:N = \g__hduthesis_stationery_bool, + stationery .initial:n = false, + stationery .default:n = true, + math-font .tl_set:N = \g__hduthesis_math_font, + CJKmain-font .tl_set:N = \g__hduthesis_main_CJK_font, + CJKsans-font .tl_set:N = \g__hduthesis_sans_CJK_font, + CJKmono-font .tl_set:N = \g__hduthesis_mono_CJK_font, + unknown .code:n = \__hduthesis_unknown_option:n {#1}, + } +\end{minted} + +定义命令 \cs{__hduthesis_unknown_option:n} 用于处理未知选项 + +若未知选项为空,则将 \cs{l_keys_key_str} 加入 \cs{g__hdu_base_class_options_clist} 列表;否则设置 \cs{l_keys_key_str} 为未知选项,并将其加入 \cs{g__hdu_base_class_options_clist} 列表 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_new_protected_nopar:Npn \__hduthesis_unknown_option:n #1 + { + \tl_if_empty:nTF { #1 } + { + \clist_gput_right:NV \g__hdu_base_class_options_clist \l_keys_key_str + } + { + \exp_args:NNx \clist_gput_right:Nn \g__hdu_base_class_options_clist + { \l_keys_key_str = \exp_not:n {#1} } + } + } +\end{minted} + +处理文档类选项 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \ProcessKeyOptions [ hduthesis / classoption ] +\end{minted} + +若启用 \cmd{l3doc} 选项,加载 \cls{l3doc} 文档类为基底,加载 \file{hdu.l3doc} 模块并结束输入 + +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \bool_if:NT \g__hduthesis_doc_bool + { + \PassOptionsToClass { 11pt, letterpaper } { l3doc } + \exp_args:NNV \LoadClass [ \g__hdu_base_class_options_clist ] { l3doc } + \hduthesis_load_module:n { hdu.l3doc } + \endinput + } +\end{minted} + +若启用 \cmd{stationery} 选项,加载 \cls{letter} 文档类为基底,加载 \file{hdu.stationery} 模块并结束输入 + +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \bool_if:NT \g__hduthesis_stationery_bool + { + \PassOptionsToClass { 12pt } { letter } + \exp_args:NNV \LoadClass [ \g__hdu_base_class_options_clist ] { letter } + \hduthesis_load_module:n { hdu.stationery } + \endinput + } +\end{minted} + +为基本文档类 \cls{ctexrep} 添加选项 \keys{a4paper, zihao = -4},为 \pkg{xeCJK} 宏包添加选项 \keys{quiet, no-math},加载 \cls{ctexrep} 文档类为基底,并用 \cs{exp_args:NNV} 将未知选项展开加载到 \cls{ctexrep} 文档类上 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \PassOptionsToClass { a4paper, zihao = -4 } { ctexrep } + \PassOptionsToPackage { quiet, no-math } { xeCJK } + \exp_args:NNV \LoadClass [ \g__hdu_base_class_options_clist ] { ctexrep } +\end{minted} + +如果用户未确认用户协议,输出错误消息,并不加载 \pkg{hyperref} 宏包,以免因``遇到报错而停止编译''而产生额外的 \pkg{hyperref} 警告. 否则,加载 \pkg{hyperref} 宏包,设置 \pkg{hyperref} 宏包选项 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \bool_if:NTF \g__hduthesis_agreement_bool + { + \RequirePackage{hyperref} + \pdfstringdefDisableCommands + { + \def \cite#1 {<#1>} + \def \hologoRobust#1 {<#1>} + } + \AtBeginDocument + { \hypersetup { hidelinks, pdfproducer = hduThesiS~by~Mingyu~Xia } } + } { \hduthesis_msg_error:nn { 用户协议 } { 未确认 } } +\end{minted} + +预加载部分常用包,设置 \pkg{pgfplots} 宏包版本,设置 \pkg{hologo} 宏包字体,设置 \cs{graphicx} 包的相对路径 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \RequirePackage { siunitx, circuitikz, pgfplots, listings, + hologo, lipsum, zhlipsum, booktabs, multicol } + \pgfplotsset { compat = newest } + \hologoFontSetup { general = \sffamily } + \graphicspath + { + {./figure/}{./figures/}{./image/}{./images/} + {./graphics/}{./graphic/}{./pictures/}{./picture/} + } +\end{minted} + +加载 \cmd{typeset} 和 \cmd{layout} 模块. +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \hduthesis_load_module:n { typeset } + \hduthesis_load_module:n { layout } +\end{minted} + +定义命令 \cs{__hduthesis_docinfo_degree_if_aux} 用于判断学号长度,若学号长度为 8,则加载 \cmd{bc.config} 模块;否则加载 \cmd{bc.config} 或 \cmd{pg.config} 模块. 此命令将用在 \file{hduthesis-docinfo-module.code} 模块中,因为学号长度的判断必须发生在设置文档信息后 + +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_new_protected:Nn \__hduthesis_docinfo_degree_if_aux: + { + \int_compare:nNnTF { \tl_count:N \l__docinfo_stdntid_tl } = { 8 } + { \hduthesis_load_module:n { bc.config } } + { \hduthesis_load_module:n { pg.config } } + } +\end{minted} + +结束 \file{hduthesis.cls} 文件 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \endinput +\end{minted}
\ No newline at end of file diff --git a/macros/xetex/latex/hduthesis/doc/cha/source/a2.tex b/macros/xetex/latex/hduthesis/doc/cha/source/a2.tex new file mode 100644 index 0000000000..8c78b072a8 --- /dev/null +++ b/macros/xetex/latex/hduthesis/doc/cha/source/a2.tex @@ -0,0 +1,88 @@ +\subsection{\file{hduthesis-typeset-module.code} 的实现} + +提供模块 \file{typeset} 文件 +\begin{minted} [ linenos, bgcolor = bg, breaklines ] {tex} + \hduthesis_provide_module:n {typeset} +\end{minted} + +设置行间距 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \linespread{1.39} +\end{minted} + +设置首行缩进 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \dim_set:Nn \parindent { 2\ccwd } +\end{minted} + +新定义字体大小 \cs{semilarge} 和 \cs{semiLarge} +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \newcommand \semilarge { \@setfontsize \semilarge{14}{16.5} } + \newcommand \semiLarge { \@setfontsize \semiLarge{16.5}{17.5} } +\end{minted} + +设置英文字体 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \RequirePackage{fontspec} + \setmainfont{texgyretermes} + [ + Extension = .otf, UprightFont = *-regular, BoldFont = *-bold, + ItalicFont = *-italic, BoldItalicFont = *-bolditalic + ] + \setsansfont{texgyreheros} + [ + Extension = .otf, BoldItalicFont = *-bolditalic, + UprightFont = *-regular, BoldFont = *-bold, + ItalicFont = *-italic, Scale = .9, + ] +\end{minted} + +调用 \pkg{amssymb}, \pkg{mathtools}, \pkg{cancel}, \pkg{fixdif}, \pkg{derivative} 宏包 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \RequirePackage { amssymb, mathtools, cancel, fixdif, derivative } +\end{minted} + +如果存在 \pkg{physics2} 宏包,则调用并配置 \pkg{physics2} 宏包 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \file_if_exist:nTF { physics2.sty } + { + \RequirePackage{physics2} + \usephysicsmodule{ ab, braket, ab.legacy, op.legacy, bm-um.legacy } + } { \RequirePackage{bm} } +\end{minted} + +调用 \pkg{unicode-math} 宏包,并关闭警告 \texttt{mathtools-colon} 和 \texttt{mathtools-overbracket} +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \RequirePackage + [ warnings-off = { mathtools-colon, mathtools-overbracket } ] {unicode-math} +\end{minted} + +设置数学环境的间距 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \AtBeginDocument + { + \dim_set:Nn \abovedisplayskip {3pt} + \dim_set:Nn \belowdisplayskip {3pt} + } +\end{minted} + +设置数学字体 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \tl_if_empty:NF \g__hduthesis_math_font + { \setmathfont { \g__hduthesis_math_font } } +\end{minted} + +设置中文字体,保留全局选项键值中的扩号以对应 \pkg{xeCJK} 宏包的接口. +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \tl_if_empty:NF \g__hduthesis_main_CJK_font + { \exp_last_unbraced:No \setCJKmainfont \g__hduthesis_main_CJK_font } + \tl_if_empty:NF \g__hduthesis_sans_CJK_font + { \exp_last_unbraced:No \setCJKsansfont \g__hduthesis_sans_CJK_font } + \tl_if_empty:NF \g__hduthesis_mono_CJK_font + { \exp_last_unbraced:No \setCJKmonofont \g__hduthesis_mono_CJK_font } +\end{minted} + +结束 \file{hduthesis-typeset-module.code} 文件 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \endinput +\end{minted} diff --git a/macros/xetex/latex/hduthesis/doc/cha/source/a3.tex b/macros/xetex/latex/hduthesis/doc/cha/source/a3.tex new file mode 100644 index 0000000000..979f48225f --- /dev/null +++ b/macros/xetex/latex/hduthesis/doc/cha/source/a3.tex @@ -0,0 +1,231 @@ +\subsection{\file{hduthesis-layout-module.code} 的实现} + +提供模块 \file{layout} 文件 +\begin{minted} [ linenos, bgcolor = bg, breaklines ] {tex} + \hduthesis_provide_module:n {layout} +\end{minted} + +调用 \pkg{geometry}、\pkg{array}、\pkg{setspace}、\pkg{fancyhdr}、\pkg{enumitem}、\pkg{cleveref} 宏包 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \RequirePackage{geometry, array, setspace, fancyhdr, enumitem, cleveref} +\end{minted} + +调用并配置 \pkg{caption} 宏包 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \RequirePackage[skip = 1.75ex, labelsep = quad, font = small]{caption} +\end{minted} + +清空页眉页脚,设置页面样式为 \cmd{fancy} +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \fancyhf{} + \pagestyle{fancy} +\end{minted} + +设置页眉线宽为 \cmd{.8pt} +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \renewcommand*\headrulewidth{.8pt} +\end{minted} + +设置图表编号格式为 \texttt{\meta{chapter}-\meta{figure/table}} +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \renewcommand*\thefigure {\arabic{chapter}-\arabic{figure}} + \renewcommand*\thetable {\arabic{chapter}-\arabic{table}} +\end{minted} + +设置公式编号格式为 \texttt{\meta{chapter}-\meta{equation}} +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \renewcommand*\theequation {\arabic{chapter}-\arabic{equation}} +\end{minted} + +减小图表后方与正文的间距 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \AddToHook{env/figure/after}{\vspace*{-2.3ex}} + \AddToHook{env/table/after}{\vskip-1.9ex} +\end{minted} + +设置 \cmd{enumerate} 环境的编号格式和缩进 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \setlist[enumerate,1] + { + label = (\,\arabic*\,), itemindent = 4em, leftmargin = 0em, + labelsep = 1ex, topsep = 0pt, itemsep = 0pt, partopsep = 0pt, + parsep = 0em, listparindent = 2\ccwd + } +\end{minted} + +设置引用格式 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \crefformat{figure}{图#2#1#3} + \crefformat{table}{表#2#1#3} +\end{minted} + +定义命令 \cs{__hduthesis_cover_spread_box:nn} 和 \cs{__hduthesis_cover_center_box:nn},用于生成封面中的分散与下划线居中对齐盒子. +\footnote + { \color{black!10} + 下划线居中对齐盒子的实现参考自 \href{https://tex.stackexchange.com/users/4427/egreg}{@egreg} 在 + \href{https://tex.stackexchange.com/questions/727960/how-to-center-a-series-of-text-width-a-fixed-width-that-can-automatically-linebr}{tex.stackexchange.com} 的解答. + } + +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_new_protected:Npn \__hduthesis_cover_spread_box:nn #1#2 + { + \mode_leave_vertical: + \hbox_to_wd:nn {#1} + { \exp_args:Nee \tl_map_inline:nn {#2} { ##1 \hfil } \unskip } + } + \cs_new_protected:Npn \__hduthesis_cover_center_box:nn #1#2 + { % by @egreg on tex.stackexchange.com + \mode_leave_vertical: + \dim_set:Nn \l_tmpa_dim {#1} + \global\setbox1 = \box\voidb@x + \group_begin: + \setbox0 = \vbox + { + \dim_set:Nn \hsize {#1}\relax + \dim_set:Nn \parindent {0pt} + \skip_set:Nn \leftskip {0pt plus 1fil} + \skip_set:Nn \rightskip {0pt plus -1fil} + \skip_set:Nn \parfillskip {0pt plus 2fil} + #2 \par + \loop + \setbox2 = \lastbox + \unless\ifvoid2 + \global\setbox1 = \vtop + { \hbox to\hsize{\strut\unhbox2} + \vskip-4pt \hrule height .5pt + \vskip9.6pt \unvbox1 + } + \unskip\unpenalty + \repeat + } + \group_end: + \box1 + } +\end{minted} + +定义命令 \cs{__hduthesis_process_array:NnnN},用于处理一维或二维数组. 其中一级分隔符为 \texttt{:},二级分隔符为 \texttt{/}. +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_new_protected_nopar:Npn \__hduthesis_process_array:NnnN #1#2#3#4 + { + \seq_set_split:Nee \l__hduthesis_process_array_seq { / } {#1} + \seq_set_split:Nee \l__hduthesis_process_array_row_seq { \c_colon_str } + { \seq_item:Nn \l__hduthesis_process_array_seq {#2} } + \tl_if_eq:nnTF {#3} {:} + { \tl_gset:Ne #4 { \seq_use:Nn \l__hduthesis_process_array_row_seq {} } } + { + \tl_gset:Ne #4 { \seq_item:Nn \l__hduthesis_process_array_row_seq {#3} } + } + \seq_clear:N \l__hduthesis_process_array_seq + \seq_clear:N \l__hduthesis_process_array_row_seq + } +\end{minted} + +将十二个 \meta{month} 的英文名称存入 \cs{g_system_month_clist} 中 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \clist_set:Nn \g_system_month_clist + { + January, February, March, April, May, June, July, + August, September, October, November, December + } +\end{minted} + +定义文档信息的键 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \keys_define:nn { hduthesis / docinfo } + { + title .clist_set:N = \l__docinfo_title_tl, + department .tl_set:N = \l__docinfo_department_tl, + major .tl_set:N = \l__docinfo_major_tl, + class .tl_set:N = \l__docinfo_class_tl, + stdntid .tl_set:N = \l__docinfo_stdntid_tl, + author .clist_set:N = \l__docinfo_author_tl, + supervisor .tl_set:N = \l__docinfo_supervisor_tl, + bibsource .tl_set:N = \l__docinfo_bibsource_tl, + } +\end{minted} + +定义用户端文档信息的输入命令 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \NewDocumentCommand \DocInfo { m } + { + \keys_set:nn { hduthesis / docinfo } {#1} + \__hduthesis_docinfo_process_aux: + \__hduthesis_docinfo_degree_if_aux: + } +\end{minted} + +定义处理文档信息的辅助命令. 其中论文标题与作者信息为一维数组,指导教师信息为二维数组. +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_set_protected_nopar:Nn \__hduthesis_docinfo_process_aux: + { + \__hduthesis_process_array:NnnN \l__docinfo_title_tl {1} {:} \@title + \__hduthesis_process_array:NnnN \l__docinfo_title_tl {2} {:} + \l__docinfo_entitle_tl + \__hduthesis_process_array:NnnN \l__docinfo_author_tl {1} {:} \@author + \__hduthesis_process_array:NnnN \l__docinfo_author_tl {2} {:} + \l__docinfo_enauthor_tl + \__hduthesis_process_array:NnnN \l__docinfo_supervisor_tl {1} {1} + \l__docinfo_cnrole_tl + \__hduthesis_process_array:NnnN \l__docinfo_supervisor_tl {1} {2} + \l__docinfo_cnsupervisor_tl + \__hduthesis_process_array:NnnN \l__docinfo_supervisor_tl {2} {1} + \l__docinfo_enrole_tl + \__hduthesis_process_array:NnnN \l__docinfo_supervisor_tl {2} {2} + \l__docinfo_ensupervisor_tl + \bool_if:NF \g__hduthesis_agreement_bool + { \tl_clear:N \l__docinfo_bibsource_tl } + \tl_if_empty:NTF \l__docinfo_bibsource_tl + { + \newcommand*\printbibliography{\chapter*{参考文献}} + \renewcommand*\cite[1]{\textsuperscript{[##1]}} + } + { + \RequirePackage[sort&compress]{gbt7714} + \bibliographystyle{gbt7714-numerical} + \dim_set:Nn \bibsep {.35ex} + \newcommand*\printbibliography + { + \nocite{*} \bibliography { \l__docinfo_bibsource_tl } + \addcontentsline{toc}{chapter}{参考文献} + } + } + } +\end{minted} + +定义处理承诺书签名数组的辅助命令. 其中签名文件名需要展开后存入 \cs{g__hduthesis_signature_file_tl} 中. +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \cs_new_protected_nopar:Npn \__hduthesis_signature_process_aux:nnn #1#2#3 + { + \clist_set:Nn \l__hduthesis_signature_process_clist {#1} + \seq_set_split:Nne \l__hduthesis_signature_figure_seq {/} + { \clist_item:Nn \l__hduthesis_signature_process_clist {#2} } + \int_compare:nNnTF {#3} = {0} + { + \tl_set:Ne \l__hduthesis_signature_figure_tl + { \seq_item:Nn \l__hduthesis_signature_figure_seq { #3 + 1 } } + \seq_clear:N \l__hduthesis_signature_figure_seq + } + { + \seq_set_split:Nne \l__hduthesis_signature_date_seq {-} + { \seq_item:Nn \l__hduthesis_signature_figure_seq {2} } + \seq_item:Nn \l__hduthesis_signature_date_seq {#3} + \seq_clear:N \l__hduthesis_signature_date_seq + } + \clist_clear:N \l__hduthesis_signature_process_clist + } +\end{minted} + +定义插入签名图片的命令 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \NewDocumentCommand \signature { m } + { + \leavevmode@ifvmode + \lower \dimexpr \f@size\p@ * 9/16 + \hbox { \includegraphics [ height = { \fp_eval:n {2*\f@size}\p@ } ] {#1} } + } +\end{minted} + +结束模块 \file{hduthesis-layout-module.code} 文件 +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \endinput +\end{minted} diff --git a/macros/xetex/latex/hduthesis/doc/cha/source/a4.tex b/macros/xetex/latex/hduthesis/doc/cha/source/a4.tex new file mode 100644 index 0000000000..e6f25c28e8 --- /dev/null +++ b/macros/xetex/latex/hduthesis/doc/cha/source/a4.tex @@ -0,0 +1,4 @@ +\subsection{\file{hduthesis-bc.config-module.code} 的实现} + +\cmd{bc.config} 模块实现的过程略,主要是对前面定义的命令进行调用,并通过 \cs{ctexset} +或对标准文档类 \cls{report} 中的命令进行重定义.
\ No newline at end of file diff --git a/macros/xetex/latex/hduthesis/doc/cha/source/a5.tex b/macros/xetex/latex/hduthesis/doc/cha/source/a5.tex new file mode 100644 index 0000000000..a23e800966 --- /dev/null +++ b/macros/xetex/latex/hduthesis/doc/cha/source/a5.tex @@ -0,0 +1,4 @@ +\subsection{\file{hduthesis-pg.config-module.code} 的实现} + +\cmd{pg.config} 模块实现的过程略,主要是对前面定义的命令进行调用,并通过 \cs{ctexset} +或对标准文档类 \cls{report} 中的命令进行重定义.
\ No newline at end of file diff --git a/macros/xetex/latex/hduthesis/doc/cha/source/a6.tex b/macros/xetex/latex/hduthesis/doc/cha/source/a6.tex new file mode 100644 index 0000000000..7efec03fbb --- /dev/null +++ b/macros/xetex/latex/hduthesis/doc/cha/source/a6.tex @@ -0,0 +1,28 @@ +\subsection{\file{hduthesis-hdu.l3doc-module.code} 的实现} + +模块 \file{hdu.l3doc} 的代码实现与之前类似,唯独不同的是添加了两个 \cs{hologo}: + +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \def \HoLogo@hduThesiS #1 + { + \raisebox{-.5pt} + { + \HOLOGO@mbox + { + \tikz [ baseline = (hduthesis.base) ] + { + \node [ inner~sep = 0pt ] (hduthesis) + {\scshape \sffamily hduThesi\scalebox{1.2}[1.2]{S}}; + \draw let \p1 = (hduthesis.west), \p2 = (hduthesis.east) + in (\x1,\y1) (\x2,\y2) [ line~width = {.028pt * (\x2 - \x1)} ] + ([yshift = -.5ex]hduthesis.north~west) to[ bend~right = 5 ] + ([yshift = .25ex]hduthesis.north~east); + } + } + } + } + \def \HoLogo@hduthesis #1 + { \raisebox{-.5pt} { \HOLOGO@mbox { \scshape \cls{hduThesiS} } } } +\end{minted} + +前者 \hologo{hduThesiS} 使用在本用户手册封面中,将字母 \textsf{S} 放大 1.2 倍,并使用 \pkg{tikz} 绘制一条搭在字母 \textsf{T} 上的曲线. 后者 \hologo{hduthesis} 则单纯地使用无衬线且缩小的大写字体.
\ No newline at end of file diff --git a/macros/xetex/latex/hduthesis/doc/cha/source/a7.tex b/macros/xetex/latex/hduthesis/doc/cha/source/a7.tex new file mode 100644 index 0000000000..a1d38534b2 --- /dev/null +++ b/macros/xetex/latex/hduthesis/doc/cha/source/a7.tex @@ -0,0 +1,35 @@ +\subsection{\file{hduthesis-hdu.stationery-module.code} 的实现} + +模块 \file{stationery} 的代码实现与之前类似. 不同的部分有使用钩子 \cmd{shipout} 来实现水印的添加 + +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \DeclareHookRule { shipout / background } { hduthesis / stationery } + { before } { pgfrcs } + \AddToHook { shipout / background } [ hduthesis / stationery ] + { + \bool_if:NT \g__docinfo_watermark_bool + { + \tikz [ remember~picture, overlay ] + \node [ opacity = .2 ] at (current~page) + { \includegraphics [ width = .4\linewidth ] {hdulogo} }; + } + } +\end{minted} + +调用 \pkg{tikzpagenodes} 宏包用于定位版心的边缘,用循环句柄 \cs{int_step_inline:nn} 与 \cs{draw} 命令来实现横线的绘制. + +\begin{minted} [ linenos, firstnumber = last, bgcolor = bg, breaklines ] {tex} + \RequirePackage{tikzpagenodes} + \NewDocumentCommand \notelines {O{20}} + { + \tikz [ remember~picture, overlay ] + { + \int_step_inline:nn { #1 - 1 } + { + \draw [ hdu, very~thick, opacity = .6 ] + ([yshift = -##1 * (\textheight + .6in - 15.87pt ) / #1 + .3in] + current~page~text~area.north~west) --++ (\linewidth, 0); + } + } + } +\end{minted} |