如何从 bib 文件中查找作者姓名,而不导致查找添加参考书目条目?

如何从 bib 文件中查找作者姓名,而不导致查找添加参考书目条目?

为了避免/检测作者姓名中的拼写错误,我希望使用 bib 文件作为姓名的单一来源。请参阅以下 mwe:

\documentclass{article}

\begin{filecontents}{demo.bib}
    @book{articleA,
        author = {Author, A.},
        year = {2001},
        title = {Alpha},
    }
    @book{articleB,
        author = {Author, A.},
        year = {2002},
        title = {Bravo},
    }
\end{filecontents}

\usepackage[style=alphabetic]{biblatex}
\addbibresource{demo.bib}

\newcommand{\authorA}{\citeauthor{articleA}}
\newcommand{\authorAL}{\citename{articleA}{author}}

\begin{document}
 
The lookup seems to work fine using biblatex's \textbackslash citeauthor and/or 
\textbackslash citename commands.
The only problem I have is, that a lookup always adds an entry (here: 
[Aut01]) to the bibliography, eg.:

Hi, my name is \authorA.

Thus my question is:
How to lookup the author's name from bib file, without causing the lookup to
add a bibliography entry?

\printbibliography

\end{document}

答案1

达到您需要的一个干净的方法是为您不想在参考文献中打印的引文创建一个书目类别,然后打印没有该类别的书目(请参阅这个答案)。

\documentclass{article}

\begin{filecontents}[overwrite]{demo.bib}
    @book{articleA,
        author = {Author, A.},
        year = {2001},
        title = {Alpha},
    }
    @book{articleB,
        author = {Buthor, B.},
        year = {2002},
        title = {Bravo},
    }
    @book{articleC,
        author = {Cuthor, C.},
        year = {2002},
        title = {Charlie},
    }
\end{filecontents}

\usepackage[style=alphabetic]{biblatex}
\addbibresource{demo.bib}

% see https://tex.stackexchange.com/a/111375/101651
\DeclareBibliographyCategory{nottocite}

\newcommand{\authorA}{\citeauthor{articleA}\addtocategory{nottocite}{articleA}}

\newcommand{\nameauthor}[1]{\citeauthor{#1}\addtocategory{nottocite}{#1}}
  
\begin{document}
 
Hi, my name is \authorA.

Or, more general \nameauthor{articleB}.

Pay attention: if you want them in bibliography, use \citeauthor{articleC}, not the previous commands.
 
\printbibliography[notcategory=nottocite]

\end{document}

在此处输入图片描述

相关内容