如何从 biblatex 书目中省略年份

如何从 biblatex 书目中省略年份

我正在使用如下所示的 bib 文件(保存为 ref.bib):

@article{key1, 
    author = {Joe Smith},
    journal={A journal}, 
    title = {An article}, 
    year = {2017}}

@article{key2, 
    author = {Joe Smith}, 
    title = {A second article}, 
    journal = {},
    year = {2017}, 
    pubstate={Draft}}

使用乳胶文件:

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\addbibresource{ref.bib}

\begin{document}
\section{ONE}
\begin{refsection}
  \nocite{key1}
  \printbibliography{}
\end{refsection}

\section{TWO}
\begin{refsection}
  \nocite{key2}
  \printbibliography{}
\end{refsection}
\end{document}

但我想从第二份参考书目中删除年份,因为这是一份未发表的草稿。我该怎么做呢?

答案1

使用@unpublishedpubstate领域。与

\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  \field{urldate}
  \field{pubstate}
  \literal{nodate}
}

您可以pubstate在参考书目中看到作者姓名后面的括号中的 。为了避免pubstate在这种情况下打印两次 ,我们重新定义了addendum+pubstate

这与 Andrew 的回答类似Biblatex:当设置 pubstate=forthcoming 时,如何获取“作者(即将出版)”,而不是“作者(nd)”?,但最终会简单一些。

平均能量损失

\documentclass{article}
\usepackage[backend=biber,style=authoryear]{biblatex}

\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  \field{urldate}
  \field{pubstate}
  \literal{nodate}
}

\renewbibmacro*{addendum+pubstate}{%
  \printfield{addendum}%
  \newunit\newblock
  \iffieldequalstr{labeldatesource}{pubstate}
    {}
    {\printfield{pubstate}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{key1, 
  author  = {Joe Smith},
  journal = {A journal}, 
  title   = {An article}, 
  year    = {2017},
}

@unpublished{key2, 
  author   = {Joe Smith}, 
  title    = {A second article}, 
  pubstate = {draft},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\cite{key1} and \cite{key2}.

\printbibliography
\end{document}

例子

相关内容