<p>This is the code I developed to auto-fill the URL field from the DOI or arXiv number. All URLs are hyperlinked.</p>
<p>You must use</p>
<blockquote>
<p>\usepackage[hidelinks]{hyperref}</p>
</blockquote>
<p>for the hyperlinks to work. Here is the code I made for the .bst file.</p>
<pre><code>FUNCTION {format.url}
{ is.use.url
    { url empty$
        { doi empty$
            { eprint empty$
                { &quot;&quot; 
                }
                { this.to.prev.status
                this.status.std
                cap.yes 'status.cap :=
                &quot;\href{https://arxiv.org/pdf/&quot; eprint * &quot;}{ [Online]. Available: https://arxiv.org/pdf/&quot; * eprint * &quot;}&quot; * output
                punct.no 'this.status.punct :=
                punct.period 'prev.status.punct :=
                space.normal 'this.status.space :=
                space.normal 'prev.status.space :=
                quote.no 'prev.status.quote :=    
                }
              if$
            }
            { this.to.prev.status
            this.status.std
            cap.yes 'status.cap :=
            &quot;\href{http://dx.doi.org/&quot; doi * &quot;}{[Online]. Available: http://dx.doi.org/&quot; * doi * &quot;}&quot; * output
            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$
        }
        { this.to.prev.status
            this.status.std
            cap.yes 'status.cap :=
            name.url.prefix &quot; &quot; *
            &quot;\url{&quot; * url * &quot;}&quot; *
            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$
    }
    { &quot;&quot; }
  if$
}
</code></pre>
adding \url link to function in .bst file
<p>How can I add a \url{} command to a .bst function. In this case, if the URL field is empty I want it to fill it with data from the DOI field, See the code below. I need to add this to the 4th line, but every way I have tried just causes it to crash.</p>
<pre><code>FUNCTION {format.url}
{ is.use.url
    { url empty$
      {&quot;[Online]. Available: https://doi.org/&quot; doi * }
      { this.to.prev.status
        this.status.std
        cap.yes 'status.cap :=
        name.url.prefix &quot; &quot; *
        &quot;\url{&quot; * url * &quot;}&quot; *
        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$
    }
    { &quot;&quot; }
  if$
}
</code></pre>
<p>This comes from IEEE.bst file and can be found around line 1920</p>