Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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{arXiv:0809.0726}{www.arxiv.org/abs/0809.0726}

which, of course can be done with a macro:

\newcommand{arxiv}[1]{{ \href{arXiv:#1}{www.arxiv.org/abs/#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...

share|improve this question
    
Have you looked into modifying the url field, supplied by, say, the plainnat.bst file? –  Mico Nov 10 '11 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 Nov 11 '11 at 1:15

2 Answers 2

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
}
share|improve this answer
    
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 Nov 10 '11 at 21:58

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.