当在参考列表中列出@online ressources 时,Biblatex 没有显示 shortauthor 吗?

当在参考列表中列出@online ressources 时,Biblatex 没有显示 shortauthor 吗?

我使用带有 authoryear-icomp 样式的 biblatex,我的 MWE 如下所示:

\documentclass[11pt]{report}    

\usepackage[
style=authoryear-icomp,
isbn=false,
pagetracker=true,
firstinits=false,
maxbibnames=50,
maxcitenames=3,
mincitenames=1,
autocite=inline,
block=space,
backref=false,
backrefstyle=three+,
date=short,
backend=biber,
uniquename=false, 
uniquelist=false,
dashed=false,
sorting=nyt,
bibencoding=utf8
]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{general.bib}
@book{bundesamt_fur_sicherheit_in_der_informationstechnik_bsi_it-grundschutzkataloge_2016,
    location = {Bonn},
    edition = {13. Ergänzungslieferung},
    title = {{IT}-Grundschutzkataloge},
    author = {{BSI (Bundesamt für Sicherheit in der Informationstechnik) }},
    shortauthor = {BSI},
    date = {2016},
}
@online{ibm,
author ={{International Business Machines Corporation}},
shortauthor = {{IBM}},
title = {2015 Cost of Data Breach Study},
year = {2015},
url = {http://www-03.ibm.com/security/data-breach/},
urldate = {2016-06-30},
}
\end{filecontents*}

\addbibresource{general.bib}

\DeclareBibliographyDriver{book}{% BOOK --> C:\texlive\2015\texmf-dist\tex\latex\biblatex\bbx\standard.bbx
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  {\printtext{\textbf
        {\usebibmacro{author/editor+others/translator+others}}}}
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{maintitle+title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \iffieldundef{author}
    {}
    {\newunit\newblock
     \usebibmacro{byeditor+others}}
  \newunit\newblock
  \printfield{edition}%
  \newunit
  \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{publisher+location+date}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit
  \printfield{pagetotal}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

\DeclareBibliographyDriver{online}{% Online --> C:\texlive\2015\texmf-dist\tex\latex\biblatex\bbx\standard.bbx
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  {\printtext{\textbf
        {\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\newblock
  \printlist{organization}%
  \newunit\newblock
  \usebibmacro{date}%
  \newunit\newblock
  \iftoggle{bbx:eprint}
    {\usebibmacro{eprint}}
    {}%
  \newunit\newblock
  \usebibmacro{url+urldate}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \newunit
  \printfield{note}%
  \usebibmacro{finentry}}


\begin{document}

\chapter{Einleitung}
\section*{}
@online ressource: \textcite[][]{bundesamt_fur_sicherheit_in_der_informationstechnik_bsi_it-grundschutzkataloge_2016}
\section*{}
@book ressource: \textcite[][]{ibm}

\clearpage

\addcontentsline{toc}{chapter}{Literaturverzeichnis}
\printbibliography[title={Literaturverzeichnis}]


\end{document}

我的问题是,biblatex 在参考文献列表中列出书籍时按预期打印了 shortauthor 字段。但是,当引用 @online 资源时,shortauthor 字段会被忽略,尽管使用了相同的 bibmacro。最后,我希望它看起来像这样,并且它只适用于书籍:

在此处输入图片描述

对于在线资源,短作者字段将被忽略:

在此处输入图片描述

我该如何改变这种情况?任何帮助都将不胜感激!抱歉我遗漏了一些内容,但我在使用 Latex 写作方面还只是个新手!

谢谢

答案1

你实际上不需要修改驱动程序,只需使用xpatch包裹。

\usepackage{xpatch}
\xpretobibmacro{author}{\begingroup\bfseries}{}{}
\xpatchbibmacro{author}
  {\printnames{author}}
  {\ifnameundef{shortauthor}
     {\printnames{author}}
     {\printnames{shortauthor}%
      \setunit{\addspace}%
      \printtext[parens]{\printnames{author}}}}
  {}{}
\xapptobibmacro{author}{\endgroup}{}{}

\xpretobibmacro{bbx:editor}{\begingroup\bfseries}{}{}
\xpatchbibmacro{bbx:editor}
  {\printnames{editor}}
  {\ifnameundef{shorteditor}
     {\printnames{editor}}
     {\printnames{shorteditor}%
      \setunit{\addspace}%
      \printtext[parens]{\printnames{editor}}}}
  {}{}
\xapptobibmacro{bbx:editor}{\endgroup}{}{}

\xpretobibmacro{bbx:translator}{\begingroup\bfseries}{}{}
\xpatchbibmacro{bbx:translator}
  {\printnames{translator}}
  {\ifnameundef{shorttranslator}
     {\printnames{translator}}
     {\printnames{shorttranslator}%
      \setunit{\addspace}%
      \printtext[parens]{\printnames{translator}}}}
  {}{}
\xapptobibmacro{bbx:translator}{\endgroup}{}{}

使用此代码,我们添加short<name>可用字段,然后将字段括<name>在括号中。此外,标签以粗体显示。

总共

\documentclass[11pt]{report}    

\usepackage[
style=authoryear-icomp,
isbn=false,
pagetracker=true,
firstinits=false,
maxbibnames=50,
maxcitenames=3,
mincitenames=1,
autocite=inline,
block=space,
backref=false,
backrefstyle=three+,
date=short,
backend=biber,
uniquename=false, 
uniquelist=false,
dashed=false,
sorting=nyt,
bibencoding=utf8
]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{general.bib}
@book{bundesamt_fur_sicherheit_in_der_informationstechnik_bsi_it-grundschutzkataloge_2016,
    location = {Bonn},
    edition = {13. Ergänzungslieferung},
    title = {{IT}-Grundschutzkataloge},
    author = {{Bundesamt für Sicherheit in der Informationstechnik}},
    shortauthor = {BSI},
    date = {2016},
}
@online{ibm,
author ={{International Business Machines Corporation}},
shortauthor = {{IBM}},
title = {2015 Cost of Data Breach Study},
year = {2015},
url = {http://www-03.ibm.com/security/data-breach/},
urldate = {2016-06-30},
}
\end{filecontents*}

\addbibresource{general.bib}

\usepackage{xpatch}
\xpretobibmacro{author}{\begingroup\bfseries}{}{}
\xpatchbibmacro{author}
  {\printnames{author}}
  {\ifnameundef{shortauthor}
     {\printnames{author}}
     {\printnames{shortauthor}%
      \setunit{\addspace}%
      \printtext[parens]{\printnames{author}}}}
  {}{}
\xapptobibmacro{author}{\endgroup}{}{}

\xpretobibmacro{bbx:editor}{\begingroup\bfseries}{}{}
\xpatchbibmacro{bbx:editor}
  {\printnames{editor}}
  {\ifnameundef{shorteditor}
     {\printnames{editor}}
     {\printnames{shorteditor}%
      \setunit{\addspace}%
      \printtext[parens]{\printnames{editor}}}}
  {}{}
\xapptobibmacro{bbx:editor}{\endgroup}{}{}

\xpretobibmacro{bbx:translator}{\begingroup\bfseries}{}{}
\xpatchbibmacro{bbx:translator}
  {\printnames{translator}}
  {\ifnameundef{shorttranslator}
     {\printnames{translator}}
     {\printnames{shorttranslator}%
      \setunit{\addspace}%
      \printtext[parens]{\printnames{translator}}}}
  {}{}
\xapptobibmacro{bbx:translator}{\endgroup}{}{}



\begin{document}

\chapter{Einleitung}
\section*{}
@online ressource: \textcite[][]{bundesamt_fur_sicherheit_in_der_informationstechnik_bsi_it-grundschutzkataloge_2016}
\section*{}
@book ressource: \textcite[][]{ibm}

\clearpage

\printbibliography[title={Literaturverzeichnis}, heading=bibintoc]
\end{document}

相关内容