7

I am trying to add an arxiv reference to my bibentries and I would like to control how it shows up in the citation.

I would like to have the field only contain the informative part:

arxiv = 0809.0726

but for the result to be more informative and perhaps contain a link:

\href{https://arxiv.org/abs/0809.0726}{arXiv:0809.0726}

which, of course can be done with a macro:

\newcommand{\arxiv}[1]{{ \href{https://arxiv.org/abs/#1}{arXiv:#1}}}
\arxiv{0809.0726}

S far so good.

I've taken unsrt.bst and started modifying it.

  1. I've added arxiv to the ENTRY list

  2. I've added a format.arxiv function that is a model for what I want:

    FUNCTION {format.arxiv}
    { arxiv empty$
         { "" }
         {" {\url{arXiv:" * arxiv * "}}" * }
      if$
    }
    
  3. I modify the relevant output functions to call arxiv.output (for example, unpublished):

     FUNCTION {unpublished}
     { output.bibitem
      format.authors "author" output.check
      new.block
      format.title "title" output.check
      new.block
      note "note" output.check
      new.block
      format.arxiv output
      format.date output
      fin.entry
     }
    

However, when I try to compile a file I get the error:

Running `BibTeX' on `ResearchStatement' with ``bibtex ResearchStatement''
This is BibTeX, Version 0.99c (Web2C 7.5.6)
The top-level auxiliary file: ResearchStatement.aux
The style file: myunsrt.bst
Database file #1: general.bib
You can't pop an empty literal stack for entry FarjounSchaeffer2010
while executing---line 963 of file myunsrt.bst
(There was 1 error message)

BibTeX exited abnormally with code 2 at Thu Nov 10 16:39:09

I tried playing with the *'s in the format.arxiv function, but I kept getting the wrong results

I'm sure this is easy for those who can access the force...but I am still a grasshopper here...

2
  • Have you looked into modifying the url field, supplied by, say, the plainnat.bst file?
    – Mico
    Commented Nov 10, 2011 at 22:36
  • 1
    Have you checked out these styles: arxiv.org/hypertex/bibstyles ? Apropos of your approach, there is already a version of unsrt.bst modified to show eprint numbers.
    – Lev Bishop
    Commented Nov 11, 2011 at 1:15

4 Answers 4

3

Try placing the following in the .bst file. (The upper function may already be present).

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

FUNCTION {format.archive}
{
  archivePrefix empty$
      { "" }
      { archivePrefix ":" *}
  if$            
}

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

FUNCTION {unpublished}
{ output.bibitem
  format.authors "author" output.check
  new.block
  format.title "title" output.check
  format.date output
  new.block
  format.note "note" output.check
  format.eprint output
  fin.entry
}
1
  • I generated my own bst file in the usual way when I wrote my thesis, but wanted something similar to what you want. I got my hack on and this was the result. Honestly, I'm not 100% certain of how it's working now, but looks fairly straight forward.
    – qubyte
    Commented Nov 10, 2011 at 21:58
1

The answer by Mark, is a complete working example, but I had my way of doing things and I therefore wanted an answer on how to fix my code...not a different code...but looking at his code I managed to figure out that there was a spurious * in my definition, which then pulled too many items from the stack. The format.arxiv function that I ended up using is:

 FUNCTION {format.arxiv}
{ arxiv empty$
    { "" }
    {"\href{www.arxiv.org/abs/" arxiv *  "}" * 
             "{\tt arXiv:" * arxiv *  "}" *}
  if$
}

Notice the lack of a * between the first two arguments of the false clause.

0

You can download the file unsrt-phys.bst in the link below: https://drive.google.com/open?id=0B8AqjYFfBKw0dEZXcFN0WEVIN0U&authuser=0 and put it in the folder of your article. Then change the style of bibliography to \bibliographystyle{unsrt-phys}. Run Bibtex, and enjoy it!

0

use

FUNCTION {format.arxiv}
{ arxiv empty$
    { "" }
    { "{\url{arXiv:" arxiv * "}}" * }
  if$
}

and, of course, an entry arxiv in the list ENTRY. Then I get:

\documentclass{article}
\usepackage{filecontents}
\usepackage{url}
\begin{filecontents*}{\jobname.bib}
@unpublished{demo,
    author="foo",
    title="bar",
    arxiv="1234.5678"
}
\end{filecontents*}

\begin{document}
    \nocite{*}
    \bibliographystyle{unsrt}
    \bibliography{\jobname}
\end{document}

enter image description here

You must log in to answer this question.

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