如何使用 biblatex 对条目集的子条目进行 `\textcite`?

如何使用 biblatex 对条目集的子条目进行 `\textcite`?

考虑以下 MWE。这里我有一个entryset,我想将其\texcite与中间条目(Weinberg 的论文)一起使用,这应该会产生Weinberg [1b]。但是,Glashow [1]尽管我使用了 选项,但它却打印了 ,即第一个条目,没有子条目subentry。如何使用 获得所需的结果\texcite{}

(这是biber2.2 和biblatex3.1)

\documentclass{article}
\usepackage[backend=biber,
            bibstyle=numeric-comp,
            sorting=none,
            subentry,
            ]{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}

Here is a set of references: \cite{stdmodel}.  Now I would like to
refer to just the middle one: \cite{weinberg}.  This works, but
trying to cite them by name fails: \textcite{weinberg} %%% Fails!
(This should read Weinberg~\cite{weinberg}.)

\printbibliography
\end{document}

在此处输入图片描述

答案1

现在,这确实很复杂……

的定义\textcite确实很复杂numeric-comp.cbx

主要思想是将 cite 命令包装在

\iffieldundef{childentrykey}
  {\usebibmacro{textcite}}
  {\begingroup
   \blx@getdata{\thefield{childentrykey}}%
   \usebibmacro{textcite}%
   \endgroup}

以便能够访问“子”条目的信息。

按照\textcite定义,这实际上是不可能的,我们需要克服很多困难才能实现这一目标

\documentclass{article}
\usepackage[backend=biber,
            style=numeric-comp,
            sorting=none,
            subentry,
            ]{biblatex}
\addbibresource{biblatex-examples.bib}

\makeatletter
\DeclareCiteCommand{\textcite}[\cbx@textcite@init\cbx@textcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite:init}}
  {\iffieldundef{childentrykey}
     {\global\undef\cbx@saved@childentrykey}
     {\xdef\cbx@saved@childentrykey{\thefield{childentrykey}}}%
   \iffieldundef{entrysetcount}
     {\global\undef\cbx@saved@entrysetcount}
     {\xdef\cbx@saved@entrysetcount{\thefield{entrysetcount}}}%
   \ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}

\DeclareCiteCommand{\cbx@textcite}
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \ifcsundef{cbx@saved@childentrykey}
    {\usebibmacro{textcite}}
    {\blx@ifdata{\cbx@saved@childentrykey}
       {\let\abx@field@entrysetcount\cbx@saved@entrysetcount%
        \begingroup
        \blx@getdata{\cbx@saved@childentrykey}%
        \usebibmacro{textcite}%
        \endgroup}
       {}}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}%
   \ifbool{cbx:parens}
     {\bibclosebracket\global\boolfalse{cbx:parens}}
     {}}
\makeatother

\begin{document}
Here is a set of references: \cite{stdmodel}.  Now I would like to
refer to just the middle one: \cite{weinberg}.  This works, but
trying to cite them by name fails: \textcite{weinberg} %%% Fails!
(This should read: Weinberg~\cite{weinberg}.)

\textcite{glashow}

\textcite{weinberg}

\textcite{salam}

\textcite{sigfridsson}

\printbibliography
\end{document}

示例输出

相关内容