BibLaTeX 引用在线资料时不打印年份

BibLaTeX 引用在线资料时不打印年份

我使用 authoryear citestyle,但我不想在引用在线来源时打印年份(但我希望在参考书目中显示日期)。

biber 版本是 2.7

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber, citestyle=authoryear]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{stackexchange,
    author = "{StackExchange}",
    title = {Tex StackExchange},
    url = {tex.stackexchange.com},
    urldate = {2017-12-10}
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

StackExchange is a Website\autocite{stackexchange}.

\end{document}

未注明年份的引用。

答案1

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber, citestyle=authoryear]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{stackexchange,
    author = "{StackExchange}",
    title = {Tex StackExchange},
    url = {tex.stackexchange.com},
    urldate = {2017-12-10}
}
\end{filecontents}

\addbibresource{\jobname.bib}


\newbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\printdelim{nonameyeardelim}}}
       {\printnames{labelname}%
        \setunit{\printdelim{nameyeardelim}}}%
        \ifentrytype{online}{}{%
             \usebibmacro{cite:labelyear+extrayear}%
     }}
    {\usebibmacro{cite:shorthand}}}


\begin{document}

StackExchange is a Website\autocite{stackexchange} a.

\printbibliography

\end{document}

相关内容