Skip to content

Commit

Permalink
Add biblatex for survey env (resolve tuna#893)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepinglee committed Jun 13, 2023
1 parent 68a018c commit cdba5ba
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 39 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

## [Unreleased]

### Added

- 本科生的附录(调研阅读报告和书面翻译)支持 `biblatex`[#893](https://github.com/tuna/thuthesis/issues/893))。

### Changed

- 不再插入 PDF 版书脊,改为编译生成([#551](https://github.com/tuna/thuthesis/issues/551))。
Expand All @@ -14,7 +18,7 @@
### Fixed

- 修正封面的职称字距问题([#879](https://github.com/tuna/thuthesis/discussions/879))。
- 解决了本科生附录的 `\printbibliography` 报错的问题([#882](https://github.com/tuna/thuthesis/discussions/882))。
- 解决了本科生附录的 `\printbibliography` 报错的问题([#882](https://github.com/tuna/thuthesis/issues/882))。

## [v7.4.0] - 2023-05-15

Expand Down
1 change: 1 addition & 0 deletions thusetup.tex
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
% 参考文献使用 BibLaTeX 宏包
% \usepackage[style=thuthesis-numeric]{biblatex}
% \usepackage[style=thuthesis-author-year]{biblatex}
% \usepackage[style=gb7714-2015]{biblatex}
% \usepackage[style=apa]{biblatex}
% \usepackage[style=mla-new]{biblatex}
% 声明 BibLaTeX 的数据库
Expand Down
98 changes: 60 additions & 38 deletions thuthesis.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -6396,6 +6396,18 @@
\bibliographyunit\relax
}
\AtEndDocument{\thu@end@appendix@ref@section}
\renewcommand\thu@set@survey@bibheading{%
\renewcommand\bibsection{%
\par
\vskip 20bp%
\thu@pdfbookmark{1}{\bibname}%
\begingroup
\centering
\xiaosi[1.667]\bibname\par
\endgroup
\vskip 6bp%
}%
}%
% \end{macrocode}
%
% 如果正文和附录引用了同一文献,\pkg{bibunits} 会给出无意义的警告,这里消除警告。
Expand All @@ -6405,25 +6417,34 @@
}
\PassOptionsToPackage{defernumbers = true}{biblatex}
\AtEndOfPackageFile*{biblatex}{
\ifthu@degree@graduate
\DeclareRefcontext{appendix}{}
\g@addto@macro\appendix{%
\pretocmd\chapter{%
\newrefsection
\DeclareRefcontext{appendix}{}
\g@addto@macro\appendix{%
\pretocmd\chapter{%
\newrefsection
\ifthu@degree@bachelor\else
\@tempcnta=\c@chapter
\advance\@tempcnta\@ne
\newrefcontext[labelprefix = {\@Alph\@tempcnta.}]{appendix}%
}{}{\thu@patch@error{\chapter}}%
\defbibheading{bibliography}[\bibname]{%
\ctexset{section/numbering = false}%
\section{#1}%
\ctexset{section/numbering = true}%
}%
}
% \renewcommand\thu@end@appendix@ref@section{%
% \endrefsection
% }
\fi
\fi
}{}{\thu@patch@error{\chapter}}%
\defbibheading{bibliography}[\bibname]{%
\ctexset{section/numbering = false}%
\section{#1}%
\ctexset{section/numbering = true}%
}%
}
\renewcommand\thu@set@survey@bibheading{%
\defbibheading{bibliography}[\bibname]{%
\par
\vskip 20bp%
\thu@pdfbookmark{1}{\bibname}%
\begingroup
\centering
\xiaosi[1.667]##1\par
\endgroup
\vskip 6bp%
}%
}%
\def\bibliographystyle#1{%
\thu@warning{'bibliographystyle' invalid for 'biblatex'.}%
}
Expand Down Expand Up @@ -6465,13 +6486,14 @@
\vskip 20bp%
}%
\let\appendix\thu@appendix@appendix
\thu@set@survey@bibheading
\renewcommand\bibname{参考文献}%
\let\bibsection\thu@appendix@bibsection
\startcontents[survey]%
}{%
\stopcontents[survey]%
\thu@reset@main@language % restore language
}
\newcommand\thu@set@appendix@bib@heading{}
% \end{macrocode}
% \end{environment}
%
Expand Down Expand Up @@ -6511,9 +6533,6 @@
\section{\bibname}%
\endgroup
}%
% \renewcommand\@bibunitname{\jobname-translation}%
% \let\bibliographystyle\defaultbibliographystyle
% \let\bibliography\thu@appendix@bibliography
\startcontents[translation]%
}{%
\stopcontents[translation]%
Expand All @@ -6525,13 +6544,26 @@
% \begin{environment}{translation}
% 书面翻译对应的原文索引,区别于译文的参考文献。
% \begin{macrocode}
\newenvironment{translation-index}{%
\begin{bibunit}%
\renewcommand\@bibunitname{\jobname-index}%
\renewcommand\bibname{书面翻译对应的原文索引}%
\let\bibsection\thu@appendix@bibsection
}{%
\end{bibunit}%
\newenvironment{translation-index}{}{}
\AtEndOfPackageFile*{bibunits}{
\renewenvironment{translation-index}{%
\begin{bibunit}%
\renewcommand\@bibunitname{\jobname-index}%
\renewcommand\bibname{书面翻译对应的原文索引}%
\thu@set@survey@bibheading
}{%
\end{bibunit}%
}
}
\AtEndOfPackageFile*{biblatex}{
\renewenvironment{translation-index}{%
\endrefsection
\begin{refsection}%
\renewcommand\bibname{书面翻译对应的原文索引}%
\thu@set@survey@bibheading
}{%
\end{refsection}%
}
}
% \end{macrocode}
% \end{environment}
Expand Down Expand Up @@ -6577,17 +6609,7 @@
%
% 调研阅读报告的参考文献(或书面翻译对应的外文资料的原文索引)标题用宋体小四号字,段前 20pt,段后 6pt,行距 20pt。
% \begin{macrocode}
\newcommand\thu@appendix@bibsection{%
\par
\vskip 20bp%
\thu@pdfbookmark{1}{\bibname}%
\begingroup
\centering
\xiaosi[1.667]\bibname\par
\endgroup
\vskip 6bp%
}%
\newcommand\thu@appendix@bibliography[1]{\putbib[#1]}
\newcommand\thu@set@survey@bibheading{}
% \end{macrocode}
%
%
Expand Down

0 comments on commit cdba5ba

Please sign in to comment.