考虑以下.bib 文件:
@MISC{test,
author = {Last1, First1 and Last2, First2 and Last3, First3},
}
我想要什么?我想要获取 .bib 文件条目中的第 n 位作者。
第一作者:First1 Last1
第二作者:First2 Last2
第三作者:First3 Last3
我尝试了下面的代码,使用\DeclareCiteCommand
和,\printnames
但没有得到想要的结果。事实上,MWE 中的代码给了我:
第一作者:First1 Last1 等
第二作者:First2 Last2 等
第三作者:First3 Last3
但我不想要逗号和“et al.”我只想要作者。
请注意,我定义了命令\citeauthorone
、\citeauthortwo
和\citeauthorthree
。这不是一个优雅的尝试。我宁愿使用类似\citenthauthor[n]{test}
并获取第 n 位作者 之类的命令。不幸的是,我不知道如何组合一个可以与\DeclareCiteCommand
传递选项交互的新命令。
平均能量损失
\documentclass{article}
\usepackage[]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@MISC{test,
author = {Last1, First1 and Last2, First2 and Last3, First3},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\DeclareCiteCommand{\citeauthorone}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printnames[][1-1]{author}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citeauthortwo}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printnames[][2-2]{author}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citeauthorthree}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printnames[][3-3]{author}}
{\multicitedelim}
{\usebibmacro{postnote}}
\begin{document}
\noindent
First Author: \citeauthorone{test} \\
Second Author: \citeauthortwo{test} \\
Third Author: \citeauthorthree{test} \\
\printbibliography
\end{document}
答案1
定义一个不带代码的新名称格式andothers
。
通常我不会推荐这样做,但如果您可以放弃通常的postnote
参数,您可以使用其可选参数作为作者编号。
\documentclass{article}
\usepackage[]{biblatex}
\DeclareNameFormat{given-family:noetal}{%
\ifgiveninits
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}}
\DeclareCiteCommand{\citeauthorone}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printnames[given-family:noetal][1-1]{author}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citeauthortwo}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printnames[given-family:noetal][2-2]{author}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citeauthorthree}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printnames[given-family:noetal][3-3]{author}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citeauthorgeneral}
{\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\usebibmacro{prenote}}
{\printnames[given-family:noetal][\thefield{postnote}-\thefield{postnote}]{author}}
{\multicitedelim}
{}
\begin{filecontents}{\jobname.bib}
@misc{test,
author = {Last1, First1 and Last2, First2 and Last3, First3},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
First Author: \citeauthorone{test}
Second Author: \citeauthortwo{test}
Third Author: \citeauthorthree{test}
First Author: \citeauthorgeneral[1]{test}
Second Author: \citeauthorgeneral[2]{test}
Third Author: \citeauthorgeneral[3]{test}
\printbibliography
\end{document}