如何在.bib 文件的注释字段中使用@STRING 变量?

如何在.bib 文件的注释字段中使用@STRING 变量?

@STRING在我的中定义了一个。围兜文件如下:

@STRING{mytext = {Last accessed: }}

这是参考书目中的条目。

@ARTICLE{knuth:1974,
  author = {Knuth, Donald E.},
  title = {{C}omputer {P}rogramming as an {A}rt},
  journal = {Communications of the ACM},
  year = {1974},
  volume = {17},
  pages = {667--673},
  number = {12},
  month = {December },
  address = {New York, NY, USA},
  publisher = {ACM Press},
  note = {Last accessed: 09/20/12}
}

我想将其用作mytext模板,以便轻松更改它。note但是,该字段包含的不仅仅是模板文本。
我如何mytextnote字段中使用变量?

答案1

我会这样做:

@string{mytext = "This is the text"}

然后在.bib条目中:

@ARTICLE{knuth:1974,
  author = {Knuth, Donald E.},
  title = {{C}omputer {P}rogramming as an {A}rt},
  journal = {Communications of the ACM},
  year = {1974},
  volume = {17},
  pages = {667--673},
  number = {12},
  month = {December },
  address = {New York, NY, USA},
  publisher = {ACM Press},
  note = mytext
}

note但是,如果字段包含的不仅仅是文本,这种方法就行不通了@string。你可以使用@preamble(如果你想在.bib文件中保留这样的命令):

@preamble{ "\newcommand{\mytext}{Last accessed:}" }

@ARTICLE{knuth:1974,
  author = {Knuth, Donald E.},
  title = {{C}omputer {P}rogramming as an {A}rt},
  journal = {Communications of the ACM},
  year = {1974},
  volume = {17},
  pages = {667--673},
  number = {12},
  month = {December },
  address = {New York, NY, USA},
  publisher = {ACM Press},
  note = {\mytext{} 09/20/12}
}

欲了解更多详细信息,请参阅尼古拉斯·马基 (Nicholas Markey) 的《驯服野兽》 (Tame the BeaST) texdoc ttb:。

答案2

您可以使用数字符号 # 连接 bib 文件中的字符串,但前提是字符串被双引号(而不是花括号)括起来。

@STRING{mytext = "Last accessed: "}

@ARTICLE{ key,
  ...
  note = mytext # "09/20/12"
}

看:http://www.bibtex.org/格式/

相关内容