如何在 Biblatex 中同时引用书籍(作者年份)和 url(作者)

如何在 Biblatex 中同时引用书籍(作者年份)和 url(作者)

我有一份书籍文档,我想使用 biblatex 包在文本中引用一本书(指作者年份)并引用一个 url(指作者)。它不会为我打印任何参考书目。你知道怎么做吗?

\documentclass{book}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@book{mybook,
author       = {Her Name},
date         = {2010},
title        = {Her title},
publisher    = {City: publisher},
}
@online{myurl,
author       = {his Name},
title        = {his title},
organization = {Wikibooks},
url          = {https://helping_each_other_and_i_help_u.com},
}
\end{filecontents}

\bibliography{\jobname}

\begin{document}
like to see \cite{mybook} try \cite{myurl}.
\printbibliography
\end{document}

答案1

对我来说,以这种方式引用作者没有任何实际意义。不过,这里有一个解决方案:

\documentclass{book}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
    @book{mybook,
        author       = {Her Name},
        date         = {2010},
        title        = {Her title},
        publisher    = {City: publisher},
    }
    @online{myurl,
        author       = {His Name},
        title        = {His title},
        organization = {Wikibooks},
        url          = {https://helping_each_other_and_i_help_u.com},
    }
\end{filecontents}
\DeclareNameFormat{family}{%
    \usebibmacro{name:family}
        {\namepartfamily}
        {\namepartgiven}
        {\namepartprefix}
        {\namepartsuffix}}
\newbibmacro*{name:family}[4]{\mkbibnamefamily{#1}\isdot}

\DeclareNameFormat{labelname}{\nameparts{#1}%
    \usebibmacro{name:given-family}{\namepartfamily}{\relax}{\relax}}
\DeclareNameFormat{author}{\nameparts{#1}%
    \usebibmacro{name:given-family}{\namepartfamily}{\relax}{\relax}}
\DeclareLabeldate{\field{date}\field{eventdate} \field{origdate}}

\addbibresource{\jobname.bib}

\begin{document}
    like to see \textcite{mybook} try \citeauthor{myurl}.
    \printbibliography
\end{document}

在此处输入图片描述 在此处输入图片描述

相关内容