Skip to content

Instantly share code, notes, and snippets.

@ezod
Created August 16, 2012 20:49
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezod/3373556 to your computer and use it in GitHub Desktop.
Save ezod/3373556 to your computer and use it in GitHub Desktop.
Patch to add DOI numbers to conference articles without pages in IEEEtranN.bst
--- /usr/share/texmf-dist/bibtex/bst/IEEEtran/IEEEtranN.bst 2008-09-30 19:18:36.000000000 -0400
+++ IEEEtranNdoi.bst 2012-08-16 16:41:34.000000000 -0400
@@ -146,6 +146,10 @@
FUNCTION {default.name.latex.cmd}{ "" }
+% The default DOI prefix.
+FUNCTION {default.name.doi.prefix}{ "" }
+
+
% The default URL prefix.
FUNCTION {default.name.url.prefix}{ "[Online]. Available:" }
@@ -274,6 +278,7 @@
chapter
day
dayfiled
+ doi
edition
editor
howpublished
@@ -310,6 +315,7 @@
CTLdash_repeated_names
CTLname_format_string
CTLname_latex_cmd
+ CTLname_doi_prefix
CTLname_url_prefix
}
{}
@@ -356,6 +362,7 @@
ALTinterwordstretchfactor
name.format.string
name.latex.cmd
+ name.doi.prefix
name.url.prefix}
@@ -376,6 +383,7 @@
default.ALTinterwordstretchfactor 'ALTinterwordstretchfactor :=
default.name.format.string 'name.format.string :=
default.name.latex.cmd 'name.latex.cmd :=
+ default.name.doi.prefix 'name.doi.prefix :=
default.name.url.prefix 'name.url.prefix :=
}
@@ -767,8 +775,8 @@
FUNCTION {empty.entry.warn}
{ author empty$ title empty$ howpublished empty$
- month empty$ year empty$ note empty$ url empty$
- and and and and and and
+ month empty$ year empty$ note empty$ doi empty$ url empty$
+ and and and and and and and
{ "all relevant fields are empty in " cite$ * warning$ }
'skip$
if$
@@ -1135,6 +1143,8 @@
write$ newline$
"\providecommand{\natexlab}[1]{#1}"
write$ newline$
+ "\providecommand{\doi}[1]{DOI:#1}"
+ write$ newline$
"\providecommand{\url}[1]{#1}"
write$ newline$
"\csname url@samestyle\endcsname"
@@ -1958,6 +1968,27 @@
+%% DOI
+
+FUNCTION {format.doi}
+{ doi empty$
+ { "" }
+ { this.to.prev.status
+ this.status.std
+ cap.yes 'status.cap :=
+ name.doi.prefix " " *
+ "\doi{" * doi * "}" *
+ punct.no 'this.status.punct :=
+ punct.period 'prev.status.punct :=
+ space.normal 'this.status.space :=
+ space.normal 'prev.status.space :=
+ quote.no 'this.status.quote :=
+ }
+ if$
+}
+
+
+
%% URL
FUNCTION {format.url}
@@ -2130,6 +2161,10 @@
format.pages output
format.note output
format.url output
+ pages empty$
+ { format.doi output }
+ {}
+ if$
fin.entry
if.url.std.interword.spacing
}
@@ -2256,6 +2291,10 @@
if$
format.note output
format.url output
+ pages empty$
+ { format.doi output }
+ {}
+ if$
fin.entry
if.url.std.interword.spacing
}
@@ -2399,6 +2438,13 @@
'name.latex.cmd :=
}
if$
+ CTLname_doi_prefix
+ missing$
+ { skip$ }
+ { CTLname_doi_prefix
+ 'name.doi.prefix :=
+ }
+ if$
CTLname_url_prefix
missing$
{ skip$ }
@johnyf
Copy link

johnyf commented Dec 15, 2017

There appears to be a bug on https://gist.github.com/ezod/3373556#file-gistfile1-diff-L99 and https://gist.github.com/ezod/3373556#file-gistfile1-diff-L110. With this patch (manually) applied to IEEEtranS.bst, and these lines copied to other entry handles too, I was getting no DOIs for articles, conference papers and other entries, except for a few books and theses. Replacing:

pages empty$
    { format.doi output }
    {}
  if$

with format.doi output, as in this modified version of IEEEtran.bst solves the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment