如何更改 IEEETran.bst 文件以忽略日期中的月份?

如何更改 IEEETran.bst 文件以忽略日期中的月份?

我正在用 Lyx 写论文,用 BibTex 创建参考书目。我的 .bib 由 Mendeley 生成。因此,我试图找到一种方法来更改我的 IEEEtran.bst 样式文件以忽略 BibTeX 的月份。

目前输出包括出版的月份和年份:

...,2017 年 12 月

但我需要删除每个条目的月份。由于该.bib文件是由 Mendeley 生成的,因此我无法更改它。此外,手动删除月份也不起作用,因为 Mendeley 会自动更新这些信息。

IEEETran 文件中日期的函数如下所示:

FUNCTION {format.date}
{
  month "month" bibinfo.check duplicate$ empty$
  year  "year" bibinfo.check duplicate$ empty$
    { swap$ 'skip$
        { this.to.prev.status
          this.status.std
          cap.status.std
         "there's a month but no year in " cite$ * warning$ }
      if$
      *
    }
    { this.to.prev.status
      this.status.std
      cap.status.std
      swap$ 'skip$
        {
          swap$
          " " * swap$
        }
      if$
      *
    }
  if$
}

问题是我真的不知道该怎么改才能忽略月份。我尝试了许多删除部分的组合。但我仍然找不到解决方案……有人能帮我吗?

答案1

对于@articleformat.date必须像这样更改:

FUNCTION {format.date}
{
  "" duplicate$ empty$
  year  "year" bibinfo.check duplicate$ empty$
    { swap$ 'skip$
        { this.to.prev.status
          this.status.std
          cap.status.std
         "there's a month but no year in " cite$ * warning$ }
      if$
      *
    }
    { this.to.prev.status
      this.status.std
      cap.status.std
      swap$ 'skip$
        {
          swap$
          " " * swap$
        }
      if$
      *
    }
  if$
}

而对于@inproceedingsformat.address.org.or.pub.date必须进行修改。

FUNCTION {format.address.org.or.pub.date}
{ 't :=
  ""
  year empty$
    { "empty year in " cite$ * warning$ }
    { skip$ }
  if$
  address empty$ t empty$ and
  year empty$ and month empty$ and
    { skip$ }
    { this.to.prev.status
      this.status.std
      cap.status.std
      address "address" bibinfo.check *
      t empty$
        { skip$ }
        { punct.period 'prev.status.punct :=
          space.large 'prev.status.space :=
          address empty$
            { skip$ }
            { ": " * }
          if$
          t *
        }
      if$
      year empty$ month empty$ and
        { skip$ }
        { t empty$ address empty$ and
            { skip$ }
            { ", " * }
          if$
          month empty$
            { year empty$
                { skip$ }
                { year "year" bibinfo.check * }
              if$
            }
            { year empty$
                 { skip$ }
                 { " " * year "year" bibinfo.check * }
              if$
            }
          if$
        }
      if$
    }
  if$
}

在此处输入图片描述

\documentclass[journal]{IEEEtran}
\usepackage{filecontents}
\begin{filecontents}{refs.bib}
@article{fuext1,
    year={2004},
    month={May},
    booktitle={$23^{rd}$ International Conference on the Theory and Applications of Cryptographic Techniques (EUROCRYPT)},
    volume={3027},
    title={Fuzzy Extractors: How to Generate Strong Keys from Biometrics and Other Noisy Data},
    publisher={{LNCS}, Springer Berlin Heidelberg},
    author={Dodis, Yevgeniy and Reyzin, Leonid and Smith, Adam},
    address={Interlaken, Switzerland},
    pages={523-540},
}

@inproceedings{fuext2,
    year={2004},
    month={May},
    booktitle={$23^{rd}$ International Conference on the Theory and Applications of Cryptographic Techniques (EUROCRYPT)},
    volume={3027},
    title={Fuzzy Extractors: How to Generate Strong Keys from Biometrics and Other Noisy Data},
    author={Dodiz, Yevgeniy and Reyzin, Leonid and Smith, Adam},
    address={Interlaken, Switzerland, {LNCS}, Springer Berlin Heidelberg},
    pages={523-540},
}
\end{filecontents}

\begin{document}
Article \cite{fuext1} and Proceedings \cite{fuext2}.
\bibliographystyle{IEEEtran}
\bibliography{refs}
\end{document}

答案2

BibTeX 语法可能相当令人困惑——最简单的解决方案有时是从具有更简单语法的更基本的参考书目样式中复制一个函数。

以下内容修改自abbrvnat.bst

FUNCTION {format.date}
{ year  "year" bibinfo.check duplicate$ empty$
    { "empty year in " cite$ * warning$
       pop$ "" }
    'skip$
  if$
}

请注意,IEEEtran.bst对于条目使用单独的日期格式化函数inproceedings,因此也应该进行编辑:

FUNCTION {format.address.org.or.pub.date}
{ 't :=
  ""
  year empty$
    { "empty year in " cite$ * warning$ }
    { skip$ }
  if$
  address empty$ t empty$ and
  year empty$ and month empty$ and
    { skip$ }
    { this.to.prev.status
      this.status.std
      cap.status.std
      address "address" bibinfo.check *
      t empty$
        { skip$ }
        { punct.period 'prev.status.punct :=
          space.large 'prev.status.space :=
          address empty$
            { skip$ }
            { ": " * }
          if$
          t *
        }
      if$
      year empty$ month empty$ and
        { skip$ }
        { t empty$ address empty$ and
            { skip$ }
            { ", " * }
          if$
          month empty$
            { year empty$
                { skip$ }
                { year "year" bibinfo.check * }
              if$
            }
            { year empty$ % removed printing the month string here
                 { skip$ }
                 { " " * year "year" bibinfo.check * }
              if$
            }
          if$
        }
      if$
    }
  if$
}

MWE 使用修改后的IEEEtran.bst

\documentclass{article}
\begin{filecontents}{\jobname.bib}
@article{articlemonth,
  author = {Mary Jones},
  title = {First Things},
  journal = {Journal of Things},
  month = {jan},
  year = {2017}
}

@inproceedings{proceedingsmonth,
  author = {Joe Peterson},
  title = {Briefly Explained},
  booktitle = {Conference of Briefness},
  month = {feb},
  year = {2017}
}
\end{filecontents}
\begin{document}
See \cite{articlemonth,proceedingsmonth}.

\bibliographystyle{IEEEtranmod}
\bibliography{\jobname}
\end{document}

结果:

在此处输入图片描述

相关内容