将\ url链接添加到.bst文件中的功能 [英] adding \url link to function in .bst file

查看:73
本文介绍了将\ url链接添加到.bst文件中的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将\ url {}命令添加到.bst函数.在这种情况下,如果URL字段为空,我希望它用DOI字段中的数据填充它,请参见下面的代码.我需要将其添加到第四行,但是我尝试过的每一种方法都只会导致其崩溃.

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.

FUNCTION {format.url}
{ is.use.url
    { url empty$
      {"[Online]. Available: https://doi.org/" doi * }
      { this.to.prev.status
        this.status.std
        cap.yes 'status.cap :=
        name.url.prefix " " *
        "\url{" * url * "}" *
        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$
    }
    { "" }
  if$
}

这来自IEEE.bst文件,可以在1920行附近找到

This comes from IEEE.bst file and can be found around line 1920

推荐答案

这是我开发的用于从DOI或arXiv编号自动填充URL字段的代码.所有URL都是超链接.

This is the code I developed to auto-fill the URL field from the DOI or arXiv number. All URLs are hyperlinked.

您必须使用

\ usepackage [hidelinks] {hyperref}

\usepackage[hidelinks]{hyperref}

使超链接起作用.这是我为.bst文件编写的代码.

for the hyperlinks to work. Here is the code I made for the .bst file.

FUNCTION {format.url}
{ is.use.url
    { url empty$
        { doi empty$
            { eprint empty$
                { "" 
                }
                { this.to.prev.status
                this.status.std
                cap.yes 'status.cap :=
                "\href{https://arxiv.org/pdf/" eprint * "}{ [Online]. Available: https://arxiv.org/pdf/" * eprint * "}" * 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 :=
            "\href{http://dx.doi.org/" doi * "}{[Online]. Available: http://dx.doi.org/" * doi * "}" * 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 " " *
            "\url{" * url * "}" *
            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$
    }
    { "" }
  if$
}

这篇关于将\ url链接添加到.bst文件中的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆