具有一位作者的 textcite 的自定义样式

具有一位作者的 textcite 的自定义样式

我正在使用 biblatex 来组织我的参考书目。如果 \textcite{ref} 仅引用一位作者,我想显示缩写的名字。请参阅以下 MWE。

\documentclass{report}

\usepackage{filecontents}
\usepackage[backend=biber, style=alphabetic, language=USenglish]{biblatex}

\begin{filecontents}{\jobname.bib}
@Article{ref1,
  Title                    = {Title 1},
  Author                   = {Duck, Donald and Mouse, Mickey and Goofy, Goofy and Duck, Daisy},
  Year                     = {2012},
  Month                    = {Oct},
  Number                   = {1},
}

@Article{ref2,
  Title                    = {The influenza virus M2 protein cytoplasmic tail interacts with the M1 protein and influences virus assembly at the site of virus budding},
  Author                   = {Duck, Donald},
  Year                     = {2008},
  Month                    = {Oct},
  Number                   = {20},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\textcite{ref1}

\textcite{ref2}
\end{document}

的输出\textcite{ref2}Duck [Duc08]。但是,我希望它是D. Duck [Duc08]。更多作者的风格不应该改变。

答案1

这是一种相当不一致的风格,但很容易实现stykle=alphabetic

\DeclareNameFormat{labelname}{%
  \ifboolexpr{test {\ifnumequal{\value{listcount}}{1}}
    and test {\ifnumequal{\value{liststop}}{1}}
    and not test \ifmorenames}
    {\ifuseprefix
       {\usebibmacro{name:given-family}
         {\namepartfamily}
         {\namepartgiveni}
         {\namepartprefix}
         {\namepartsuffixi}}
       {\usebibmacro{name:given-family}
         {\namepartfamily}
         {\namepartgiveni}
         {\namepartprefixi}
         {\namepartsuffixi}}}
    {\usebibmacro{name:family}
       {\namepartfamily}
       {\namepartgiven}
       {\namepartprefix}
       {\namepartsuffix}}%
  \usebibmacro{name:andothers}}

相关内容