[Tex/LaTex] Bibliography style JHEP.bst: arXiv number and parentheses

bibliographies

I would like to modify the bibliography style JHEP.bst to solve the following issue:

enter image description here

When a journal reference is included the arXiv reference appears in parentheses […], while there are no parentheses if there is no journal reference. How do I have to modify the .bst file if I want parentheses in any case?

MWEB (copy JHEP.bst in working directory, run LaTeX+BibTex+LaTeX+LaTeX):

\documentclass{article}
\usepackage[numbers]{natbib}
\usepackage{filecontents}

\begin{filecontents}{references.bib}
@article{a,
      author         = "Author, A.",
      title          = "{Title}",
      journal        = "Journal",
      volume         = "1",
      pages          = "1",
      year           = "2009",
      eprint         = "0904.0464",
}
@article{b,
      author         = "Author, B.",
      title          = "{Title}",
      eprint         = "0904.0464",
}

\end{filecontents}


\begin{document}

Reference \cite{a,b}

\bibliographystyle{JHEP}
\bibliography{references}


\end{document}

Best Answer

You can make a copy of JHEP.bst in your working directory, rename it to for example JHEPmod.bst and change in the article function the line

{ format.eprint output }

to

{ format.eprint.paren output }

In your document you can use the renamed style with \bibliographystyle{JHEPmod}.

FUNCTION {article}
{ output.bibitem
  format.collaboration output
  format.authors "author" output.check
  format.title "title" output.check
  blank.sep
  crossref missing$
  { journal missing$
    { format.eprint.paren output } % <- THIS LINE NEEDS TO BE CHANGED !!!!!!!
    { journal empty$ { format.eprint output } {
      format.doi * "{" * journal emphasize before.all 'output.state := "journal" output.check
      % added \href{doi} and { before journal
      % Slv
      blank.sep
      format.volume output
      blank.sep
      format.date.paren "year" output.check
      %month empty$ { format.number output }
      %           'skip$ if$
      blank.sep
      format.pages.nopp "}" * output }
      %% closed parenthesis for href argument
      if$
      }
    if$
    report missing$
            { journal empty$ {} { format.eprint.paren output} if$ }
            {blank.sep format.report output format.eprint.paren output}
            if$
    }
    { format.article.crossref output.nonnull
      format.pages output
      format.eprint.paren output
    }
  if$
  new.sentence
  % format.doi output
  % note output
  fin.entry
}

enter image description here

Related Question