diff --git a/ACM-Reference-Format.bst b/ACM-Reference-Format.bst index ea3f35a..c47cb4c 100644 --- a/ACM-Reference-Format.bst +++ b/ACM-Reference-Format.bst @@ -3,7 +3,8 @@ %%% @BibTeX-style-file{ %%% author = "Nelson H. F. Beebe, Boris Veytsman and Gerald Murray", %%% version = "2.1", -%%% date = "14 June 2017", +%%% acmart-version = "1.90", +%%% date = "Mar 26 2023", %%% filename = "ACM-Reference-Format.bst", %%% email = "borisv@lk.net, boris@varphi.com", %%% codetable = "ISO/ASCII", @@ -23,15 +24,18 @@ ENTRY author booktitle chapter - city - date + city + date edition editor eprint + eprinttype + eprintclass howpublished institution journal key + location month note number @@ -48,7 +52,7 @@ ENTRY % New keys recognized issue % UTAH: used in, e.g., ACM SIGSAM Bulletin and ACM Communications in Computer Algebra articleno - eid + eid day % UTAH: needed for newspapers, weeklies, bi-weeklies doi % UTAH url % UTAH @@ -60,6 +64,7 @@ ENTRY isbn-13 % UTAH issn % UTAH lccn % UTAH + distinctURL % whether to print url if doi is present } {} { label.year extra.label sort.year sort.label basic.label.year} @@ -146,6 +151,16 @@ FUNCTION { empty.or.unknown } if$ } +FUNCTION { empty.or.zero } +{ + %% Examine the top entry and push 1 if it is empty, or is zero + duplicate$ empty$ + { pop$ #1 } + { "0" = } + if$ +} + + FUNCTION { writeln } { %% In BibTeX style files, the sequences @@ -423,6 +438,44 @@ FUNCTION { output.coden } % UTAH if$ } +% +% Sometimes articleno starts with the word 'Article' or 'Paper. +% (this is a bug of acmdl, sigh) +% We strip them. We assume eid or articleno is already on stack +% + +FUNCTION { strip.articleno.or.eid } +{ + 't := + t #1 #7 substring$ "Article" = + {t #8 t text.length$ substring$ 't :=} + { } + if$ + t #1 #7 substring$ "article" = + {t #8 t text.length$ substring$ 't :=} + { } + if$ + t #1 #5 substring$ "Paper" = + {t #6 t text.length$ substring$ 't :=} + { } + if$ + t #1 #5 substring$ "paper" = + {t #6 t text.length$ substring$ 't :=} + { } + if$ + % Strip any left trailing space or ~ + t #1 #1 substring$ " " = + {t #2 t text.length$ substring$ 't :=} + { } + if$ + t #1 #1 substring$ "~" = + {t #2 t text.length$ substring$ 't :=} + { } + if$ + t +} + + FUNCTION { format.articleno } { articleno empty.or.unknown not eid empty.or.unknown not and @@ -433,25 +486,25 @@ FUNCTION { format.articleno } { "" } { numpages empty.or.unknown - { "articleno or eid field, but no numpages field, in " + { "articleno or eid field, but no numpages field, in " cite$ * warning$ } { } if$ - eid empty.or.unknown - { "Article \bibinfo{articleno}{" articleno * "}" * } - { "Article \bibinfo{articleno}{" eid * "}" * } + eid empty.or.unknown + { "Article \bibinfo{articleno}{" articleno strip.articleno.or.eid * "}" * } + { "Article \bibinfo{articleno}{" eid strip.articleno.or.eid * "}" * } if$ } if$ } FUNCTION { format.year } -{ % push year string or "[n. d.]" onto output stack +{ % push year string or "[n.\,d.]" onto output stack %% Because year is a mandatory field, we always force SOMETHING %% to be output "\bibinfo{year}{" year empty.or.unknown - { "[n. d.]" } + { "[n.\,d.]" } { year } if$ * "}" * @@ -504,15 +557,14 @@ FUNCTION { strip.doi } % UTAH % result on the output stack, as recommended by CrossRef DOI % documentation. % For example, reduce "http://doi.acm.org/10.1145/1534530.1534545" to - % "10.1145/1534530.1534545". That is later typeset and displayed as - % doi:10.1145/1534530.1534545 as the LAST item in the reference list - % entry. Publisher Web sites wrap this with a suitable link to a real - % URL to resolve the DOI, and the master https://doi.org/ address is - % preferred, since publisher-specific URLs can disappear in response - % to economic events. All journals are encouraged by the DOI - % authorities to use that typeset format and link procedures for - % uniformity across all publications that include DOIs in reference - % lists. + % "10.1145/1534530.1534545". A suitable URL is later typeset and + % displayed as the LAST item in the reference list entry. Publisher Web + % sites wrap this with a suitable link to a real URL to resolve the DOI, + % and the master https://doi.org/ address is preferred, since publisher- + % specific URLs can disappear in response to economic events. All + % journals are encouraged by the DOI authorities to use that typeset + % format and link procedures for uniformity across all publications that + % include DOIs in reference lists. % The numeric prefix is guaranteed to start with "10.", so we use % that as a test. % 2017-02-04 Added stripping of https:// (Boris) @@ -578,14 +630,11 @@ FUNCTION { output.doi } % UTAH doi empty.or.unknown { } { - %% NB: We want URLs at beginning of line to reduce likelihood of - %% BibTeX's nasty line wrapping after column 79, which then requires - %% manual (or automated) editing of the .bbl file to repair. - %% The \url{} macro strips percent-newlines, and is thus safe in - %% the presence of the line wrapping, but \path|...| and - %% \verb|...| do not. - "\showDOI{%" writeln - "\url{https://doi.org/" strip.doi * "}}" * writeln + %% Use \urldef here for the same reason it is used in output.url, + %% see output.url for further discussion. + "\urldef\tempurl%" writeln + "\url{https://doi.org/" strip.doi * "}" * writeln + "\showDOI{\tempurl}" writeln } if$ } @@ -655,7 +704,7 @@ FUNCTION { output.note } % UTAH { % return with stack empty note empty.or.unknown { } - { "\shownote{" note add.period$ * "}" * writeln } + { "\shownote{" note * "}" add.period$ * writeln } if$ } @@ -663,7 +712,7 @@ FUNCTION { output.note.check } % UTAH { % return with stack empty note empty.or.unknown { "empty note in " cite$ * warning$ } - { "\shownote{" note add.period$ * "}" * writeln } + { "\shownote{" note * "}" add.period$ * writeln } if$ } @@ -673,15 +722,22 @@ FUNCTION { output.eprint } % { } { "\showeprint" archiveprefix empty.or.unknown - { } - { "[" archiveprefix "l" change.case$ "]" * * * } + { eprinttype empty.or.unknown + { } + { "[" eprinttype "]" * * * } + if$ + } + { "[" archiveprefix "l" change.case$ "]" * * * } if$ - "{" * + "{" eprint "}" * * * primaryclass empty.or.unknown - { } - { primaryclass "/" * *} + { eprintclass empty.or.unknown + { } + { "~[" eprintclass "]" * * * } + if$ + } + { "~[" primaryclass "]" * * * } if$ - eprint "}" * * writeln } if$ @@ -692,60 +748,34 @@ FUNCTION { output.eprint } % % Changes by BV 2011/04/15. Do not output % url if doi is defined % +% +% Changes by BV 2021/11/26. Output url even if doi is defined +% if distinctURL is not zero. +% FUNCTION { output.url } % UTAH { % return with stack untouched % output URL and associated lastaccessed fields - doi empty.or.unknown + doi empty.or.unknown distinctURL empty.or.zero not or { url empty.or.unknown { } { - %% NB: We want URLs at beginning of line to reduce likelihood of - %% BibTeX's nasty line wrapping after column 79, which would require - %% manual (or automated) editing of the .bbl file to repair. However, - %% the \url{} macro handles the unwrapping job automatically. + %% Use \urldef, outside \showURL, so that %nn, #, etc in URLs work + %% correctly. Put the actual URL on its own line to reduce the + %% likelihood of BibTeX's nasty line wrapping after column 79. + %% \url{} can undo this, but if that doesn't work for some reason + %% the .bbl file would have to be repaired manually. + "\urldef\tempurl%" writeln + "\url{" url * "}" * writeln + "\showURL{%" writeln lastaccessed empty.or.unknown { "" } { "Retrieved " lastaccessed * " from " * } if$ - - %% The URL field may contain a semicolon-separated list of Web - %% addresses, and we locate and wrap each of them in \url{...}. - %% The simplistic approach of putting the entire list into the - %% macro argument is that the semicolons are typeset in a - %% typewriter font, and no space follows them. - %% - %% We therefore replace the original code - %% "\url{" * url * "}}" * writeln - %% with this character-at-a-time loop: - - "\url{" * - - url 't := % get modifiable copy of URL list - - { t text.length$ } - { - t #1 #1 substring$ ";" = - { % then split argument at separator - "};" * writeln - "\url{" - } - { % else concatenate nonblank character to argument - t #1 #1 substring$ " " = - { } - { t #1 #1 substring$ * } - if$ - } - if$ - - t #2 t text.length$ #1 - substring$ 't := - } - while$ - - "}}" * writeln + "\tempurl}" * writeln } - if$ + if$ } { } if$ @@ -754,9 +784,9 @@ FUNCTION { output.url } % UTAH FUNCTION { output.year.check } { % warn if year empty, output top string and leave " YEAR