Skip to content

Commit

Permalink
@misc: Improve formatting of arXiv preprints
Browse files Browse the repository at this point in the history
May be considered as `acl_natbib_nourl.bst` for urlbst processing

Works with `@misc` type only.
Supports `archivePrefix` or `eprinttype`.
Sets `arXiv preprint` if `publisher = {arXiv}` and no `eprint` number is provided.
This will work with arXiv generated bibs (more info at https://tex.stackexchange.com/a/679743) and some doi2bib.org bibs generated from arxiv doi.

No support for `primaryClass` (no example from ACL), no detection of versions from `url` (seems too hard to me), and no support for `@article` with `eprint` from DBLP (too much to test for now — may get worse).

P.S. This addition was originally inspired by `output.eprint` from `ACM-Reference-Format.bst` from acmart, but later diverged.
  • Loading branch information
LSinev committed Mar 9, 2024
1 parent 6820d08 commit 3f2dffa
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions latex/acl_natbib.bst
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@

ENTRY
{ address
archivePrefix
author
booktitle
chapter
edition
editor
eid
eprint
eprinttype % = archivePrefix
howpublished
institution
journal
Expand Down Expand Up @@ -893,6 +896,45 @@ FUNCTION {format.organization.address}
{ organization "organization" bibinfo.check format.org.or.pub
}

FUNCTION {archiveprefix.or.eprinttype} % holder for eprinttype with archiveprefix precedence
{
archiveprefix empty$
{
eprinttype empty$
{ "" } % not using 'skip$ to reduce errors like "nothing to pop from stack"
{ eprinttype }
if$
}
{ archiveprefix }
if$
}

FUNCTION {output.eprint} % this is only used with the @misc record type (common for arXiv and other preprint server bibtex records)
{
eprint empty$
{% if eprint field is empty
publisher field.or.null "arXiv" = % field.or.null here helps when no publisher field in the record
{ publisher " preprint" * } % add " preprint" to publisher with the idea that publisher is the name of the preprint server
{ "" } % if publisher != "arXiv" then empty output
if$
emphasize % no output function after emphasize because nothing goes after this
}
{% if eprint field is not empty
archiveprefix.or.eprinttype empty$
{ "" } % not using 'skip$ to reduce errors like "nothing to pop from stack"
{% if archiveprefix or eprinttype fields are not empty
journal empty$
{ "Preprint" } % if journal field is empty: output just "Preprint" emphasized like a journal name
{ journal } % if journal field is not empty, output it (takes precedence)
if$
emphasize output % emphasize what we formed before, setting output as a border to the subblock that follows with the comma delimiter
archiveprefix.or.eprinttype ":" * eprint * % subblock with eprinttype and eprint number
}
if$
}
if$
}

FUNCTION {article}
{ output.bibitem
format.authors "author" output.check
Expand Down Expand Up @@ -1098,6 +1140,8 @@ FUNCTION {misc}
new.block
howpublished "howpublished" bibinfo.check output
new.block
output.eprint output
new.block
format.note output
fin.entry
}
Expand Down

0 comments on commit 3f2dffa

Please sign in to comment.