使用时biblatex
我经常使用\textcite
。有时我想写“Smith (2000) 的 x 公式是”而不是“Smith (2000) 将 x 公式化为”。我该如何实现呢?或者更一般地说,我如何让作者的名字输出\textcite
在所有格?我主要在寻找英语版本。这意味着我希望\textcite
能够在作者姓名后添加“'s”,例如输出
Knuth(1984)
代替
Knuth(1984)
理想情况下,我希望有一个解决方案,能够将任何作者或作者的名字放在所有格中,并能够处理除英语以外的其他语言。
下面的例子也许能解释我所要求的:
\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{database.bib}
@book{texbook,
author = {Donald E. Knuth},
title = {The {{\TeX}book}},
publisher = {Addison-Wesley},
date = {1984}
}
\end{filecontents*}
\bibliography{database.bib}
\begin{document}
\textcite{texbook}% Standard use. Output: "Knuth (1984)"
\textcite{texbook}'s% Failed try to get output in the possesive case. Output: "Knuth (1984)'s"
Knuth's (1984)% The ouput that I want
\end{document}
答案1
这个答案延伸Philipp Lehman 的方法labelname
使用格式别名生成所有格。它应该适用于标准作者年份样式的所有变体。
请注意,该解决方案不适用于复数标签名,其中所有格由 just'
和 not组成's
。不过,这种情况可能非常罕见。其他语言可能不那么容易处理。有关示例,请参阅先前的问题,其中考虑了挪威语所有格。
\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\usepackage{filecontents}
\DeclareNameFormat{labelname:poss}{% Based on labelname from biblatex.def
\ifcase\value{uniquename}%
\usebibmacro{name:last}{#1}{#3}{#5}{#7}%
\or
\ifuseprefix
{\usebibmacro{name:first-last}{#1}{#4}{#5}{#8}}
{\usebibmacro{name:first-last}{#1}{#4}{#6}{#8}}%
\or
\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
\fi
\usebibmacro{name:andothers}%
\ifnumequal{\value{listcount}}{\value{liststop}}{'s}{}}
\DeclareFieldFormat{shorthand:poss}{%
\ifnameundef{labelname}{#1's}{#1}}
\DeclareFieldFormat{citetitle:poss}{\mkbibemph{#1}'s}
\DeclareFieldFormat{label:poss}{#1's}
\newrobustcmd*{\posscitealias}{%
\AtNextCite{%
\DeclareNameAlias{labelname}{labelname:poss}%
\DeclareFieldAlias{shorthand}{shorthand:poss}%
\DeclareFieldAlias{citetitle}{citetitle:poss}%
\DeclareFieldAlias{label}{label:poss}}}
\newrobustcmd*{\posscite}{%
\posscitealias%
\textcite}
\newrobustcmd*{\Posscite}{\bibsentence\posscite}
\newrobustcmd*{\posscites}{%
\posscitealias%
\textcites}
\begin{filecontents}{\jobname.bib}
@Article{bertram:sa,
author = {Bertram, Aaron and Wentworth, Richard},
shortauthor = {BW},
title = {Gromov invariants for holomorphic maps on Riemann surfaces},
journaltitle = {J.~Amer. Math. Soc.},
volume = {9},
number = {2},
date = {1996},
pages = {529--571}}
@Book{title,
title = {A Book with No Author},
date = {1933}}
@Book{shorthand,
title = {A Book with No Author},
shorthand = {ABWNA},
date = {1933}}
@Book{label,
label = {Fallback label},
date = {1933}}
@Book{does,
title = {A Book by the Does},
author = {Doe, John and Doe, Jane},
shortauthor = {{The Does}},
date = {1990}}
\end{filecontents}
\addbibresource{\jobname.bib}
\bibliography{biblatex-examples}
\renewcommand{\baselinestretch}{1.25}
\begin{document}
\subsection*{cite with labelname}
posscite many authors: \posscite[3036]{aksin} \\
textcite shortauthor: \textcite[e.g.][3]{bertram:sa} \\
posscite shortauthor: \posscite[e.g.][4]{bertram:sa} \\
textcite shorthand: \textcite{kant:ku} \\
posscite shorthand: \posscite{kant:ku} \\
textcite compact: \textcite{aristotle:physics,aristotle:poetics} \\
posscite compact: \posscite{aristotle:physics,aristotle:poetics} \\
textcites: \textcites[3036]{aksin}[529]{bertram:sa} \\
posscites: \posscites[3036]{aksin}[529]{bertram:sa} \\
posscite with plural labelname (where this solution is bad): \posscite{does}
\subsection*{cite without labelname}
textcite shorthand: \textcite{shorthand} \\
posscite shorthand: \posscite{shorthand} \\
textcite title: \textcite{title} \\
posscite title: \posscite{title} \\
textcite label: \textcite{label} \\
posscite label: \posscite{label} \\
\end{document}
答案2
您可以自己定义一个“所有格引用”命令,如下所示:
\newcommand\posscite[1]{\citeauthor{#1}'s (\citeyear{#1})}
虽然我不能保证它看起来很漂亮或者适用于多位作者的作品......
当然,正确地说你应该做的是使用biblatex
自己的\DeclarCiteCommand
和朋友的接口(并用正确的宏替换括号,这样如果你改变使用的括号的类型,它们也会改变......)
答案3
Audrey 之前的回答提供了与旧版本的 Biblatex 兼容的所有格引用命令。但是,由于以下原因,此代码在 Biblatex 3.3 中不起作用格式的改变\DeclareNameFormat
。
以下是 Audrey 代码的改编版(我非常感谢保丽康(进行轻微更正)应该适用于 Biblatex 3.3。根据 PLK,\nameparts
如果您使用的是 Biblatex 3.4,则不需要此行。(我不确定保留它是否会导致任何问题。)
\documentclass{article}
\usepackage[style=authoryear-comp]{biblatex}
\addbibresource{biblatex-examples.bib}
\DeclareNameFormat{labelname:poss}{% Based on labelname from biblatex.def
\nameparts{#1}% Not needed if using Biblatex 3.4
\ifcase\value{uniquename}%
\usebibmacro{name:family}{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}%
\or
\ifuseprefix
{\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiveni}{\namepartprefix}{\namepartsuffixi}}
{\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiveni}{\namepartprefixi}{\namepartsuffixi}}%
\or
\usebibmacro{name:first-last}{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}%
\fi
\usebibmacro{name:andothers}%
\ifnumequal{\value{listcount}}{\value{liststop}}{'s}{}}
\DeclareFieldFormat{shorthand:poss}{%
\ifnameundef{labelname}{#1's}{#1}}
\DeclareFieldFormat{citetitle:poss}{\mkbibemph{#1}'s}
\DeclareFieldFormat{label:poss}{#1's}
\newrobustcmd*{\posscitealias}{%
\AtNextCite{%
\DeclareNameAlias{labelname}{labelname:poss}%
\DeclareFieldAlias{shorthand}{shorthand:poss}%
\DeclareFieldAlias{citetitle}{citetitle:poss}%
\DeclareFieldAlias{label}{label:poss}}}
\newrobustcmd*{\posscite}{%
\posscitealias%
\textcite}
\newrobustcmd*{\Posscite}{\bibsentence\posscite}
\newrobustcmd*{\posscites}{%
\posscitealias%
\textcites}
答案4
作为补充,这里要添加无括号的 \posscite 变体(实际上是 \cite 而不是 \textcite 的所有格变体)。
% Possessive Cite (no parentheses) \posscitenopar
\newrobustcmd*{\posscitenopar}{%
\posscitealias%
\cite}
\newrobustcmd*{\Posscitenopar}{\bibsentence\posscite}
\newrobustcmd*{\posscitesnopar}{%
\posscitealias%
\cites}