![使用 biblatex 修改字母书目标签](https://linux22.com/image/283121/%E4%BD%BF%E7%94%A8%20biblatex%20%E4%BF%AE%E6%94%B9%E5%AD%97%E6%AF%8D%E4%B9%A6%E7%9B%AE%E6%A0%87%E7%AD%BE.png)
我正在尝试修改 biblatex 定义的字母样式标签的格式:我希望使用作者的整个姓氏和年份的 4 位数字,而不是作者的前 3 个字母和年份的后 2 位数字。当
只有一位作者时,我可以使用以下代码来做到这一点,该代码与原始定义略有修改:
\DeclareLabelalphaTemplate{
\labelelement{
\field[final]{shorthand}
\field{label}
\field[strside=left,ifnames=1]{labelname}%
\field[strside=left, names=3]{labelname}
}
\labelelement{
\literal{~}
}
\labelelement{
\field[strside=right]{year}
}
\labelelement{
\literal{~: }%
}
}
当有多位作者时,名字之间应该用逗号和空格分隔(最后一个也一样),但我没看到在名字列表元素之间引入这个的方法。
有人知道是否可以实现这一点吗?
我已设法满足其他要求,即将姓名打印为姓氏 (firstinit.),以逗号分隔。对标签尝试相同操作的一种方法是打印不带名字部分的作者列表。以下是我现在获得的示例:
如您所见,当有 2 位或更多作者时,我无法在姓名之间插入任何内容。
答案1
以下是尝试获得您所追求的风格。
正如上面的评论所指出的那样,似乎比当前的情况authoryear
更合适。alphabetic
你将需要biblatex
加载
\usepackage[backend=biber, style=authoryear, firstinits, mergedate=false, maxcitenames=3, maxbibnames=999]{biblatex}
这意味着所有名称都将出现在参考书目中,而(在文本中)引用缩短为最多三个名称。
我们用句点来分隔区块,
\renewcommand*{\newunitpunct}{\addperiod\space}
但没有最后的标点。
\renewcommand*{\finentrypunct}{}
姓名的格式为姓氏首字母,首字母放在括号中,姓名之间没有逗号,姓氏采用小写字母。
\renewcommand*{\revsdnamepunct}{}
\renewcommand*{\finalnamedelim}{\multinamedelim}
\renewcommand*{\mkbibnamelast}[1]{\textsc{#1}}
\DeclareNameAlias{sortname}{last-first}
\DeclareNameFormat{last-first}{%
\iffirstinits
{\usebibmacro{name:last-first}{#1}{(#4)}{#5}{#7}}
{\usebibmacro{name:last-first}{#1}{(#3)}{#5}{#7}}%
\usebibmacro{name:andothers}}
名称和标题之间有破折号
\renewcommand*{\labelnamepunct}{\space--\space}
我们去掉了参考书目中的额外年份
\renewbibmacro*{date+extrayear}{}%
文章在期刊之前未收到
\renewbibmacro{in:}{%
\ifentrytype{article}
{}
{\printtext{\bibstring{in}\intitlepunct}}}
日期不在括号中
\renewbibmacro*{issue+date}{%
\printfield{issue}%
\setunit{\addcomma\space}%
\printdate%
\newunit}
此外,位置和发布者之间没有冒号,而是逗号
\renewbibmacro*{publisher+location+date}{%
\printlist{location}%
\setunit*{\addcomma\space}%
\printlist{publisher}%
\setunit*{\addcomma\space}%
\usebibmacro{date}%
\newunit}
最后,此代码在参考书目中每个条目前添加了粗体标签。代码现在确保只打印与正常引文中打印的一样多的名称,我们还确保引文标签不使用小写字母,而实际参考书目则使用小写字母。
\makeatletter
\renewbibmacro*{begentry}{%
\renewcommand*{\mkbibnamelast}[1]{##1}%
\defcounter{maxnames}{\blx@maxcitenames}%
\printtext[bold]{\usebibmacro{cite}\addspace:\space}%
\defcounter{maxnames}{\blx@maxbibnames}
\renewcommand*{\mkbibnamelast}[1]{\textsc{\textnohyphenation{##1}}}}
\makeatother
目前文本中的引用标签使用小写字母,为了摆脱这种行为,也会出现问题
\AtBeginDocument{\renewcommand*{\mkbibnamelast}[1]{#1}}
平均能量损失
\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=authoryear, firstinits, mergedate=false, maxcitenames=3, maxbibnames=999]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@collection{py:dicocer,
editor = {Michel Py},
title = {Dictionnaire des céramiques antiques (VIIe s. av. n. è. -- VIIe s. de n. è.) en Méditerranée nord-occidentale (Provence, Languedoc, Ampurdan)},
series = {Lattara},
publisher = {Lattes},
number = {6},
date = {1993},
pagetotal = {624},
}
@collection{CompGreekTrag:EuripidesIV,
editor = {Grene, David and Lattimore, Richmond},
maintitle = {The Complete Greek Tragedies},
title = {Euripides IV},
date = {1968-11},
isbn = {0-226-30783-2},
pagetotal = {314},
}
@incollection{beowulf06aa,
editor = {Stephen Greenblatt and M. H. Abrams and Carol T. Christ and Alfred David and Barbara K. Lewalski and Lawrence Lipking and George M. Logan and Deidre Shauna Lynch},
title = {Beowulf},
booktitle = {The Norton Anthology of English Literature},
year = {2006},
edition = {8},
publisher = {W. W. Norton},
location = {New York, New York},
volume = {1},
pages = {34-100},
}
@book{bohec,
author = {Le Bohec, Yann},
title = {Histoire militaire des guerres puniques},
date = {1996},
location = {Monaco},
publisher = {Rocher},
isbn = {2-268-02147-5},
}
@article{leveau,
author = {Philippe Leveau},
title = {Le franchissement du Rhône par Hannibal: le chenal et la navigation fluviale à la fin de l’Âge du Fer},
journaltitle = {Revue archéologique},
date = {2003},
volume = {35},
pages = {25-50},
doi = {10.3917/arch.031.0025},
}
@article{Shapiro2000,
author = {A.M. James Shapiro and Jonathan R.T. Lakey and Edmond A. Ryan and Gregory S. Korbutt and Ellen Toth and Garth L. Warnock and Norman M. Kneteman and Ray V. Rajotte},
title = {Islet Transplantation in Seven Patients with Type 1 Diabetes Mellitus Using a Glucocorticoid-Free Immunosuppressive Regimen},
journaltitle = {New England Journal of Medicine},
date = {2000},
volume = {343},
number = {2},
pages = {230--238},
doi = {10.1056/NEJM200007273430401},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\renewcommand*{\newunitpunct}{\addperiod\space}
\renewcommand*{\finentrypunct}{}
\renewcommand*{\revsdnamepunct}{}
\renewcommand*{\finalnamedelim}{\multinamedelim}
\DeclareNameAlias{sortname}{last-first}
\DeclareNameFormat{last-first}{%
\iffirstinits
{\usebibmacro{name:last-first}{#1}{(#4)}{#5}{#7}}
{\usebibmacro{name:last-first}{#1}{(#3)}{#5}{#7}}%
\usebibmacro{name:andothers}}
\renewcommand*{\labelnamepunct}{\space--\space}
\renewbibmacro*{date+extrayear}{}%
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{#1}
\renewbibmacro{in:}{%
\ifentrytype{article}
{}
{\printtext{\bibstring{in}\intitlepunct}}}
\renewbibmacro*{issue+date}{%
\printfield{issue}%
\setunit{\addcomma\space}%
\printdate%
\newunit}
\renewbibmacro*{publisher+location+date}{%
\printlist{location}%
\setunit*{\addcomma\space}%
\printlist{publisher}%
\setunit*{\addcomma\space}%
\usebibmacro{date}%
\newunit}
\makeatletter
\renewbibmacro*{begentry}{%
\renewcommand*{\mkbibnamelast}[1]{##1}%
\defcounter{maxnames}{\blx@maxcitenames}%
\printtext[bold]{\usebibmacro{cite}\addspace:\space}%
\defcounter{maxnames}{\blx@maxbibnames}
\renewcommand*{\mkbibnamelast}[1]{\textsc{\textnohyphenation{##1}}}}
\makeatother
%\AtBeginDocument{\renewcommand*{\mkbibnamelast}[1]{#1}}% optional
\begin{document}
\cite{wilde,cicero,coleridge,vangennep,vazques-de-parga,bohec,leveau,beowulf06aa,Shapiro2000,CompGreekTrag:EuripidesIV,py:dicocer}
\printbibliography
\end{document}