抑制期刊文章的月份和日期并保留报纸文章的月份和日期

抑制期刊文章的月份和日期并保留报纸文章的月份和日期

我还没有找到这个问题的解决方案。我想在参考书目中删除所有期刊文章中的月份和日期(如果有的话),但同时我想为报纸或杂志文章指明年月日。

由于期刊和报纸文章都以@articlebibtex 格式标注,因此这个问题变得复杂。一种可能的解决方案是,只有当@article条目包含一个或两个字段时volumenumber因此假设它实际上是一篇期刊文章),才有选择地删除月份和日期。

我曾经考虑过这样的事情,但我的 TeX 不是那么好......

\AtEveryBibitem{%
  \ifentrytype{article}{%
% AND IF entry contains {number} and/or {volume}
    \clearfield{month}%
    \clearfield{day}%
  }{%
  }%
}

这里是 MWE

\documentclass[a4paper]{article}

\RequirePackage{filecontents}

\begin{filecontents*}{mybib.bib}
  @article{test1,
    title = {Ideas \& trends; politics of the web: {Meet}, greet, segregate, meet again},
    url = {http://www.nytimes.com/2004/01/25/weekinreview/ideas-trends-politics-of-the-web-meet-greet-segregate-meet-again.html},
    urldate = {2014-01-14},
    journal = {New {York} {Times}},
    author = {Harmon, Amy},
    day = {01},
    month = jan,
    year = {2004},
  }
  @article{test2,
    title = {Social movement networks virtual and real},
    volume = {3},
    issn = {1369-118X},
    url = {http://www.tandfonline.com/doi/abs/10.1080/13691180051033333},
    doi = {10.1080/13691180051033333},
    number = {3},
    urldate = {2013-05-31},
    journal = {Information, {Communication} \& {Society}},
    author = {Diani, Mario},
    month = jan,
    year = {2000},
    pages = {386--401}
  }
}
\end{filecontents*}

% Set the values for the bibliography
\usepackage[
style=apa,
backend=biber
]{biblatex}

\usepackage[utf8]{inputenc}

% Set language
\usepackage[british]{babel}
\DeclareLanguageMapping{british}{british-apa}

\addbibresource{mybib.bib}

\begin{document}

\cite{test1}

\cite{test2}


\printbibliography
\end{document}

答案1

魔法条件语句可以使用以下方式构建etoolbox's \ifboolexpr(etoolboxbiblatex;另请参阅etoolbox手动的biblatex文档,特别是§4.6.3测试\ifboolexpr\ifthenelse,第 179 页)。

我们\ifboolexpr可以使用biblatex(参见独立测试,第 171-179 页biblatex文档):我们只需test在测试前添加一个,并将命令括在花括号中,我们还省略了“真”和“假”分支。所以\iffieldundef{volume}{true}{false}变成了\ifboolexpr{test {\iffieldundef{volume}}}{true}{false};的妙处\ifboolexpr在于我们可以使用逻辑运算符来连接表达式。

在本例中,我们有

\AtEveryBibitem{%
  \ifboolexpr{test {\ifentrytype{article}} and (not test {\iffieldundef{number}} or not test {\iffieldundef{volume}})}
    {\clearfield{month}%
     \clearfield{day}}
     {}%
}

这将删除具有或字段的monthday字段(或两者,因为是逻辑上的包含或)。@articlesnumbervolumeor


您还可以利用该entrysubtype字段,只需添加到来自报纸的entrysubtype = {newspaper}每个条目中(令人惊讶的是)。@article

@article{test1,
  title         = {Ideas \& trends; politics of the web: {Meet}, greet, segregate, meet again},
  url           = {http://www.nytimes.com/2004/01/25/weekinreview/ideas-trends-politics-of-the-web-meet-greet-segregate-meet-again.html},
  urldate       = {2014-01-14},
  journal       = {New {York} {Times}},
  author        = {Harmon, Amy},
  day           = {01},
  month         = jan,
  year          = {2004},
  entrysubtype  = {newspaper},%<---- here it is
}

然后我们使用条件

\AtEveryBibitem{%
  \ifboolexpr{test {\ifentrytype{article}} and not test {\iffieldequalstr{entrysubtype}{newspaper}}}
    {\clearfield{month}%
     \clearfield{day}}
    {}%
}

删除month并且day从中@articles不存在newspaper @articles


平均能量损失

\documentclass[a4paper]{article}
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{test1,
  title         = {Ideas \& trends; politics of the web: {Meet}, greet, segregate, meet again},
  url           = {http://www.nytimes.com/2004/01/25/weekinreview/ideas-trends-politics-of-the-web-meet-greet-segregate-meet-again.html},
  urldate       = {2014-01-14},
  journal       = {New {York} {Times}},
  author        = {Harmon, Amy},
  day           = {01},
  month         = jan,
  year          = {2004},
  %entrysubtype  = {newspaper},
}
@article{test2,
  title     = {Social movement networks virtual and real},
  volume    = {3},
  issn      = {1369-118X},
  url       = {http://www.tandfonline.com/doi/abs/10.1080/13691180051033333},
  doi       = {10.1080/13691180051033333},
  number    = {3},
  urldate   = {2013-05-31},
  journal   = {Information, {Communication} \& {Society}},
  author    = {Diani, Mario},
  month     = jan,
  year      = {2000},
  pages     = {386--401},
}
\end{filecontents*}

\usepackage[
  style=apa,
  backend=biber
]{biblatex}

\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\DeclareLanguageMapping{british}{british-apa}

\addbibresource{\jobname.bib}

\AtEveryBibitem{%
  \ifboolexpr{test {\ifentrytype{article}} and (not test {\iffieldundef{number}} or not test {\iffieldundef{volume}})}
  %\ifboolexpr{test {\ifentrytype{article}} and not test {\iffieldequalstr{entrysubtype}{newspaper}}}
    {\clearfield{month}%
     \clearfield{day}}
    {}%
}

\begin{document}
  Lorem \parencite{test1} ipsum \parencite{test2}.

  \printbibliography
\end{document}

在此处输入图片描述

答案2

新的吸水工程为 OP 的要求提供了另一种解决方案。虽然 Bibulous 可以检查是否存在充当标志的字段(在 @moewe 提供的 BibLatex 解决方案中,使用该entrysubtype字段),但 Bibulous 的一个更简洁的解决方案是简单地为报纸文章定义一个新的条目类型,以将其与期刊文章区分开来。因此,使用以下数据库文件main.bib

@newsarticle{test1,
  title = {Ideas \& trends; politics of the web: {Meet}, greet, segregate, meet again},
  url = {http://www.nytimes.com/2004/01/25/weekinreview/ideas-trends-politics-of-the-web-meet-greet-segregate-meet-again.html},
  urldate = {2014-01-14},
  journal = {New York Times},
  author = {Harmon, Amy},
  day = {1},
  month = jan,
  year = {2004}
}

@article{test2,
  title = {Social movement networks virtual and real},
  volume = {3},
  issn = {1369-118X},
  url = {http://www.tandfonline.com/doi/abs/10.1080/13691180051033333},
  doi = {10.1080/13691180051033333},
  number = {3},
  urldate = {2013-05-31},
  journal = {Information, Communication \& Society},
  author = {Diani, Mario},
  month = jan,
  year = {2000},
  pages = {386--401}
}

我们可以开发一个 Bibulous 格式的样式文件,main.bst例如

TEMPLATES:
article = <au> (<year>). <title>. \textit{<journal>} \textit{<volume>}(<number>),{ }...
          [<startpage>--<endpage>|<startpage>|<eid>|].[ doi:\url{<doi>}| url:\url{<url>}]
newsarticle = <au> (<year>, <month.monthname()> <day>). <title>.{ }...
          \textit{<journal>}. Retrieved <urldate>, from \url{<url>}.

SPECIAL-TEMPLATES:
authorlist = <author.to_namelist()>
editorlist = <editor.to_namelist()>
au = <authorlist.format_authorlist()>
ed = <editorlist.format_editorlist()>
citelabel = (<authorlist.0.last>, <year>)

OPTIONS:
namelist_format = last_name_first

(上面的块显示了整个样式文件。)最后,我们需要重新定义\@biblabel\@cite宏,以使 Latex 在文本中使用正确的引用标签。因此,main.tex文件将如下所示

\documentclass{article}
\usepackage[paper=letterpaper, text={6.2in,8.5in},centering]{geometry}
\usepackage[colorlinks=True,urlcolor=blue,citecolor=black,breaklinks=true]{hyperref}

\makeatletter
   \renewcommand{\@biblabel}[1]{}
   \renewcommand{\@cite}[2]{{#1\if@tempswa , #2\fi}}
\makeatother

\begin{document}

Lorem \cite{test1} ipsum \cite{test2}.

\bibliography{example9}
\bibliographystyle{example9}

\end{document}

编译后,将生成如下所示的格式化的参考列表:

格式化的参考文献列表

相关内容