当 biblatex 中的 'useauthor=false' 时,隐藏 'author' 字段

当 biblatex 中的 'useauthor=false' 时,隐藏 'author' 字段

我希望仅在我已将条目放入文件中的情况下才阻止biblatex打印by (name of author)参考书目。我假设我可以在序言中放置一个相对简单的命令来处理这个问题。下面是一个愚蠢的例子:OPTIONS = "useauthor=false".bib.tex

\documentclass{article}
\usepackage{csquotes}
\usepackage[
        bibstyle = authoryear,
        citestyle = authoryear-comp,
        sorting = nyt,
        language = american,
        abbreviate = false,
        backend = biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{bible,
    AUTHOR = "God",
    EDITOR = "James, King",
    TITLE = "The {H}oly {B}ible",
    YEAR = "1611",
    OPTIONS = "useauthor=false, useeditor=true"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\noindent
Text \parencite{bible}.
\printbibliography
\end{document}

在此处输入图片描述

答案1

有很多方法可以做到这一点;但其中一种简单的方法(根本不需要摆弄书目驱动程序)就是在为假时清除该author字段:useauthor

\AtEveryCitekey{\ifuseauthor{}{\clearname{author}}}
\AtEveryBibitem{\ifuseauthor{}{\clearname{author}}}

答案2

重新定义byauthorbibmacro 使其不执行任何操作。

\documentclass{article}
\usepackage{csquotes}
\usepackage[
        bibstyle = authoryear,
        citestyle = authoryear-comp,
        sorting = nyt,
        language = american,
        abbreviate = false,
        backend = biber]{biblatex}
\renewbibmacro*{byauthor}{}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{bible,
    AUTHOR = "God",
    EDITOR = "James, King",
    TITLE = "The {H}oly {B}ible",
    YEAR = "1611",
    OPTIONS = "useauthor=false, useeditor=true"}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\noindent
Text \parencite{bible}.
\printbibliography
\end{document}

在此处输入图片描述

比较原始版本byauthor

\newbibmacro*{byauthor}{%
  \ifboolexpr{
    test \ifuseauthor
    or
    test {\ifnameundef{author}}
  }
    {}
    {\usebibmacro{bytypestrg}{author}{author}%
     \setunit{\addspace}%
     \printnames[byauthor]{author}}}

相关内容