biblatex:每个条目的 backref 选项

biblatex:每个条目的 backref 选项

biblatex' backref默认情况下只能全局设置选项。我想要实现的是针对单个书目关闭和打开它。这样其中一个printbibliography启用backref,另一个不启用。这可能吗?

编辑

这是 MWE。目标是启用backref电影目录,即第二个书目。

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\usepackage[style=fiwi,]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{bib.bib}
@incollection{Muller.M:2014a,
Address = {Baden-Baden},
Author = {Müller, Martin},
Booksubtitle = {Zum Staatsverständnis in den klassischen Utopien},
Booktitle = {Idealstaat oder Gedankenexperiment?},
Editor = {Schölderle, Thomas},
Pages = {287--304},
Publisher = {Nomos},
Title = {Richard Rortys \emph{Contingency, Irony, and Solidarity} (1989)},
Year = {2014}}
@movie{Kubrick.S:1964,
Address = {GB},
Author = {Kubrick, Stanley},
Shorttitle = {Dr. Strangelove},
Subtitle = {Dr. Seltsam oder Wie ich lernte, die Bombe zu lieben},
Title = {Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb},
Year = {1964}
}
\end{filecontents*}
\addbibresource{bib.bib}
\begin{document}
\cite{Muller.M:2014a}
\citefilm{Kubrick.S:1964}
\printbibliography[nottype=movie]
\newrefcontext[sorting=title]
\printbibliography[type=movie]
\end{document}

答案1

有多种方法可以实现此目的。

首先,backref=true全局启用。

如果您只希望movies 具有反向引用,请相应地修改宏。

\renewbibmacro*{pageref}{%
  \ifboolexpr{not test {\iflistundef{pageref}} and test {\ifentrytype{movie}}}
    {\printtext[parens]{%
       \ifnumgreater{\value{pageref}}{1}
         {\bibstring{backrefpages}\ppspace}
         {\bibstring{backrefpage}\ppspace}%
       \printlist[pageref][-\value{listtotal}]{pageref}}}%
   {}}

使用此方法,backref 不依赖于参考书目,而是依赖于条目类型(在您的 MWE 中,两者一致,也许这是您通常想要的,也可能不是)。


或者,你可以在下一个参考书目中使用以下代码来抑制反向引用

\AtNextBibliography{\renewbibmacro*{pageref}{}}
\printbibliography[nottype=movie]

或者反过来删除pageref定义,但恢复相关参考书目

\savebibmacro{pageref}
\renewbibmacro*{pageref}{}

\begin{document}
\cite{Muller.M:2014a}
\citefilm{Kubrick.S:1964}

\printbibliography[nottype=movie]

\newrefcontext[sorting=title]
\AtNextBibliography{\restorebibmacro{pageref}}
\printbibliography[type=movie]
\end{document}

不幸的是,\printbibliography没有其他可以使用的预编码参数。

下面是一个概念证明,它为我们提供了前置代码和后置代码,我们可以从中直接执行任意代码\printbibliography

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{csquotes}
\usepackage[style=fiwi,backref=true]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@incollection{Muller.M:2014a,
Address = {Baden-Baden},
Author = {Müller, Martin},
Booksubtitle = {Zum Staatsverständnis in den klassischen Utopien},
Booktitle = {Idealstaat oder Gedankenexperiment?},
Editor = {Schölderle, Thomas},
Pages = {287--304},
Publisher = {Nomos},
Title = {Richard Rortys \emph{Contingency, Irony, and Solidarity} (1989)},
Year = {2014}}
@movie{Kubrick.S:1964,
Address = {GB},
Author = {Kubrick, Stanley},
Shorttitle = {Dr. Strangelove},
Subtitle = {Dr. Seltsam oder Wie ich lernte, die Bombe zu lieben},
Title = {Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb},
Year = {1964}
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\savebibmacro{pageref}
\renewbibmacro*{pageref}{}

\makeatletter
\define@key{blx@bib1}{precode}{}
\define@key{blx@biblist1}{precode}{}
\define@key{blx@bib2}{precode}{\blx@key@precode{#1}}
\define@key{blx@biblist2}{precode}{\blx@key@precode{#1}}

\def\blx@key@precode#1{\def\blx@hook@option@precode{#1}}

\define@key{blx@bib1}{postcode}{}
\define@key{blx@biblist1}{postcode}{}
\define@key{blx@bib2}{postcode}{\blx@key@postcode{#1}}
\define@key{blx@biblist2}{postcode}{\blx@key@postcode{#1}}

\def\blx@key@postcode#1{\def\blx@hook@option@postcode{#1}}

\def\blx@bibliography{%
  \blx@langstrings
  \blx@bibheading\blx@theheading\blx@thetitle
  \blx@bibnote\blx@theprenote
  \begingroup
  \blx@bibinit
  \let\@noitemerr\@empty
  \let\blx@noitem\blx@warn@bibempty
  \ifnum\bibinitsep=\z@
    \let\blx@initsep\relax
  \fi
  \ifnum\bibnamesep=\z@
    \let\blx@namesep\relax
  \fi
  \csuse{blx@env@\blx@theenv}%
  \csuse{blx@hook@bibinit}%
  \csuse{blx@hook@bibinit@next}%
  \csuse{blx@hook@option@precode}% <--- this is new
  \let\blx@do\blx@bibitem
  \let\blx@done\blx@endbibliography
  \blx@listloop}

\def\blx@endbibliography{%
  \csuse{blx@hook@option@postcode}% <--- this is new
  \csuse{blx@endenv@\blx@theenv}%
  \blx@noitem
  \endgroup
  \blx@bibnote\blx@thepostnote
  \endgroup}
\makeatother


\begin{document}
\cite{Muller.M:2014a}
\citefilm{Kubrick.S:1964}

\printbibliography[nottype=movie]

\newrefcontext[sorting=title]
\printbibliography[type=movie,precode={\restorebibmacro{pageref}}]
\end{document}

答案2

您可以定义一个新的引用命令( ),其中\citenbf没有 backref 调用\backtrackerref预编码\cite部分(源自中的原始命令fiwi.cbx):

\DeclareCiteCommand{\citenbf}
  {\backtrackerfalse\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}

您修改后的示例:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\usepackage[style=fiwi,backref]{biblatex}
\DeclareCiteCommand{\citenbf}
  {\backtrackerfalse\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{cite:postnote}}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@incollection{Muller.M:2014a,
Address = {Baden-Baden},
Author = {Müller, Martin},
Booksubtitle = {Zum Staatsverständnis in den klassischen Utopien},
Booktitle = {Idealstaat oder Gedankenexperiment?},
Editor = {Schölderle, Thomas},
Pages = {287--304},
Publisher = {Nomos},
Title = {Richard Rortys \emph{Contingency, Irony, and Solidarity} (1989)},
Year = {2014}}
@movie{Kubrick.S:1964,
Address = {GB},
Author = {Kubrick, Stanley},
Shorttitle = {Dr. Strangelove},
Subtitle = {Dr. Seltsam oder Wie ich lernte, die Bombe zu lieben},
Title = {Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb},
Year = {1964}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\citenbf{Muller.M:2014a}
\citefilm{Kubrick.S:1964}
\printbibliography[nottype=movie]
\newrefcontext[sorting=title]
\printbibliography[type=movie]
\end{document}

在此处输入图片描述

相关内容