# arxiv citation function

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.

• Off-topic: You shouldn't be using the `@article` entry type for an arxiv-published piece. For one, it has neither a `journal` nor a `year` field. Consider using the `@misc` entry type instead. – Mico Mar 19 '16 at 7:22
• `@online` would also be perfectly fine, cf. `biblatex-example.bib`'s `baez/online`. – moewe Mar 19 '16 at 7:30
• @Mico an arXiv paper has the year (it's even part of its ID together with the month), for the journal usually something like "ArXiv e-prints" is usually employed, this is what NASA ADS Database does. – giordano Mar 19 '16 at 8:56
• In relation of the comment by @Mico, see How to cite an article from Arxiv using bibtex – carnendil Mar 22 '16 at 8:45

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}{%
\ifhyperref
{\href{http://arxiv.org/\abx@arxivpath/#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.

• arXiv runs TeX Live 2011, you must be sure this solution is compatible with such an old distribution. – giordano Mar 19 '16 at 8:59
• @giordano Where in the question does it say that the solution needs to run on the arXiv systems? The solution does not employ any fancy commands as you can see, so I'm quite confident it works with a fairly wide range of older `biblatex` versions. Whether the one included in TeX live 2011 is amongst those I cannot say with certainty; I just had a look at `biblatex` 1.0 dated November 2010 however and am fairly optimistic that it will actually do the right thing there and with all newer versions. – moewe Mar 19 '16 at 9:31
• Indeed I gave it fro granted that it was needed for arXiv, sorry, my fault. I was just asking whether `\DeclareCiteCommand` was available in earlier version of the package. – giordano Mar 19 '16 at 10:01
• @giordano `\DeclareCiteCommand` is one of the basic commands `biblatex` provides and has been available at least since version 1.0. I would suspect it was available in all official releases of `biblatex`, but that I cannot say with certainty. – moewe Mar 19 '16 at 10:12
• @SU3 Ah, yes, I forgot the `\makeatletter...\makeatother` bit. The code should now work together with `hyperref`. – moewe Mar 22 '16 at 18:41