使用 biblatex (+biber / lualatex) 我希望创建如下引用样式:整个引用位于括号内并超链接到相关的参考书目条目,并且Firstauthorname.year
如果该形式不明确,则添加字母标识符的形式。
我可以通过各种包导入选项来实现某些目的,但还不够:
\documentclass{article}
\usepackage[
style=authoryear,
backend=biber,
maxcitenames=1,
uniquelist=false,
]{biblatex}
\usepackage{filecontents}
\usepackage{hyperref}
\begin{filecontents*}{\jobname.bib}
@article{one,
author = {Alpha Bravo and Charlie Delta},
title = {How to make cites and influence formatting},
journal = {Journal of LateX typesetting},
date = {2025},
}
@article{two,
author = {Alpha Bravo and Echo Foxtrot},
title = {Biblatex citations and where to find them},
journal = {Journal of LateX sightseeing},
date = {2025},
}
@article{three,
author = {Charlie Delta and Echo Foxtrot},
title = {The man who killed Don Knuth},
journal = {Journal of LateX novelling},
date = {2025},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\begin{tabular}{l|l}
Actual & Desired (need hyperlinks too) \\ \hline
\cite{one} & [Bravo.2025a] \\
\cite{two} & [Bravo.2025b] \\
\cite{three} & [Delta.2025] \\
\end{tabular}
\printbibliography
\end{document}
有很多类似但实际上并非如此的,例如自定义 BibLaTeX 样式但我无法推断出需要做什么。
答案是某处在第 4 部分中biblatex 手册,我尝试阅读,但看不懂。直接深入研究书目宏的源代码也是一样(biblatex.def
)。
答案1
这似乎是authoryear
和alphabetic
引用样式之间的一个边界情况。一般来说,我建议不要滥用alphabetic
本质上是变体的样式authoryear
,但在这里我并不清楚样式应该是什么。
biblatex
由于目前禁用“et al.”比较棘手(在未来的版本中将成为可能:https://github.com/plk/biblatex/issues/861),我先给出一个alphabetic
解决方案,这个解决方案主要依赖于\DeclareLabelalphaTemplate
。
\documentclass{article}
\usepackage[
style=authoryear,
citestyle=alphabetic,
backend=biber,
maxcitenames=1,
maxalphanames=1,
uniquelist=false,
]{biblatex}
\usepackage{hyperref}
\renewcommand*{\labelalphaothers}{}
\DeclareLabelalphaTemplate{
\labelelement{
\field[final]{shorthand}
\field{label}
\field{labelname}
}
\labelelement{
\literal{.}
}
\labelelement{
\field{year}
}
}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{one,
author = {Alpha Bravo and Charlie Delta},
title = {How to make cites and influence formatting},
journal = {Journal of {\LaTeX} typesetting},
date = {2025},
}
@article{two,
author = {Alpha Bravo and Echo Foxtrot},
title = {Biblatex citations and where to find them},
journal = {Journal of {\LaTeX} sightseeing},
date = {2025},
}
@article{three,
author = {Charlie Delta and Echo Foxtrot},
title = {The man who killed Don Knuth},
journal = {Journal of {\LaTeX} novelling},
date = {2025},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\begin{tabular}{ll}
Actual & Desired (need hyperlinks too) \\ \hline
\cite{one} & [Bravo.2025a] \\
\cite{two} & [Bravo.2025b] \\
\cite{three} & [Delta.2025] \\
\end{tabular}
\printbibliography
\end{document}
在将来的版本biblatex
(v3.13 及以上版本)中,您应该能够执行以下操作。(我正在使用我的biblatex-ext
捆绑包来快速将括号更改为方括号。)
\documentclass{article}
\usepackage[
style=ext-authoryear,
backend=biber,
maxcitenames=1,
uniquelist=false,
nohashothers=true, nosortothers=true,
]{biblatex}
\usepackage{hyperref}
\DeclareOuterCiteDelims{parencite}{\bibopenbracket}{\bibclosebracket}
\DeclareDelimFormat{nameyeardelim}{\addperiod}
\DeclareNameFormat{labelname}{%
\usebibmacro{name:family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{one,
author = {Alpha Bravo and Charlie Delta},
title = {How to make cites and influence formatting},
journal = {Journal of {\LaTeX} typesetting},
date = {2025},
}
@article{two,
author = {Alpha Bravo and Echo Foxtrot},
title = {Biblatex citations and where to find them},
journal = {Journal of {\LaTeX} sightseeing},
date = {2025},
}
@article{three,
author = {Charlie Delta and Echo Foxtrot},
title = {The man who killed Don Knuth},
journal = {Journal of {\LaTeX} novelling},
date = {2025},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\begin{tabular}{ll}
Actual & Desired (need hyperlinks too) \\ \hline
\autocite{one} & [Bravo.2025a] \\
\autocite{two} & [Bravo.2025b] \\
\autocite{three} & [Delta.2025] \\
\end{tabular}
\printbibliography
\end{document}
nohashothers=true, nosortothers=true,
如果从 MWE 中删除新选项,那么即使在 的当前版本中,代码也将正常工作biblatex
。但由于“et al.”无法正确忽略,这可能会导致作者撰写了一部没有合著者的作品和另一部有合著者的作品时出现问题。