3

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$

2
  • Nice work figuring out the answer to the arxiv-related issue! To help future readers of this posting, you may want to place your solution in a separate answer. I'll be happy to upvote. :-)
    – Mico
    Feb 27, 2016 at 8:03
  • @Mico, I added it, fell free to edit it :) Feb 27, 2016 at 12:45

2 Answers 2

4

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.

2
  • Thanks for your answer. What is the role of format.title.p? and what about the arxiv problem ? Feb 26, 2016 at 13:50
  • @LlavDem - I suggested the change to format.title.p mostly pre-emptively. I'm afraid I don't have much to say about "the arxiv problem".
    – Mico
    Feb 26, 2016 at 14:04
2

To fix the problem of arxiv papers, first, you have to replace, in the utphys.bst file, the code

FUNCTION {format.primaryClass}
{
  primaryClass empty$
      { "" }
      { " [" primaryClass * "]" *}
  if$            
}

FUNCTION {format.eprint}
{ eprint empty$
     { ""}
     { archive empty$
          {"\href{http://arxiv.org/abs/" eprint * "}" * 
             "{{\ttfamily " * format.archive * eprint *
              format.primaryClass * "}}" *}
          {"\href{" archive *  "/" * eprint * "}" * 
             "{{\ttfamily " * format.archive * eprint *
              format.primaryClass * "}}" *}
       if$
     }
     if$
}

by the following code:

FUNCTION {format.primaryClass}
{
  primaryClass empty$
      { "Arxiv:" } % 
     { "" primaryClass * "/" *}        %Vall { " [" primaryClass * "]" *}
  if$            
}

FUNCTION {format.eprint} % eprint:9605032, http://arxiv.org/abs/hep-th/9605023
{ eprint empty$
     { "" }
     {  archive empty$
          {"\href{http://arxiv.org/abs/"  format.primaryClass *  eprint * "}" *
             "{{" * " [" * format.primaryClass *                              % vall "{{\ttfamily " * format.archive * eprint *
               eprint * "]" * "}}" * }

          {"\href{http://arxiv.org/abs/"  "}" *
             "{{" * " [" * format.primaryClass *
              eprint * "]" * "}}" *}
       if$
        }
     if$
}

Explication:

I) in format.primaryClass { "" primaryClass * "/" *} instead of { " [" primaryClass * "]" *} will replace [hep-th] by hep-th/. So it will print primaryClass/ (printClass is the catagory of the paper e.g. hep-th ) when it is defined, else (some of arxiv papers do not have a primaryClass) it would print Arxiv: (If$ will check that).

II) in format.eprint:

A): \href{http://arxiv.org/abs/" format.primaryClass * eprint * "}": this useful only when you use the hyperref package, it produces the hyperlink http://arxiv.org/abs/primerClass/eprint e.g. if primaryClass = {hep-th} and eprint = {9605032} it will produce http://arxiv.org/abs/hep-th/9605032. The code "{{" * " [" * format.primaryClass * eprint * "]" * "}}" * } is the hyperlinked printed text which is [format.primaryClass eprint] i.e. in my previous example [hep-th/9605032]. Remark: If you do not use the hyperref package this will just print [hep-th/9605032].

B) : Now, you can guess what the code "\href{http://arxiv.org/abs/" "}" does ?. When the arxiv paper does not have a primaryClass the case A) is omitted and the program will excute this code, so this is nothing but \href{http://arxiv.org/abs/format.primaryClass eprint } and since there is no primaryClass the format.primaryClass is just Arxiv:. e.g. if eprint = {1512.00704} this will give the hyperlink http://arxiv.org/abs/Arxiv:1512.00704 and you will automatically redirected to the link http://arxiv.org/abs/1512.00704. Finally, the code "{{" * " [" * format.primaryClass * eprint * "]" * "}}" * will print the hyperlinked text [format.primaryClass eprint] which is in our last example [Arxiv:1512.00704].

To remove the comma before Arxiv you must replace the following code (as in this answer):

FUNCTION {article}
{ output.bibitem
  format.collaboration output
  format.authors "author" output.check
  format.title "title" output.check
  blank.sep
  crossref missing$
  { journal missing$   
        {}
        { format.journal add.doi "journal" output.check}
      if$
    report missing$
        {format.eprint output}
        {blank.sep format.report output format.eprint output}
      if$
    }
    { format.article.crossref output.nonnull
      format.pages output
      format.eprint output
    }
  if$
  new.sentence
  format.url output
  new.sentence
  note output
  new.sentence
  format.SLACcitation output
  fin.entry
}

by the code:

FUNCTION {article}
{ output.bibitem
  format.collaboration output
  format.authors "author" output.check
  format.title "title" output.check
  blank.sep
  crossref missing$
  { journal missing$   
        {}
        { format.journal add.doi "journal" output.check}
      if$
    report missing$
         {before.all 'output.state := %% added  
         format.eprint output}
        {blank.sep format.report output format.eprint output}
      if$
    }
    { format.article.crossref output.nonnull
      format.pages output
      format.eprint output
    }
  if$
  new.sentence
  format.url output
  new.sentence
  note output
  new.sentence
  format.SLACcitation output
  fin.entry
}

A MWE:

  \documentclass{article}
   \begin{filecontents*}{test.bib}
     @article{A,
      archivePrefix = {arXiv},
      arxivId = {hep-th/9605032},
      author = {AuthorI, A. and AuthorII, B. and AuthorIII, C.},
      eprint = {9605032},
      journal = {Journal of Bla bla},
      pages = {12},
      primaryClass = {hep-th},
      title = {{Title of the paper A}},
      volume = {123},
      year = {2016}
        }
     @article{B,
      archivePrefix = {arXiv},      
      author = {AuthorA, A. and AuthorB, B. and AuthorC, C.},
      arxivId = {1512.00704},
      eprint = {1512.00704},
      journal = {Journal of bla bla},
      pages = {1233},
      title = {{Title of the paper B}},
      volume = {567},
      year = {2016}
        }
  \end{filecontents*}
  \begin{document}

   ~\nocite{*}

 %Bibleography

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

The result: enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .