Skip to content

Commit

Permalink
Provide More Bibliography Utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddy-van-Jerry committed Feb 24, 2024
1 parent 9fb8e2e commit 07a3e93
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 43 deletions.
101 changes: 101 additions & 0 deletions assets/bib_custom.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
% In this class, the default is to use sentence case for titles.
\bool_if:NF \l__seuthesis_bib_title_case_bool
{
\DeclareFieldFormat { sentencecase } { \MakeSentenceCase { #1 } }
% Modified based on
% https://github.com/hushidong/biblatex-gb7714-2015/blob/15db5aaf6834b2359c605227726c67d1350bc660/gb7714-2015.bbx#L3373-L3406
\renewbibmacro*{title}{%
\ifboolexpr{%
test{\iffieldundef{title}}%
and
test{\iffieldundef{subtitle}}}%
{}%
{
\printtext[title]{\bibtitlefont%增加字体控制命令
\printfield[sentencecase]{title}%
\ifboolexpr{test {\iffieldundef{subtitle}}}%增加了对子标题的判断
{}{\setunit{\subtitlepunct}\printfield[sentencecase]{subtitle}}%
\iffieldundef{titleaddon}{}{\setunit{\subtitlepunct}\printfield{titleaddon}}%判断一下titleaddon
\ifboolexpr{test{\ifentrytype{book}} and (not test{\iffieldundef{volume}})}%判断一下book类有没有volume
{\setunit{\subtitlepunct}\printfield{volume}}{}%
\iftoggle{bbx:gbtype}%
{\iffieldundef{entrysubtype}{\printfield[gbtypeflag]{usera}}%在标题后直接给出文献标识字母,判断一下,是否是报纸和标准
{\iffieldequalstr{entrysubtype}{standard}{\printfield[gbtypeflags]{usera}}%判断是否为标准
{\iffieldequalstr{entrysubtype}{news}{\printfield[gbtypeflagn]{usera}}%判断是否为报纸
{\printfield[gbtypeflag]{usera}}}}}{}%%其它
}%
}%
}
}
% arXiv settings (you need to export from arxiv.org instead of Google Scholar)
% Reference: https://github.com/hushidong/biblatex-gb7714-2015/blob/76f594bac2fa8c0c0e3582143bd1eedc1b17cc89/biblatex-gb7714-2015.tex#L2063-L2126
%自动添加一些信息
\newcommand \seuthesis@arxiv@urldate { 2024-03-01 } % default date
\AtEndPreamble
{
\DeclareStyleSourcemap{
\maps [ datatype = bibtex ]
{
\map [ overwrite ]
{
\pertype{misc}
\step[fieldsource=archivePrefix,match=arXiv,final]
\step[fieldset=usera,fieldvalue={EB}]
\step[fieldset=primaryClass,fieldvalue={}]
\step[fieldset=url,fieldvalue={https://arxiv.org/abs/}]
\step[fieldsource=eprint]
\step[fieldset=url,origfieldval, append]
\step[fieldset=urldate,fieldvalue={\seuthesis@arxiv@urldate}]
}
}
}

%添加更新日期
\renewbibmacro*{doi+eprint+url}{%
\iftoggle{bbx:eprint}
{\iffieldundef{eprint}{}{\newunit\usebibmacro{eprint}}}
{}%
\iffieldundef{eprinttype}{}%%注意:archivePrefix映射成了eprinttype
{\iffieldequalstr{eprinttype}{arXiv}%
{\mkbibparens{\usebibmacro{newsdate}}}{}}%
\iftoggle{bbx:url}
{\usebibmacro{url+urldate}}
{}
\newunit\newblock
\iftoggle{bbx:doi}
{\printfield{doi}}
{}}

%
% 备选类型驱动
%
% 利用biblatex的misc驱动
\DeclareBibliographyDriver{misc}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\ifnameundef{namea}{}{\setunit{\labelnamepunct}\newblock}%
\usebibmacro{title}%
\newunit\newblock
\printfield{howpublished}%
\newunit\newblock
\printfield{type}%
\newunit
\printfield{version}%
\newunit
\printfield{note}%
\newunit\newblock
\iffieldundef{eprinttype}{\usebibmacro{institution+location+date}}%
{}%注意:archivePrefix映射成了eprinttype
\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}}
}
30 changes: 28 additions & 2 deletions chapters/body.tex
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,44 @@ \section{参考文献}
硬件设计方面的研究包括:
高层级综合工具 FLAMES 库设计\cite{zhao2024flexible},
自动生成语言 AHDW\cite{zhao2023automatic}。

\name 的所有工作有\cite{zhao2023ompl,you2024beam,zhao2024flexible,zhao2023automatic}。

使用 \texttt{\string\cite} 的引用均为上标;
如果需要非上标,可以使用 \texttt{\string\parencite},例如 \parencite{zhao2023ompl}。
此模版额外提供了 \texttt{\string\Lcite} 和 \texttt{\string\YLcite} 命令,
可以实现作者引用、已经带年份的作者引用。
此外,注意 arXiv 文章自动使用 EB 类型,例如 \cite{kastner2018parallel},请使用 arXiv.org 直接导出 \texttt{@misc} 类型 bib
而不是谷歌学术的 \texttt{@article} 类型 bib。
arXiv 文章的访问时间(即 \texttt{urldate})均设置为 2024-03-01,
如果需要修改可以在导言区添加:
\begin{lstlisting}[language=tex, alsoletter={\\}, morekeywords={\\renewcommand,\\makeatletter,\\makeatother}]
\makeatletter
\renewcommand \seuthesis@arxiv@urldate {2024-04-01} % the date you want
\makeatother
\end{lstlisting}

所有使用效果如表~\ref{tab:cite_effect} 所示。
\begin{xltabular}{\linewidth}{lX}
\caption{引用效果示例} \label{tab:cite_effect} \\
\longTableHdr{命令 & 效果 \\}
\ttfamily 泰迪 \textcolor{Blue}{\string\cite}\{zhao2023ompl\} & 泰迪 \cite{zhao2023ompl} \\
\ttfamily 泰迪 \textcolor{Blue}{\string\cite}[Fig.\string~1]\{zhao2023ompl\} & 泰迪 \cite[Fig.~1]{zhao2023ompl} \\
\ttfamily 泰迪 \textcolor{Blue}{\string\cite}\{zhao2023ompl,you2023beam\} & 泰迪 \cite{zhao2023ompl,you2024beam} \\
\ttfamily 泰迪 \textcolor{Blue}{\string\parencite}\{zhao2023ompl\} & 泰迪 \parencite{zhao2023ompl} \\
\ttfamily \textcolor{Blue}{\string\Lcite}\{zhao2023ompl\} & \Lcite{zhao2023ompl} \\
\ttfamily \textcolor{Blue}{\string\Lcite}[软件]\{zhao2023ompl\} & \Lcite[软件]{zhao2024mmcesim} \\
\ttfamily \textcolor{Blue}{\string\Lcite}\{zhao2023ompl,you2023beam\} & \Lcite{zhao2023ompl,you2024beam} \\
\ttfamily \textcolor{Blue}{\string\Lcite}\{zhao2023ompl,you2023beam\}[哈哈哈哈] & \Lcite{zhao2023ompl,you2024beam}[哈哈哈哈] \\
\ttfamily \textcolor{Blue}{\string\Lcite}\{zhao2023ompl,you2023beam,\mbox{尤肖虎}20145g\} & \Lcite{zhao2023ompl,you2024beam,尤肖虎20145g} \\
\ttfamily \textcolor{Blue}{\string\YLcite}\{zhao2023ompl\} & \YLcite{zhao2023ompl} \\
\end{xltabular}

\subsection{分类别示例}\label{subsec:bib_types}
\textbf{期刊论文 [J]}:\parencite{zhao2023ompl,you2024beam,zhao2024flexible,尤肖虎20145g};
\textbf{会议论文 [C]}:\parencite{zhao2023automatic};
\textbf{计算机程序 [CP]}:\parencite{zhao2024mmcesim,zhao2024dg};
\textbf{标准 [S]}:\parencite{IEEE802.11ad};
\textbf{电子公告 [EB]}:\parencite{amd2023zcu111};
\textbf{电子公告 [EB]}:\parencite{amd2023zcu111,kastner2018parallel};
\textbf{普通图书 [M]}:\parencite{wong2017key};
\textbf{学位论文 [D]}:\parencite{wipf2006bayesian};
\textbf{报告 [R]}:\parencite{zhao2024dual}。% 此条目实际上按照 online 的格式处理
Expand Down
10 changes: 10 additions & 0 deletions ref/ref.bib
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ @inproceedings{zhao2023automatic
booktitle = {2023 {IEEE} 15th International Conference on {ASIC} ({ASICON})},
year = {2023},
month = oct,
location = {Nanjing, China},
publisher = {IEEE}
}

Expand Down Expand Up @@ -108,3 +109,12 @@ @report{zhao2024dual
urldate = {2024-02-16},
pages = {1--9}
}

@misc{kastner2018parallel,
title = {Parallel Programming for {FPGAs}},
author = {Ryan Kastner and Janarbek Matai and Stephen Neuendorffer},
year = {2018},
eprint = {1805.03648},
archiveprefix = {arXiv},
primaryclass = {cs.AR}
}
109 changes: 68 additions & 41 deletions seuthesis2024b.cls
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

\NeedsTeXFormat {LaTeX2e}
\RequirePackage {l3keys2e}
\ProvidesExplClass {seuthesis2024b} {2024/02/20} {0.6.0}
\ProvidesExplClass {seuthesis2024b} {2024/02/24} {0.7.0}
{Southeast University Thesis for Class of 2024 Bachelors}

\str_const:Nn \c__seuthesis_name_str { seuthesis2024b }
Expand Down Expand Up @@ -407,8 +407,8 @@
\renewcommand \thetable { \arabic{table } }
}
{
\renewcommand \thefigure { \arabic{chapter}-\arabic{figure} }
\renewcommand \thetable { \arabic{chapter}.\arabic{table } }
\renewcommand \thefigure { \thechapter-\arabic{figure} }
\renewcommand \thetable { \thechapter.\arabic{table } }
}
\captionsetup
{
Expand Down Expand Up @@ -559,34 +559,55 @@
]
{ biblatex }
\AtBeginBibliography { \zihao{5} }
% In this class, the default is to use sentence case for titles.
\bool_if:NF \l__seuthesis_bib_title_case_bool
{
\DeclareFieldFormat { sentencecase } { \MakeSentenceCase { #1 } }
% Modified based on
% https://github.com/hushidong/biblatex-gb7714-2015/blob/15db5aaf6834b2359c605227726c67d1350bc660/gb7714-2015.bbx#L3373-L3406
\renewbibmacro*{title}{%
\ifboolexpr{%
test{\iffieldundef{title}}%
and
test{\iffieldundef{subtitle}}}%
{}%
{
\printtext[title]{\bibtitlefont%增加字体控制命令
\printfield[sentencecase]{title}%
\ifboolexpr{test {\iffieldundef{subtitle}}}%增加了对子标题的判断
{}{\setunit{\subtitlepunct}\printfield[sentencecase]{subtitle}}%
\iffieldundef{titleaddon}{}{\setunit{\subtitlepunct}\printfield{titleaddon}}%判断一下titleaddon
\ifboolexpr{test{\ifentrytype{book}} and (not test{\iffieldundef{volume}})}%判断一下book类有没有volume
{\setunit{\subtitlepunct}\printfield{volume}}{}%
\iftoggle{bbx:gbtype}%
{\iffieldundef{entrysubtype}{\printfield[gbtypeflag]{usera}}%在标题后直接给出文献标识字母,判断一下,是否是报纸和标准
{\iffieldequalstr{entrysubtype}{standard}{\printfield[gbtypeflags]{usera}}%判断是否为标准
{\iffieldequalstr{entrysubtype}{news}{\printfield[gbtypeflagn]{usera}}%判断是否为报纸
{\printfield[gbtypeflag]{usera}}}}}{}%%其它
}%
}%
\input { assets/bib_custom } % a bunch of settings here

\DeclareNameFormat { CNauthor }
{
\namepartfamily
}
\DeclareNameFormat { CNauthorEtAl }
{
\ifthenelse { \value{liststop} = 1 } { } { 等 }
}
\DeclareCiteCommand* { \CNciteauthor }
{
\boolfalse{citetracker}
\boolfalse{pagetracker}
\usebibmacro{prenote}}
{
\ifciteindex
{\indexnames{labelname}}
{}
\printnames[CNauthor ][1-1]{labelname}
\printnames[CNauthorEtAl][2-2]{labelname}
}
{ \multicitedelim }
{ \usebibmacro{postnote} }

\NewDocumentCommand \seuthesis@LciteSingle { O{文献} m }
{
\CNciteauthor* { #2 } 在 #1 \cite { #2 }
}
\NewDocumentCommand \Lcite { O{文献} m O{中} }
{
\Lcite_expressed_in:nn { #1 } { #2 } #3
}
\clist_new:N \l__seuthesis_Lcite_clist
\cs_new_protected:Npn \Lcite_expressed_in:nn #1 #2
{
\clist_clear:N \l__seuthesis_Lcite_clist
\clist_map_inline:nn { #2 }
{
\clist_put_right:Nx \l__seuthesis_Lcite_clist
{
\seuthesis@LciteSingle [ #1 ] { ##1 }
}
}
\clist_use:Nnnn { \l__seuthesis_Lcite_clist } { 和 } { 、 } { 和 }
}
\NewDocumentCommand \YLcite { O{文献} m O{中} }
{
\citeyear { #2 } 年 \Lcite [ #1 ] { #2 } [ #3 ]
}

%% ==========================
Expand All @@ -598,23 +619,28 @@
\newcommand \seuthesis@lst@belowskip { .2\baselineskip }
\newcommand \seuthesis@lst@numcolor { gray }
\newcommand \seuthesis@lst@keycolor { Blue }
\newcommand \seuthesis@lst@strcolor { Purple }
\newcommand \seuthesos@lst@comcolor { gray }
\newcommand \seuthesis@lst@bgcolor { gray!3 }
\RequirePackage { listings }
\lstset
{
, frame = lines
, basicstyle =
, frame = lines
, basicstyle =
\linespread{\seuthesis@lst@linespread}
\seuthesis@lst@fontsize\ttfamily
, numberstyle = \scriptsize\sffamily\color{\seuthesis@lst@numcolor}
, keywordstyle = \bfseries\color{\seuthesis@lst@keycolor}
, backgroundcolor = \color{\seuthesis@lst@bgcolor}
, aboveskip = \seuthesis@lst@aboveskip
, belowskip = \seuthesis@lst@belowskip
, breaklines = true
, upquote = true
, columns = fixed
, numbers = left
, numberstyle = \scriptsize\sffamily\color{\seuthesis@lst@numcolor}
, keywordstyle = \bfseries\color{\seuthesis@lst@keycolor}
, commentstyle = \color{\seuthesos@lst@comcolor}
, stringstyle = \color{\seuthesis@lst@strcolor}
, backgroundcolor = \color{\seuthesis@lst@bgcolor}
, aboveskip = \seuthesis@lst@aboveskip
, belowskip = \seuthesis@lst@belowskip
, breaklines = true
, upquote = true
, columns = fixed
, numbers = left
, showstringspaces = false
}

%% ==========================
Expand All @@ -628,6 +654,7 @@
, pdfsubject = { \c__seuthesis_institute_str 本科毕业设计(论文)报告 }
, pdfcreator = { LaTeX~with~\c__seuthesis_name_str }
, bookmarksdepth = 2 % PDF bookmarks up to \subsection
, bookmarksnumbered = true
}
% --- \title ---
\bool_new:N \l__seuthesis_title_cont_bool
Expand Down
Binary file modified seuthesis2024b.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions seuthesis2024b.tex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
\supervisor{Ted Roosevelt}
\date{2023年12月 至 2024年5月}

% % default arXiv date is 2024-03-01
% \makeatletter
% \renewcommand \seuthesis@arxiv@urldate {2024-04-01} % the date you want
% \makeatother

% 添加参考文献 bib 文件,注意使用符合 BibLaTeX(配合 Biber)的格式
\addbibresource{ref/IEEEfull.bib}
\addbibresource{ref/ref.bib}
Expand Down

0 comments on commit 07a3e93

Please sign in to comment.