给定和 BibTeX 条目
@articel{paper,
author={Jane Doe and John Hansen and Tom Nielsen},
year={2012},
title={Paper title}
}
我如何biblatex
使用
- 在文本中插入“Jane Doe、John Hansen 和 Tom Nielsen”(
\citeauthor
仅使用姓氏) - 在文本中插入“Jane Doe”(即仅限第一作者)
谢谢
答案1
以下是(简化)引用命令的定义,用于打印第一作者的(全名)名称和作者的全名。
\documentclass[a4paper,12pt]{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@articel{test,
author={Jane Doe and John Hansen and Tom Nielsen},
year={2012},
title={Paper title}
}
\end{filecontents}
\usepackage{xpatch}
\usepackage[style=authoryear,maxbibnames=6]{biblatex}
\addbibresource{\jobname.bib}
\DeclareNameFormat{onlyfirst}{%
\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
}
\DeclareCiteCommand{\citefirstauthor}
{\usebibmacro{prenote}}
{\printnames[onlyfirst][1-1]{labelname}
\usebibmacro{citeindex}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citenames}
{\usebibmacro{prenote}}
{\printnames[first-last]{labelname}}
{\multicitedelim}
{\usebibmacro{postnote}}
\begin{document}
First author only: \citefirstauthor{test}
All authors: \citenames{test}
\printbibliography
\end{document}
答案2
以下是基于的 MWE@Guido的回答:
\documentclass{article}
\usepackage{filecontents} % tlmgr install filecontents
\begin{filecontents*}{btest.bib}
@BOOK{Author2014,
author = {Jane Doe and John Hansen and Tom Nielsen},
publisher = {Another},
title = {The Author book},
year = 2014
}
\end{filecontents*}
\usepackage[%
style=ieee,
isbn=true,
doi=false,
url=true,
backend=biber
]{biblatex}
\bibliography{btest}
\DeclareNameFormat{onlyfirst}{%
\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}%
}
\DeclareCiteCommand{\citefirstauthor}
{\usebibmacro{prenote}}
{\printnames[onlyfirst][1-1]{labelname}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\citenames}
{\usebibmacro{prenote}}
{\printnames[first-last]{labelname}}
{\multicitedelim}
{\usebibmacro{postnote}}
\begin{document}
Testing citenames here: \citenames{Author2014}
\end{document}
使用pdflatex test.tex
、、、、编译此biber test
内容,pdflatex test.tex
但pdflatex test.tex
我仍然得到以下结果:
我使用的代码与答案中完全相同,但我只获得了名字的首字母。为什么以及如何获得全名?
编辑:刚刚发现只需要添加firstinits=false
到包加载中:
...
\usepackage[%
style=ieee,
isbn=true,
doi=false,
url=true,
firstinits=false, %% this!
backend=biber
]{biblatex}
\bibliography{btest}
...
...然后生成全名:
EDIT2:...如果您需要此命令在 IEEE 等环境中明确切换,其中 firstinits=true,并且您不想firstinits=false
在前言中设置 - 可能会起作用:
\DeclareCiteCommand{\citenames}
{\usebibmacro{prenote}}
{%
% \ExecuteBibliographyOptions{firstinits=false} % only in preamble
\makeatletter%
\setkeys{blx@opt@pre}{firstinits=false}%
\makeatother%
\printnames[first-last]{labelname}%
\makeatletter%
\setkeys{blx@opt@pre}{firstinits=true}%
\makeatother%
}
{\multicitedelim}
{\usebibmacro{postnote}}