Skip to content

Commit

Permalink
feat: 给专有命令加上了宏集前缀,简化了自定义字体的表达式
Browse files Browse the repository at this point in the history
  • Loading branch information
atxy-blip committed Sep 10, 2021
1 parent c1cd3bd commit 3ddf960
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 39 deletions.
16 changes: 8 additions & 8 deletions njuthesis.cls
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
\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
}

Expand All @@ -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

Expand Down
14 changes: 7 additions & 7 deletions njuthesis.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NJU Thesis Undergraduate
% 南京大学本科生毕业论文LaTeX模板
% Version 0.4.0 (2021-09-10)
% Version 0.4.1 (2021-09-10)
%
% 请关注项目地址以获取最新变化
% https://github.com/nju-lug/NJUThesisUndergraduate
Expand All @@ -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}

% 输入个人信息
Expand Down
6 changes: 3 additions & 3 deletions profile/cover.sty
Original file line number Diff line number Diff line change
Expand Up @@ -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 目}
Expand Down Expand Up @@ -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 计}}

Expand Down
35 changes: 14 additions & 21 deletions profile/font.sty
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
}

% 根据操作系统选择相应字体
\ifUseSysFont
\ifnju@systemfont
% 检测是否是 Windows
\sys_if_platform_windows:TF
{
Expand All @@ -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 字体(请您赶快坐到主席台上来)
Expand Down

0 comments on commit 3ddf960

Please sign in to comment.