From 1ab3762fb5293d8f046f1c6582eec97dd220ceda Mon Sep 17 00:00:00 2001 From: Zeping Lee Date: Fri, 12 May 2023 11:14:30 +0800 Subject: [PATCH] Add \printbibliography in appendices (#875) --- data/appendix.tex | 3 +-- thuthesis.dtx | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/data/appendix.tex b/data/appendix.tex index a92ef69b..a955b4e5 100644 --- a/data/appendix.tex +++ b/data/appendix.tex @@ -56,5 +56,4 @@ \section{参考文献} 附录中的参考文献示例(\cite{carlson1981two} 和 \cite{carlson1981two,taylor1983scanning,taylor1981study})。 -\bibliographystyle{thuthesis-numeric} -\bibliography{ref/refs} +\printbibliography diff --git a/thuthesis.dtx b/thuthesis.dtx index e550a6bb..85822183 100644 --- a/thuthesis.dtx +++ b/thuthesis.dtx @@ -5790,20 +5790,40 @@ % % 设置 \option{cite-style} 的接口,只对 \BibTeX{} 的编译方式有效。 % \begin{macrocode} - \thu@define@key{ - cite-style = { - name = cite@style, - choices = { - super, - inline, - author-year, - } +\thu@define@key{ + cite-style = { + name = cite@style, + choices = { + super, + inline, + author-year, } } +} % \end{macrocode} % % \subsubsection{BibTeX + \pkg{natbib} 宏包} % +% \begin{macrocode} +\def\bibliographystyle#1{% + \gdef\bu@bibstyle{#1}% + \ifx\@begindocumenthook\@undefined\else + \expandafter\AtBeginDocument + \fi + {\if@filesw + \immediate\write\@auxout{\string\bibstyle{#1}}% + \immediate\write\@auxout{\string\gdef\string\bu@bibstyle{#1}}% + \fi}% +} +\def\bibliography#1{% + \if@filesw + \immediate\write\@auxout{\string\bibdata{\zap@space#1 \@empty}}% + \immediate\write\@auxout{\string\gdef\string\bu@bibdata{#1}}% + \fi + \gdef\bu@bibdata{#1}% + \@input@{\jobname.bbl}} +% \end{macrocode} +% % \BibTeX{} 和 \pkg{natbib} 宏包的配置。 % \begin{macrocode} \PassOptionsToPackage{compress}{natbib} @@ -6335,6 +6355,7 @@ \renewcommand\thu@end@appendix@ref@section{% \bibliographyunit\relax } + \providecommand\printbibliography{\putbib\relax}% \AtEndDocument{\thu@end@appendix@ref@section} % \end{macrocode} %