Skip to content
Snippets Groups Projects
Commit 3ddf9609 authored by Yu Xiong's avatar Yu Xiong :confounded:
Browse files

feat: 给专有命令加上了宏集前缀,简化了自定义字体的表达式

parent c1cd3bdb
No related branches found
No related tags found
No related merge requests found
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{njuthesis}
\ProvidesClass{njuthesis}[2021/09/10 NJU Thesis Undergraduate LaTeX Template]
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
family=njuthesis,
prefix=,% 故意留空防止出现大量@,但估计要发布CTAN还得加回
prefix=nju@,% 故意留空防止出现大量@,但估计要发布CTAN还得加回nju@。
setkeys=\kvsetkeys
}
......@@ -20,12 +20,12 @@
zihao=-4
]{ctexbook}[2018/04/01]
\DeclareStringOption[1]{TitleLength}
\DeclareStringOption[UG]{Degree}
\DeclareStringOption[thesis]{Type}
\DeclareBoolOption[true]{UseSysFont}
\DeclareStringOption[windows]{CustomEnFont}
\DeclareStringOption[windows]{CustomZhFont}
\DeclareStringOption[1]{titlelength}
\DeclareStringOption[UG]{degree}
\DeclareStringOption[thesis]{type}
\DeclareBoolOption[true]{systemfont}
\DeclareStringOption[windows]{customlatinfont}
\DeclareStringOption[windows]{customchinesefont}
\ProcessKeyvalOptions*\relax
......
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NJU Thesis Undergraduate
% 南京大学本科生毕业论文LaTeX模板
% Version 0.4.0 (2021-09-10)
% Version 0.4.1 (2021-09-10)
%
% 请关注项目地址以获取最新变化
% https://github.com/nju-lug/NJUThesisUndergraduate
......@@ -16,12 +16,12 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[
TitleLength=2,% 选择标题行数,范围是1~3
Degree=UG,% UG: 本科
Type=thesis,% thesis: 毕业论文,design: 毕业设计
% UseSysFont=false,% 自定义字体请反注释此项
% CustomEnFont=windows,% 设置英文字符集
% CustomZhFont=windows,% 设置中文字符集
titlelength=2,% 选择标题行数,范围是1~3
% degree=UG,% UG: 本科
type=thesis,% thesis: 毕业论文,design: 毕业设计
systemfont=false,% 自定义字体请反注释此项
customlatinfont=windows,% 设置英文字符集
customchinesefont=windows,% 设置中文字符集
]{njuthesis}
% 输入个人信息
......
......@@ -41,7 +41,7 @@
\coverbox:n {\hfill}
& \cover_underline:nn {250pt}{\songti\Major}\\
\int_case:nn {\TitleLength}
\int_case:nn {\nju@titlelength}
{
{ 1 } {
\coverbox:n {\hfill}
......@@ -91,10 +91,10 @@
}
% 判断类型
\str_if_eq:eeTF {\Degree} {UG}
\str_if_eq:eeTF {\nju@degree} {UG}
{\tl_const:Nn \Degreename {\hfill\hfill }}{}
\str_if_eq:eeTF {\Type} {thesis}
\str_if_eq:eeTF {\nju@type} {thesis}
{\tl_const:Nn \typename {\Degreename\hfill\hfill\hfill}}
{\tl_const:Nn \typename {\Degreename\hfill\hfill\hfill}}
......
......@@ -152,7 +152,7 @@
}
% 根据操作系统选择相应字体
\ifUseSysFont
\ifnju@systemfont
% 检测是否是 Windows
\sys_if_platform_windows:TF
{
......@@ -173,29 +173,22 @@
}
}
\else% 如果用户需要自定义
% tl_case:Nn 只能实现宏和宏之间的比较,不能直接实现字符串和宏的比较,无奈出此下策,希望之后能找到更优雅的写法
\tl_const:Nn \usingwindows {windows}
\tl_const:Nn \usingmacos {macos}
\tl_const:Nn \usingfandol {fandol}
\tl_const:Nn \usinggyre {gyre}
\tl_const:Nn \usingfounder {founder}
\tl_const:Nn \usingnoto {noto}
\tl_const:Nn \usingnull {null}
\tl_case:Nn {\CustomEnFont}
% 此处需要使用\str_case_e而不是\str_case使宏展开为字符串
\str_case_e:nn { \nju@customlatinfont }
{
\usingwindows{\set_latin_fontset_windows}
\usingmacos{\set_latin_fontset_macos}
\usinggyre{\set_latin_fontset_gyre}
\usingnull{}
{ windows } { \set_latin_fontset_windows }
{ macos} { \set_latin_fontset_macos }
{ gyre } { \set_latin_fontset_gyre }
{ null } {}
}
\tl_case:Nn {\CustomZhFont}
\str_case_e:nn { \nju@customchinesefont }
{
\usingwindows{\set_chinese_fontset_windows}
\usingmacos{\set_chinese_fontset_macos}
\usingfandol{\set_chinese_fontset_fandol}
\usingfounder{\set_chinese_fontset_founder}% 使用方正字体
\usingnoto{\set_chinese_fontset_noto}% 使用思源宋体+思源黑体
\usingnull{}
{ windows } { \set_chinese_fontset_windows }
{ macos} { \set_chinese_fontset_macos }
{ gyre } { \set_chinese_fontset_gyre }
{ founder } { \set_chinese_fontset_founder }
{ noto } { \set_chinese_fontset_noto }
{ null } {}
}
\fi
% 我是 Linux 用户,但我用 Windows 字体(请您赶快坐到主席台上来)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment