diff --git a/bithesis-doc.tex b/bithesis-doc.tex index a9d66f15..afd9c5a4 100644 --- a/bithesis-doc.tex +++ b/bithesis-doc.tex @@ -1858,35 +1858,46 @@ \subsection{后置部分} \end{function} \begin{function}[label=env.publications]{publications} -\begin{bitsyntax}[emph={[1]publications,addpubs,printbibliography}] -文献较少的时候。 +\begin{bitsyntax}[emph={[1]publications,addpubs,printbibliography,refsection,nocite}] +传统方式(手动指定文献): \begin{publications} \addpubs{\meta{引用内容的key},\meta{引用内容的key2}} \printbibliography[heading=none,category=mypub,resetnumbers=true] \end{publications} -文献较多,需要分类的时候。 -\begin{publications} - \addpubs{\meta{引用内容的key},\meta{引用内容的key2}} - \pubsection{文章} - - \printbibliography[heading=none,type=article,category=mypub,resetnumbers=true]{} - - \pubsection{一些书} +推荐方式(使用 refsection 和 \nocite{*}): +\begin{refsection}[\meta{pub.bib文件路径}] + \begin{publications} + \nocite{*} + \printbibliography[heading=none,resetnumbers=true] + \end{publications} +\end{refsection} - \printbibliography[heading=none,type=book,category=mypub,resetnumbers=true,notkeyword=dummy]{} +文献较多,需要分类的时候: +\begin{refsection}[\meta{pub.bib文件路径}] + \begin{publications} + \nocite{*} + \pubsection{文章} + \printbibliography[heading=none,type=article,resetnumbers=true]{} - \pubsection{另一些书} + \pubsection{一些书} + \printbibliography[heading=none,type=book,resetnumbers=true,notkeyword=dummy]{} - \printbibliography[heading=none,type=book,category=mypub,keyword=dummy,resetnumbers=true]{} -\end{publications} + \pubsection{另一些书} + \printbibliography[heading=none,type=book,keyword=dummy,resetnumbers=true]{} + \end{publications} +\end{refsection} \end{bitsyntax} - 攻读学位期间发表论文与研究成果清单。 +攻读学位期间发表论文与研究成果清单。 + +BIThesis 从 v3.3.0 开始推荐使用 biblatex 的 |refsection| 环境配合 |\nocite{*}| +来替代手动使用 |\addpubs| 的方式。这样可以自动包含 pub.bib 中的所有条目, +无需手动指定每个引用的 key,避免了 pub.bib 和 ref.bib 共存时可能出现的问题。 \end{function} -\begin{function}[added=2022-10-23]{\addpubs,\addpub} +\begin{function}[added=2022-10-23, updated=2025-01-02]{\addpubs,\addpub} \begin{bitsyntax}[emph={[1]publications,addpubs,addpub}] \begin{publications} \addpub{\meta{单条引用内容的key}} @@ -1894,8 +1905,12 @@ \subsection{后置部分} \end{publications} \end{bitsyntax} -\textbf{请注意,如果你的参考文献同时出现在「攻读学位期间发表论文与研究成果清单」和「参考文献」中, -请将条目分别添加进入两个 |.bib| 文件中,并修改它们的key以避免重名;切勿重复使用。} +\textbf{请注意,从 v3.3.0 开始,推荐使用 refsection 配合 \nocite{*} 的方式, +详见 publications 环境的说明。传统的 \addpubs 方式仍然支持,但不再推荐。} + +\textbf{如果你的参考文献同时出现在「攻读学位期间发表论文与研究成果清单」和「参考文献」中, +使用新的 refsection 方式可以避免 pub.bib 和 ref.bib 共存的问题。 +传统方式下需要将条目分别添加进入两个 |.bib| 文件中,并修改它们的key以避免重名;切勿重复使用。} \textit{在「攻读学位期间发表论文与研究成果清单」环境中使用。} 用于添加个人成果,添加过的成果可以通过 |printbibliography| 打印。 diff --git a/bithesis.dtx b/bithesis.dtx index a7bdc30d..24afb873 100644 --- a/bithesis.dtx +++ b/bithesis.dtx @@ -3518,6 +3518,19 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\nociteall} +% 在 publications 环境中使用 refsection 时,可以使用 \nociteall 来自动添加所有文献。 +% 这相当于 \nocite{*},但会自动将所有条目添加到 mypub 类别中。 +% \begin{macrocode} +\NewDocumentCommand \nociteall {} { + % 自动 nocite 所有条目 + \nocite{*} + % 获取当前 refsection 中的所有条目并添加到 mypub 类别 + % 由于 biblatex 的限制,我们需要在 printbibliography 时处理类别过滤 +} +% \end{macrocode} +% \end{macro} +% % \begin{macro}{\pubsection} % 设置小标题。 % \begin{macrocode} @@ -3542,6 +3555,9 @@ % % \begin{environment}{publications} % 生成攻读学位期间发表论文与研究成果清单。 +% 支持两种使用方式: +% 1. 传统方式:使用 \addpubs{key1,key2,...} 手动指定文献条目 +% 2. 新方式:使用 refsection 环境包裹,然后在 publications 环境中使用 \nocite{*} % \begin{macrocode} \NewDocumentEnvironment {publications} {+b} { diff --git a/handbook/chapters/ch2-template-usage.tex b/handbook/chapters/ch2-template-usage.tex index 42d3cdf6..399307a7 100644 --- a/handbook/chapters/ch2-template-usage.tex +++ b/handbook/chapters/ch2-template-usage.tex @@ -171,7 +171,10 @@ \section{其他部分} \isGraduateTF{ \subsection{「攻读学位期间发表论文与研究成果清单」} 这部分用 \texttt{pub.bib} 记录文献,用 \texttt{4\_pub.tex} 列出清单。 -增添成果需首先在 \texttt{pub.bib} 中添加新的文献条目。% + +从 BIThesis v3.3.0 开始,推荐使用 biblatex 的 \texttt{refsection} 环境配合 \texttt{\textbackslash nocite\{*\}} 的方式来管理发表论文清单。这样可以避免 \texttt{pub.bib} 和 \texttt{ref.bib} 共存时可能出现的问题,也无需手动指定每个文献的 key。 + +传统方式仍然支持:增添成果需首先在 \texttt{pub.bib} 中添加新的文献条目,然后在 \texttt{4\_pub.tex} 中使用 \texttt{\textbackslash addpubs} 手动指定。% % 而如果你想要在盲审模式中隐藏自己的名字,那么你需要 根据 pub.bib 中的示例以及注释说明,为每个文献条目添加并设置 diff --git a/templates/graduate-thesis/misc/4_pub.tex b/templates/graduate-thesis/misc/4_pub.tex index a5ecc607..4a3c532d 100644 --- a/templates/graduate-thesis/misc/4_pub.tex +++ b/templates/graduate-thesis/misc/4_pub.tex @@ -5,22 +5,34 @@ % ==== 攻读学位期间发表论文与研究成果清单 ==== % 1. 在 `../reference/pub.bib` 中添加数据。 -% 2. 在本文件下方 `\addpubs` 添加该文献(参考下方示例)。 +% 2. 有两种使用方式: +% 方式一(传统方式):在本文件下方 `\addpubs` 添加该文献(参考下方示例)。 +% 方式二(推荐):使用 refsection 包裹,然后使用 \nocite{*} 自动包含所有文献。 % **注意:如果发现渲染出来的文献编号不正确,请同时使用以下两个方式解决:** % 1. 请清除缓存重新编译,比如`latexmk -gg`,详见 https://bithesis.bitnp.net/faq/clean.html 。 % 2. 请确保无编译错误。 -\begin{publications} +% 方式一:传统方式 +% \begin{publications} +% % **默认情况下,这里的内容将按照学校要求,以发表时间排序。** +% % - 如果想要按照引用顺序排序,可在`main.tex`设置`publications/sorting = false`。 +% % - 如果想要微调,详见 https://bithesis.bitnp.net/faq/bib-sort.html#sortkey 。 +% % 更多信息请参考「bithesis.pdf」手册。 +% \addpubs{myCiteKey,myCiteKey2,dummy:1,dummy:2} +% +% % 主要针对硕士生 +% \printbibliography[heading=none,category=mypub,resetnumbers=true] +% \end{publications} - % **默认情况下,这里的内容将按照学校要求,以发表时间排序。** - % - 如果想要按照引用顺序排序,可在`main.tex`设置`publications/sorting = false`。 - % - 如果想要微调,详见 https://bithesis.bitnp.net/faq/bib-sort.html#sortkey 。 - % 更多信息请参考「bithesis.pdf」手册。 - \addpubs{myCiteKey,myCiteKey2,dummy:1,dummy:2} - - % 主要针对硕士生 - \printbibliography[heading=none,category=mypub,resetnumbers=true] +% 方式二:使用 refsection(推荐) +\begin{refsection}[../reference/pub.bib] + \begin{publications} + % 使用 \nocite{*} 自动包含所有条目,无需手动 \addpubs + \nocite{*} + + % 主要针对硕士生 + \printbibliography[heading=none,resetnumbers=true] % 如果想要分为多个列表,可以使用以下的命令。 % 主要针对博士生。 @@ -50,4 +62,5 @@ % \item 于《新青年》发表论文一篇,本人第一作者。 % \item 于\textit{La Jeunesse}发表论文一篇,导师第一作者,本人第二作者。 % \end{enumerate} -\end{publications} + \end{publications} +\end{refsection} diff --git a/tests/publications/main.tex b/tests/publications/main.tex index d156e4ed..1684a493 100644 --- a/tests/publications/main.tex +++ b/tests/publications/main.tex @@ -20,30 +20,33 @@ \begin{document} +% Test traditional approach with addpubs \begin{publications} \addpubs{a1,a2,a3,a4} - - % 主要针对硕士生 \printbibliography[heading=none,category=mypub,resetnumbers=true,keyword=a] \end{publications} -\begin{publications} - \addpubs{b1,b2,b3,b4} - - 如果想要分为多个列表,可以使用以下的命令。 - 主要针对博士生。 - \pubsection{文章} +% Test new refsection approach +\begin{refsection}[pub.bib] + \begin{publications} + % 使用 \nocite{*} 自动包含所有条目,无需手动 \addpubs + \nocite{*} + + % Test filtering with keywords to match previous behavior + 如果想要分为多个列表,可以使用以下的命令。 + 主要针对博士生。 + \pubsection{文章} - \printbibliography[heading=none,type=article,category=mypub,resetnumbers=true,notkeyword=a]{} + \printbibliography[heading=none,type=article,resetnumbers=true,notkeyword=a]{} - \pubsection{一些书} + \pubsection{一些书} - \printbibliography[heading=none,type=book,category=mypub,resetnumbers=true,notkeyword=dummy,notkeyword=a]{} + \printbibliography[heading=none,type=book,resetnumbers=true,notkeyword=dummy,notkeyword=a]{} - \pubsection{另一些书} + \pubsection{另一些书} - \printbibliography[heading=none,type=book,category=mypub,keyword=dummy,resetnumbers=true,notkeyword=a]{} - -\end{publications} + \printbibliography[heading=none,type=book,keyword=dummy,resetnumbers=true,notkeyword=a]{} + \end{publications} +\end{refsection} \end{document}