[Tex/LaTex] How to customize a .bst file

bibliographiesbibtexpunctuation

I want to customize this .bst file.
Now, when I compile a reference it gives me (For an entry of type @article):

Author1, Author2, "Title," Journal Volume (Year) pages, arxiv:0208157.

But I want to make the comma appear after the quotation mark, and I want to replace arxiv:0208157 with [hep-ph/0208157]:

Author1, Author2, "Title", Journal Volume (Year) pages
[hep-ph/0208157].

Here is an MWE:

  \documentclass{article}
   \usepackage{filecontents}
   \begin{filecontents*}{test.bib}
      @article{AA,
      archivePrefix = {arXiv},
      arxivId = {hep-th/9605032},
      primaryClass = {hep-th},
      author = {AuthorI, A. and AuthorII, B. and AuthorIII, C.},
      eprint = {9605032},
      journal = {Journal},
      pages = {pages},
      title = {{Title with ?}},
      volume = {Volume},
      year = {Year}
      }
  \end{filecontents*}
  \begin{document}

  \nocite{*}

  %Bibloography

 \bibliographystyle{utphys}
 \bibliography{test}
 \end{document}

Update: Concerning the arxiv problem, you have to replace, in the FUNCTION {format.primaryClass} of .bst file, the code "{ " [" primaryClass * "]" *} by { "" primaryClass *}. And in the function FUNCTION {format.eprint} you should replace "{{\ttfamily " * format.archive * eprint * format.primaryClass * "}}" *} by "{{" * " [" * format.primaryClass * "/" * eprint * "]" * "}}" * }

Now, I have a new problem: when the arxivId does not contains a category e.g. hep-th,in primaryClass = {hep-th}, the citation printed as [/9605032]. So, my new question is how to write it in this case just [Arxiv:9605032]?.

Update II: The solution is so easy!, I have just to type "Arxiv" instead of "" after primaryClass empty$

Best Answer

You need to apply minor modifications to the following two functions, starting on l. 519, in the file utphys.bst:

FUNCTION {format.title}
{ title empty$
    { "" }
    { "``" title "t" change.case$ * ",''" * }
  if$
}

FUNCTION {format.title.p}
{ title empty$
    { "" }
    { "``" title "t" change.case$ * ".''" * }
  if$
}

Specifically, change ,'' to '', in format.title, and change .'' to ''. in format.title.p.

Note that you shouldn't edit and change an original file from the TeX distribution directly. Instead, make a copy of the file utphys.bst and apply the two suggestions given above to the copy.

Related Question