我在 biblatex 中使用详细参考书目样式,并希望将 URL 和 DOI 字段放在每个条目的末尾,即(引用页码 ...)字段之后,而不是之前。有没有办法重新排序现有样式的字段?
答案1
对于一般情况,当你想重新排序的字段不一定出现在末尾时,biblatex 的\clearfield
-type 宏和xpatch 包派上用场。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[style=verbose,backref=true]{biblatex}
\usepackage[colorlinks]{hyperref}
\usepackage{xpatch}
\newbibmacro*{addendum+pubstate+pageref}{%
\usebibmacro{addendum+pubstate}%
\clearfield{addendum}%
\clearfield{pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\clearlist{pageref}%
\newunit\newblock}
\xpretobibmacro{doi+eprint+url}{\usebibmacro{addendum+pubstate+pageref}}{}{}
\xpretobibmacro{eprint}{\usebibmacro{addendum+pubstate+pageref}}{}{}
\xpretobibmacro{url+urldate}{\usebibmacro{addendum+pubstate+pageref}}{}{}
\addbibresource{biblatex-examples.bib}
\begin{document}
\null\vfill\noindent
Filler text.\footcite{bertram,kastenholz,ctan,itzhaki}
\printbibliography
\end{document}
答案2
在随附的参考书目样式中biblatex
,不同条目类型(@article
、、@book
...)的驱动程序通常以
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}
因此,可以重新定义doi+eprint+url
bibmacro 使其不执行任何操作,同时finentry
bibmacro 也承担原始任务doi+eprint+url
(而不仅仅是排版 a \finentrypoint
)。
\documentclass{article}
\usepackage[style=verbose,backref=true]{biblatex}
\renewbibmacro*{doi+eprint+url}{}
\renewbibmacro*{finentry}{%
\iftoggle{bbx:doi}
{\printfield{doi}}
{}%
\newunit\newblock
\iftoggle{bbx:eprint}
{\usebibmacro{eprint}}
{}%
\newunit\newblock
\iftoggle{bbx:url}
{\usebibmacro{url+urldate}}
{}%
\finentry
}
\textheight=120pt% just for the example
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
url = {www.tex.stackechange.com},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
Some text \autocite{A01}.
\printbibliography
\end{document}
@online
注意:和条目类型的驱动程序@unpublished
直接使用url+urdate
bibmacro。您不能重新定义此宏以使其不执行任何操作,因为它由 内部使用。相反,您必须将和doi+eprint+url
的定义复制到文档前言中并删除相应的代码行。@online
@unpublished
\DeclareBibliographyDriver{online}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{version}%
\newunit
\printfield{note}%
\newunit\newblock
\printlist{organization}%
\newunit\newblock
\usebibmacro{date}%
% \newunit\newblock% DELETED
% \iftoggle{bbx:eprint}% DELETED
% {\usebibmacro{eprint}}% DELETED
% {}% DELETED
% \newunit\newblock% DELETED
% \usebibmacro{url+urldate}% DELETED
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}
\DeclareBibliographyDriver{unpublished}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\printfield{howpublished}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{location+date}%
% \newunit\newblock% DELETED
% \iftoggle{bbx:url}% DELETED
% {\usebibmacro{url+urldate}}% DELETED
% {}% DELETED
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}