
我開始使用 BibLatex/biber 來處理 Latex 中的書目條目。使用作者年份風格作為開始,我進行調整以符合我將提交論文的期刊的編輯風格。其中一項調整是使用以下程式碼在參考書目中最後一位作者之前用與號 (&) 替換預設的「and」:
% Add a comma and replace "and" with "&" before last coauthor
\renewcommand*{\finalnamedelim}{%
\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
\addcomma\addspace\&\space}
不幸的是,這個代碼也取代了引文中的“and”,這與期刊對引文的要求相反。
我的問題是,如何僅在參考書目中用“&”替換“and”?似乎 biblatex-dw 有這個選項,但我的文檔沒有用這種風格編譯。
答案1
我確信BibLaTeX
有更好、更有效的解決方案的設施,以下是快速破解
\documentclass{article}
\usepackage{filecontents}
\usepackage{etoolbox}
\usepackage[style=authoryear]{biblatex}
\newtoggle{incitation}
\pretocmd{\citesetup}{\toggletrue{incitation}}{}{}
\pretocmd{\bibsetup}{\togglefalse{incitation}}{}{}
\newcommand{\biband}{\iftoggle{incitation}{and}{\&}}
\renewcommand*{\finalnamedelim}{%
\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
\addcomma\addspace\biband\space}
\begin{filecontents}{\jobname.bib}
@article{test,
author = "Family, Given and FamilyTwo, GivenTwo",
title = "title",
journal = "Journal",
year = "2012"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{test}
\printbibliography
\end{document}
編輯
根據@Audrey的建議
\documentclass{article}
\usepackage{filecontents}
\usepackage[style=authoryear]{biblatex}
\newcommand{\biband}{\ifcurrentname{labelname}{\bibstring{and}}{\&}}
\renewcommand*{\finalnamedelim}{%
\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
\addcomma\addspace\biband\space}
\begin{filecontents}{\jobname.bib}
@article{test,
author = "Family, Given and FamilyTwo, GivenTwo",
title = "title",
journal = "Journal",
year = "2012"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{test}
\printbibliography
\end{document}
答案2
\documentclass{article}
\usepackage{filecontents}
\usepackage[style=authoryear,backend=biber]{biblatex}% delete backend= when running bibtex
\begin{filecontents}{\jobname.bib}
@article{test,
author = "Family, Given and FamilyTwo, GivenTwo and Family3, Given3",
title = "title",
journal = "Journal",
year = "2012"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
foo\cite{test}
\begingroup
\renewcommand*\finalnamedelim{ \& }
\printbibliography
\endgroup
\end{document}