[Tex/LaTex] arxiv citation function

arxivbiblatexcitinghyperref

Suppose I have a bibliography entry that looks like this (I'm using biblatex):

@article{foo,
  author = {A. Author},
  title = {Super article},
  archivePrefix = "arXiv",
  eprint        = "3301.1234",
  primaryClass  = "hep-ex"
}

I would like to create a command \arxiv, that I could use like
\arxiv{foo}, that would print

[1][arXiv:3301.1234]

where [1] would be the same a what \cite does, and the second part would link to the arXiv page for the article, e.g. http://arxiv.org/abs/3301.1234.

Can this be done? I want this so I can cite arXiv papers in beamer, and if somebody (or I later) pulls apart the slides, the citation is useful even without the bibliography slides.

Best Answer

You can define \arxivcite. It is a normal \cite and additionally prints the eprint information if available

\DeclareCiteCommand{\arxivcite}[\mkbibbrackets]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}%
   \newunit
   \usebibmacro{eprint}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

For numeric-comp, try

\makeatletter
\DeclareFieldFormat{eprint:cite:arxiv}{%
  arXiv\addcolon\space
  \ifhyperref
    {\href{http://arxiv.org/\abx@arxivpath/#1}{%
       \nolinkurl{#1}}}
    {\nolinkurl{#1}}}
\makeatother

\newbibmacro*{cite:eprint}{%
  \iffieldundef{eprinttype}
    {\printfield{eprint}}
    {\printfield[eprint:cite:\strfield{eprinttype}]{eprint}}}

\DeclareCiteCommand{\arxivcite}
  {}
  {\printtext[labelnumberwidth]{%
     \usebibmacro{prenote}%
     \usebibmacro{citeindex}%
     \printtext[bibhyperref]{%
       \printfield{labelprefix}%
       \printfield{labelnumber}}%
     \usebibmacro{postnote}}%
   \printtext[brackets]{\usebibmacro{cite:eprint}}}
  {\multicitedelim}
  {}

which disables any -comp features for this particular command. You will have to have a \DeclareFieldFormat{eprint:cite:<type>} for every eprint type you intend to use.