Biblatex: 引用には「and」を使用しますが、参考文献には「&」を使用します

Biblatex: 引用には「and」を使用しますが、参考文献には「&」を使用します

私は、BibLatex/biber を使用して Latex で書誌エントリを処理し始めています。まず、authoryear スタイルを使用して、論文を投稿するジャーナルの編集スタイルに準拠するように調整します。調整の 1 つは、次のコードを使用して、書誌の最後の著者の前にあるデフォルトの "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}

関連情報