Skip to content

Commit

Permalink
Merge pull request #214 from BITNP/209-bibtex
Browse files Browse the repository at this point in the history
feat: Add a quirks mode (disabled by default) to support BIT's unique format.
  • Loading branch information
fky2015 committed Feb 1, 2023
2 parents 29b196d + e5690e6 commit 19709ca
Show file tree
Hide file tree
Showing 8 changed files with 469 additions and 36 deletions.
1 change: 1 addition & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[default.extend-words]
ist = "ist"
acn = "acn"
usera = "usera"

[files]
extend-exclude = ["CHANGELOG.md"]
111 changes: 111 additions & 0 deletions bithesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,29 @@
% 此选项用于输出符合盲审要求的论文。所有可能暴露个人信息的页面都将隐藏,
% 比如封面、信息页、原创性声明、个人简介、致谢等等。
% \end{function}
%
% \begin{function}{quirks}
% \begin{bitsyntax}[emph={[1]quirks}]
% quirks = (*<(false)|true>*)
% \end{bitsyntax}
%
% 此选项用于开启针对北理工官方示例的兼容模式。
%
% 具体包括:
% \begin{itemize}
% \item \pkg{biblatex} 中的 |patent| 类型将不再采用国标 GB/T 7714-2015 的格式,
% 而是采用北理工官方示例的格式。
% \end{itemize}
%
% 之所以需要此选项,是因为北理工官方示例中的格式
% 与国标 GB/T 7714-2015 中的格式不一致;
% 而这部分改动可能引入潜在的兼容性问题。
% 而这些差异其实比较细微,所以我们将其作为一个默认不开启的选项。
%
% 在未来,如果持续有用户反馈问题,亦或是没有边界问题,
% ,我们可能会将其中的功能移入默认效果中。
%
% \end{function}
%
% \begin{function}{twoside}
% \begin{bitsyntax}[emph={[1]twoside}]
Expand Down Expand Up @@ -1673,6 +1696,17 @@
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{\g_@@_quirks_mode_bool}
% 是否兼容更符合北理工官方模板或规范,但不太符合一般排版要求的模式。默认为 false。
% 目前此选项包括:
% \begin{itemize}
% \item \pkg{biblatex} 的专利格式不再使用国标格式,而采用北理工自定义格式。
% \end{itemize}
% \begin{macrocode}
\bool_new:N \g_@@_quirks_mode_bool
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{\g_@@_label_divide_char_tl}
% 用于分隔标签的字符。默认为「-」或者「.」。
% \begin{macrocode}
Expand Down Expand Up @@ -2027,6 +2061,7 @@
twoside .bool_gset:N = \g_@@_twoside_bool,
blindPeerReview .bool_gset:N = \g_@@_blind_mode_bool,
ctex .tl_set:N = \l_@@_options_to_ctex_tl,
quirks .bool_gset:N = \g_@@_quirks_mode_bool,
}
% \end{macrocode}
%
Expand Down Expand Up @@ -2351,6 +2386,82 @@
\cs_if_exist:NT \DeclareBibliographyCategory {
\DeclareBibliographyCategory{mypub}
}

% 修改 biblatex 中「专利」(patent)部分的著录格式。
% 主要根据北理工自定义的规范,参考 biblatex 和
% biblatex-gb7714-2015 的实现修改而成。
%
% 默认不开启,因为此修改可能会产生其他边界问题。
\bool_if:NT \g_@@_quirks_mode_bool {
\cs_if_exist:NT \DeclareBibliographyDriver {
%
% 重设专利title的输出,将文献类型标识符输出出去
%
\newbibmacro*{patenttitle}{%原输出来自biblatex.def文件
\ifboolexpr{%
test{\iffieldundef{title}}%
and%
test{\iffieldundef{subtitle}}%
}%
{}%
{\printtext[title]{\bibtitlefont%
\printfield[titlecase]{title}%
\ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题
{}{\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}%
\iftoggle{bbx:gbtype}{\printfield[gbtypeflag]{usera}}{}%
\iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格
{\setunit{\subtitlepunct}\printfield{titleaddon}}%
% :地区
\setunit{\subtitlepunct}\iflistundef{location}
{}
{\setunit*{\subtitlepunct}%
\printtext{%[parens]
\printlist[][-\value{listtotal}]{location}}}%
% ,专利号
\setunit{\addcomma\addspace}\printfield{number}%写专利号
\setunit{\addcomma\addspace}
\usebibmacro{newsdate}%
}%
}%
}

%
% 重定义专利文献驱动
%
\DeclareBibliographyDriver{patent}{%源来自standard.BBX
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
\usebibmacro{patenttitle}%给出专利专用的标题输出
\iftoggle{bbx:gbstrict}{}{%
\newunit%
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}
}%
\newunit\newblock
\printfield{type}%
\setunit*{\addspace}%
\newunit\newblock
\usebibmacro{byholder}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{annotation}\usebibmacro{finentry}}
}
}
}
% \end{macrocode}
%
Expand Down
78 changes: 78 additions & 0 deletions templates/graduate-thesis/bithesis.cls
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
\bool_new:N \g__bithesis_twoside_bool
\bool_new:N \g__bithesis_thesis_type_english_bool
\bool_new:N \g__bithesis_blind_mode_bool
\bool_new:N \g__bithesis_quirks_mode_bool
\tl_new:N \g__bithesis_label_divide_char_tl
\seq_new:N \l__bithesis_right_seq
\seq_new:N \l__bithesis_left_seq
Expand Down Expand Up @@ -259,6 +260,7 @@
twoside .bool_gset:N = \g__bithesis_twoside_bool,
blindPeerReview .bool_gset:N = \g__bithesis_blind_mode_bool,
ctex .tl_set:N = \l__bithesis_options_to_ctex_tl,
quirks .bool_gset:N = \g__bithesis_quirks_mode_bool,
}
\keys_define:nn { bithesis / cover }
{
Expand Down Expand Up @@ -499,6 +501,82 @@
\cs_if_exist:NT \DeclareBibliographyCategory {
\DeclareBibliographyCategory{mypub}
}

% 修改 biblatex 中「专利」(patent)部分的著录格式。
% 主要根据北理工自定义的规范,参考 biblatex 和
% biblatex-gb7714-2015 的实现修改而成。
%
% 默认不开启,因为此修改可能会产生其他边界问题。
\bool_if:NT \g__bithesis_quirks_mode_bool {
\cs_if_exist:NT \DeclareBibliographyDriver {
%
% 重设专利title的输出,将文献类型标识符输出出去
%
\newbibmacro*{patenttitle}{%原输出来自biblatex.def文件
\ifboolexpr{%
test{\iffieldundef{title}}%
and%
test{\iffieldundef{subtitle}}%
}%
{}%
{\printtext[title]{\bibtitlefont%
\printfield[titlecase]{title}%
\ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题
{}{\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}%
\iftoggle{bbx:gbtype}{\printfield[gbtypeflag]{usera}}{}%
\iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格
{\setunit{\subtitlepunct}\printfield{titleaddon}}%
% :地区
\setunit{\subtitlepunct}\iflistundef{location}
{}
{\setunit*{\subtitlepunct}%
\printtext{%[parens]
\printlist[][-\value{listtotal}]{location}}}%
% ,专利号
\setunit{\addcomma\addspace}\printfield{number}%写专利号
\setunit{\addcomma\addspace}
\usebibmacro{newsdate}%
}%
}%
}

%
% 重定义专利文献驱动
%
\DeclareBibliographyDriver{patent}{%源来自standard.BBX
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
\usebibmacro{patenttitle}%给出专利专用的标题输出
\iftoggle{bbx:gbstrict}{}{%
\newunit%
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}
}%
\newunit\newblock
\printfield{type}%
\setunit*{\addspace}%
\newunit\newblock
\usebibmacro{byholder}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{annotation}\usebibmacro{finentry}}
}
}
}
\cs_new:Npn \xihei:n #1 {
\xeCJK_family_if_exist:nTF {xihei} {
Expand Down
2 changes: 2 additions & 0 deletions templates/graduate-thesis/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
% 博士论文模板 type=doctor
% 开启盲审格式 blindPeerReview=true (如:[type=master,blindPeerReview=true])
% 开启双面打印 twoside=true (如:[type=master,twoside=true])
%
% **更多使用说明请参考 bithesis.pdf **

\documentclass[type=master]{bithesis}

Expand Down
79 changes: 43 additions & 36 deletions templates/graduate-thesis/reference/main.bib
Original file line number Diff line number Diff line change
Expand Up @@ -17,54 +17,61 @@
@article{Jiang2005Size,
title={形状记忆聚合物研究现状与发展},
author={姜敏 and 彭少贤 and 郦华兴},
journal={现代塑料加工应用},
volume={17},
number={2},
pages={53-56},
year={2005},
title = {形状记忆聚合物研究现状与发展},
author = {姜敏 and 彭少贤 and 郦华兴},
journal = {现代塑料加工应用},
volume = {17},
number = {2},
pages = {53-56},
year = {2005},
}

@article{Takahashi1996Structure,
title={Structure and properties of {shape-memory} polyurethane block copolymers},
author={Takahashi, Toshisada and Hayashi, Noriya and Hayashi, Shunichi},
journal={Journal of Applied Polymer Science},
volume={60},
number={7},
pages={1061-1069},
year={1996},
title = {Structure and properties of {shape-memory} polyurethane block
copolymers},
author = {Takahashi, Toshisada and Hayashi, Noriya and Hayashi, Shunichi},
journal = {Journal of Applied Polymer Science},
volume = {60},
number = {7},
pages = {1061-1069},
year = {1996},
}

@inproceedings{Xia2002Analysis,
title={Analysis of Affective Characteristics and Evaluation of Harmonious Feeling of Image Based on 1/f Fluctuation Theory},
author={Xia, Mao and Chen, Bin and Gang, Zhu and Itsya, Muta},
booktitle={Developments in Applied Artificial Intelligence, International Conference on Industrial and Engineering, Applications of Artificial Intelligence and Expert Systems, Iea/aie 2002, Cairns, Australia, June 17-20, 2002, Proceedings},
pages={780-789},
year={2002},
title = {Analysis of Affective Characteristics and Evaluation of Harmonious
Feeling of Image Based on 1/f Fluctuation Theory},
author = {Xia, Mao and Chen, Bin and Gang, Zhu and Itsya, Muta},
booktitle = {Developments in Applied Artificial Intelligence, International
Conference on Industrial and Engineering, Applications of
Artificial Intelligence and Expert Systems, Iea/aie 2002, Cairns,
Australia, June 17-20, 2002, Proceedings},
pages = {780-789},
year = {2002},
}

@misc{Jiang1989,
title={一种温热外敷药的制备方法},
author={姜锡洲},
year={1989},
@patent{Jiang1989,
title = {一种温热外敷药的制备方法},
author = {姜锡洲},
location = {中国},
number = {881056078},
year = {1983-08-12},
}

@article{Mao2000Motion,
title={情感工学破解"舒服"之谜},
author={毛峡},
journal={科技文萃},
number={7},
pages={157-158},
year={2000},
title = {情感工学破解"舒服"之谜},
author = {毛峡},
journal = {科技文萃},
number = {7},
pages = {157-158},
year = {2000},
}

@article{Feng1998,
title={核反应堆管道和压力容器的LBB分析},
author={冯西桥 and 何树延},
journal={力学进展},
volume={28},
number={2},
pages={198-217},
year={1998},
title = {核反应堆管道和压力容器的LBB分析},
author = {冯西桥 and 何树延},
journal = {力学进展},
volume = {28},
number = {2},
pages = {198-217},
year = {1998},
}
Loading

0 comments on commit 19709ca

Please sign in to comment.