Skip to content

Commit

Permalink
refactor!: merge environment options to setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
fky2015 committed Jul 30, 2022
1 parent 7421bc3 commit 3b0fbac
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 286 deletions.
116 changes: 59 additions & 57 deletions bithesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,8 @@
cover .meta:nn = { bithesis / cover } {#1},
style .meta:nn = { bithesis / style } {#1},
option .meta:nn = { bithesis / option } {#1},
TOC .meta:nn = { bithesis / TOC } {#1},
appendices .meta:nn = { bithesis / appendices } {#1},
}

\keys_define:nn { bithesis / option }
Expand Down Expand Up @@ -1261,7 +1263,24 @@
{4} {北京理工大学硕士学位论文}
{5} {北京理工大学博士学位论文}
}
}
},
}

\keys_define:nn { bithesis / TOC }
{
abstract .bool_set:N = \l_@@_add_abstract_to_toc_bool,
abstract .initial:n = {true},
abstractEn .bool_set:N = \l_@@_add_abstract_en_to_toc_bool,
abstractEn .initial:n = {true},
symbols .bool_set:N = \l_@@_add_symbols_to_toc_bool,
symbols .initial:n = {true},
}

\keys_define:nn { bithesis / appendices }
{
chapterLevel .bool_set:N = \l_@@_appendices_chapter_level_bool,
title .tl_set:N = \l_@@_appendices_title_tl,
TOCTitle .tl_set:N = \l_@@_appendix_toc_title_tl,
}

\ProcessKeysOptions { bithesis / option }
Expand Down Expand Up @@ -1481,39 +1500,38 @@
{\thecontentslabel\hspace{\ccwd}}{}
{\hspace{.5em}\titlerule*{.}\contentspage}


\bool_new:N \l_@@_add_to_toc_bool
\bool_set_true:N \l_@@_add_to_toc_bool

\keys_define:nn { bit }
{
abstract .meta:nn = { bit / abstract } {#1},
abstract_en .meta:nn = { bit / abstract_en } {#1},
symbols .meta:nn = { bit / symbols } {#1},
appendices .meta:nn = { bit / appendices } {#1},
}

\keys_define:nn { bit / abstract }
{
addTOC .bool_set:N = \l_@@_add_to_toc_bool,
}

\keys_define:nn { bit / abstract_en }
{
addTOC .bool_set:N = \l_@@_add_to_toc_bool,
}

\keys_define:nn { bit / symbols }
{
addTOC .bool_set:N = \l_@@_add_to_toc_bool,
}

\keys_define:nn { bit / appendices }
{
chapterLevel .bool_set:N = \l_@@_appendices_chapter_level_bool,
title .tl_set:N = \l_@@_appendices_title_tl,
TOCTitle .tl_set:N = \l_@@_appendix_toc_title_tl,
}
% \bool_new:N \l_@@_add_to_toc_bool
% \bool_set_true:N \l_@@_add_to_toc_bool
%
% \keys_define:nn { bit }
% {
% abstract .meta:nn = { bit / abstract } {#1},
% abstract_en .meta:nn = { bit / abstract_en } {#1},
% symbols .meta:nn = { bit / symbols } {#1},
% appendices .meta:nn = { bit / appendices } {#1},
% }
%
% \keys_define:nn { bit / abstract }
% {
% addTOC .bool_set:N = \l_@@_add_to_toc_bool,
% }
%
% \keys_define:nn { bit / abstract_en }
% {
% addTOC .bool_set:N = \l_@@_add_to_toc_bool,
% }
%
% \keys_define:nn { bit / symbols }
% {
% addTOC .bool_set:N = \l_@@_add_to_toc_bool,
% }
%
% \keys_define:nn { bit / appendices }
% {
% chapterLevel .bool_set:N = \l_@@_appendices_chapter_level_bool,
% title .tl_set:N = \l_@@_appendices_title_tl,
% TOCTitle .tl_set:N = \l_@@_appendix_toc_title_tl,
% }

\RenewDocumentCommand \frontmatter {} {

Expand Down Expand Up @@ -2332,13 +2350,9 @@
}

% TODO:
\NewDocumentEnvironment {abstract} {o}
\NewDocumentEnvironment {abstract} {}
{

\IfValueT {#1} {
\keys_set:nn { bit / abstract } {#1}
}

\cleardoublepage
\setstretch{1.53}

Expand Down Expand Up @@ -2370,7 +2384,7 @@

{
\@@_same_page:
\bool_if:NTF \l_@@_add_to_toc_bool {
\bool_if:NTF \l_@@_add_abstract_to_toc_bool {
\chapter{\c_@@_label_abstract_tl}
} {
\chapter*{\c_@@_label_abstract_tl}
Expand All @@ -2385,12 +2399,8 @@
\newpage
}

\NewDocumentEnvironment {abstractEn} {o}
\NewDocumentEnvironment {abstractEn} {}
{
\IfValueT {#1} {
\keys_set:nn { bit / abstract_en } {#1}
}

\cleardoublepage
\setstretch{1.53}

Expand Down Expand Up @@ -2435,7 +2445,7 @@

{
\@@_same_page:
\bool_if:nTF {\l_@@_add_to_toc_bool} {
\bool_if:nTF {\l_@@_add_abstract_en_to_toc_bool} {
\chapter{\c_@@_label_abstract_en_tl}
} {
\chapter*{\c_@@_label_abstract_en_tl}
Expand Down Expand Up @@ -2494,12 +2504,8 @@

% #1: The name that used as chapter title
% #2: The name that used in ToC.
\NewDocumentEnvironment {appendices} {o}
\NewDocumentEnvironment {appendices} {}
{
\IfValueT {#1} {
\keys_set:nn { bit / appendices } {#1}
}

% Used in chapter, ToC.
\tl_new:N \l_@@_appendix_plain_label_tl
% Used before reference label.
Expand Down Expand Up @@ -2616,13 +2622,9 @@
{
}

\NewDocumentEnvironment {symbols} {o}
\NewDocumentEnvironment {symbols} {}
{
\IfValueT {#1} {
\keys_set:nn { bit / symbols } {#1}
}

\bool_if:NTF \l_@@_add_to_toc_bool {
\bool_if:NTF \l_@@_add_symbols_to_toc_bool {
\chapter{\c_@@_label_symbols_tl}
} {
\chapter*{\c_@@_label_symbols_tl}
Expand Down
83 changes: 27 additions & 56 deletions templates/graduate-thesis/bithesis.cls
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@
cover .meta:nn = { bithesis / cover } {#1},
style .meta:nn = { bithesis / style } {#1},
option .meta:nn = { bithesis / option } {#1},
TOC .meta:nn = { bithesis / TOC } {#1},
appendices .meta:nn = { bithesis / appendices } {#1},
}

\keys_define:nn { bithesis / option }
Expand Down Expand Up @@ -301,7 +303,24 @@
{4} {北京理工大学硕士学位论文}
{5} {北京理工大学博士学位论文}
}
}
},
}

\keys_define:nn { bithesis / TOC }
{
abstract .bool_set:N = \l__bithesis_add_abstract_to_toc_bool,
abstract .initial:n = {true},
abstractEn .bool_set:N = \l__bithesis_add_abstract_en_to_toc_bool,
abstractEn .initial:n = {true},
symbols .bool_set:N = \l__bithesis_add_symbols_to_toc_bool,
symbols .initial:n = {true},
}

\keys_define:nn { bithesis / appendices }
{
chapterLevel .bool_set:N = \l__bithesis_appendices_chapter_level_bool,
title .tl_set:N = \l__bithesis_appendices_title_tl,
TOCTitle .tl_set:N = \l__bithesis_appendix_toc_title_tl,
}

\ProcessKeysOptions { bithesis / option }
Expand Down Expand Up @@ -513,38 +532,6 @@
{\thecontentslabel\hspace{\ccwd}}{}
{\hspace{.5em}\titlerule*{.}\contentspage}

\bool_new:N \l__bithesis_add_to_toc_bool
\bool_set_true:N \l__bithesis_add_to_toc_bool

\keys_define:nn { bit }
{
abstract .meta:nn = { bit / abstract } {#1},
abstract_en .meta:nn = { bit / abstract_en } {#1},
symbols .meta:nn = { bit / symbols } {#1},
appendices .meta:nn = { bit / appendices } {#1},
}

\keys_define:nn { bit / abstract }
{
addTOC .bool_set:N = \l__bithesis_add_to_toc_bool,
}

\keys_define:nn { bit / abstract_en }
{
addTOC .bool_set:N = \l__bithesis_add_to_toc_bool,
}

\keys_define:nn { bit / symbols }
{
addTOC .bool_set:N = \l__bithesis_add_to_toc_bool,
}

\keys_define:nn { bit / appendices }
{
chapterLevel .bool_set:N = \l__bithesis_appendices_chapter_level_bool,
title .tl_set:N = \l__bithesis_appendices_title_tl,
TOCTitle .tl_set:N = \l__bithesis_appendix_toc_title_tl,
}

\RenewDocumentCommand \frontmatter {} {

Expand Down Expand Up @@ -1337,13 +1324,9 @@
}

% TODO:
\NewDocumentEnvironment {abstract} {o}
\NewDocumentEnvironment {abstract} {}
{

\IfValueT {#1} {
\keys_set:nn { bit / abstract } {#1}
}

\cleardoublepage
\setstretch{1.53}

Expand Down Expand Up @@ -1375,7 +1358,7 @@

{
\__bithesis_same_page:
\bool_if:NTF \l__bithesis_add_to_toc_bool {
\bool_if:NTF \l__bithesis_add_abstract_to_toc_bool {
\chapter{\c__bithesis_label_abstract_tl}
} {
\chapter*{\c__bithesis_label_abstract_tl}
Expand All @@ -1390,12 +1373,8 @@
\newpage
}

\NewDocumentEnvironment {abstractEn} {o}
\NewDocumentEnvironment {abstractEn} {}
{
\IfValueT {#1} {
\keys_set:nn { bit / abstract_en } {#1}
}

\cleardoublepage
\setstretch{1.53}

Expand Down Expand Up @@ -1440,7 +1419,7 @@

{
\__bithesis_same_page:
\bool_if:nTF {\l__bithesis_add_to_toc_bool} {
\bool_if:nTF {\l__bithesis_add_abstract_en_to_toc_bool} {
\chapter{\c__bithesis_label_abstract_en_tl}
} {
\chapter*{\c__bithesis_label_abstract_en_tl}
Expand Down Expand Up @@ -1497,12 +1476,8 @@

% #1: The name that used as chapter title
% #2: The name that used in ToC.
\NewDocumentEnvironment {appendices} {o}
\NewDocumentEnvironment {appendices} {}
{
\IfValueT {#1} {
\keys_set:nn { bit / appendices } {#1}
}

% Used in chapter, ToC.
\tl_new:N \l__bithesis_appendix_plain_label_tl
% Used before reference label.
Expand Down Expand Up @@ -1619,13 +1594,9 @@
{
}

\NewDocumentEnvironment {symbols} {o}
\NewDocumentEnvironment {symbols} {}
{
\IfValueT {#1} {
\keys_set:nn { bit / symbols } {#1}
}

\bool_if:NTF \l__bithesis_add_to_toc_bool {
\bool_if:NTF \l__bithesis_add_symbols_to_toc_bool {
\chapter{\c__bithesis_label_symbols_tl}
} {
\chapter*{\c__bithesis_label_symbols_tl}
Expand Down
4 changes: 2 additions & 2 deletions templates/graduate-thesis/chapters/abstract.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
%
% The Current Maintainer of this work is Feng Kaiyu.

\begin{abstract}[addTOC=false]
\begin{abstract}
本文......。
\textcolor{blue}{(摘要是一篇具有独立性和完整性的短文,应概括而扼要地反映出本论文的主要内容。包括研究目的、研究方法、研究结果和结论等,特别要突出研究结果和结论。中文摘要力求语言精炼准确,博士学位论文建议1000~1200字,硕士学位论文摘要建议500~800字。摘要中不可出现参考文献、图、表、化学结构式、非公知公用的符号和术语。英文摘要与中文摘要的内容应完全一致,在语法、用词上应准确无误,语言简练通顺。留学生的英文版博士学位论文中应有不少于3000字的“详细中文摘要”。)}
\end{abstract}

\begin{abstractEn}[addTOC=false]
\begin{abstractEn}
In order to exploit.......
\end{abstractEn}
10 changes: 9 additions & 1 deletion templates/graduate-thesis/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@
keywordsEn = shape memory properties; polyurethane; textile; synthesis; application,
% 必要时置于封面右上角,并按照国家规定进行标记。
% classifiedLevel = 密级 $\bigstar$ 保密期限,
}
},
% 在目录页中不显示摘要和主要符号对照表的标题。
TOC = {
abstract = false,
abstractEn = false,
symbols = false,
},
% 采用章节标题级别的附录格式
appendices / chapterLevel = true,
}

\usepackage[
Expand Down
2 changes: 1 addition & 1 deletion templates/graduate-thesis/misc/0_symbols.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
%
% The Current Maintainer of this work is Feng Kaiyu.

\begin{symbols}[addTOC=false]
\begin{symbols}
\item[BIT] 北京理工大学的英文缩写
\item[\LaTeX] 一个很棒的排版系统
\item[\LaTeXe] 一个很棒的排版系统的最新稳定版
Expand Down
2 changes: 1 addition & 1 deletion templates/graduate-thesis/misc/3_appendices.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
%
% The Current Maintainer of this work is Feng Kaiyu.

\begin{appendices}[chapterLevel=true]
\begin{appendices}
\chapter{费马大定理的证明}
关于此,我确信已发现了一种美妙的证法,可惜这里空白的地方太小,写不下。

Expand Down
Loading

0 comments on commit 3b0fbac

Please sign in to comment.