3

I am using natbib with apsrev style for references in article document class:

\documentclass{article}

\usepackage[]{natbib}       
\usepackage{hyperref}
\hypersetup{colorlinks = true}

\bibliographystyle{apsrev}          

\begin{document}
This is referring to \cite{example}.
\bibliography{eprint_ref}       
\end{document}

I am trying to show doi and arXiv links, as written in my eprint_ref.bib file:

@article{example,
    author =    {A. Author},
    title = {The title of this article},
    journal =   {JCAP},
    volume =    {1212},
    pages = {022},
    year =  {2035},
    doi  =          {10.1088/1475-7516/2012/12/022},
    url  =          {https://doi.org/10.1088/1475-7516/2012/12/022},
    archivePrefix = {arXiv},
    eprint =        {1210.6104},
    primaryClass =  {astro-ph.CO}
}

However, the arXiv link is shown wrong pointing to an incorrect address 1210.6104 which is not a url.

doi is printed correctly but after an ugly URL https://doi.org/ term. enter image description here It is really helpful to me if someone can suggest how to print the arXiv link correct.

2 Answers 2

3

apsrev wraps the eprint field in an \eprint command and provides the following fallback definition for \eprint: \providecommand{\eprint}[2][]{\url{#2}}.

If you know that all your eprints are only ever arXiv links, you can use the following definition in your preamble (if you load hyperref)

\newcommand{\eprint}[2][]{\href{https://arxiv.org/abs/#2}{arXiv:~\nolinkurl{#2}}}

If you have links to other eprint servers in eprint and distinguish them via archivePrefix, you'd need to edit apsrev, because it discards the info from archivePrefix.

\documentclass{article}
\usepackage{natbib}
\usepackage{hyperref}
\hypersetup{colorlinks = true}

\bibliographystyle{apsrev}

\newcommand{\eprint}[2][]{\href{https://arxiv.org/abs/#2}{arXiv:~\nolinkurl{#2}}}

\begin{filecontents}{\jobname.bib}
@article{example,
  author        = {A. Author},
  title         = {The title of this article},
  journal       = {JCAP},
  volume        = {1212},
  pages         = {022},
  year          = {2035},
  doi           = {10.1088/1475-7516/2012/12/022},
  url           = {https://doi.org/10.1088/1475-7516/2012/12/022},
  archivePrefix = {arXiv},
  eprint        = {1210.6104},
  primaryClass  = {astro-ph.CO},
}
\end{filecontents}

\begin{document}
This is referring to \cite{example}.
\bibliography{\jobname}
\end{document}

Linked arXiv info.

2

To show arXiv identifiers, the most suitable style is apsrev4-1 instead of apsrev.

Two more BibTEX fields archivePrefix, and primaryClass have been added to apsrev4-1.bst in addition to the existing eprint field.

The \eprint macros can be used to create and hyperlink (if using hyperref) the appropriate arXiv.org identifier as arXiv:hep-th/1210.6104 or arXiv:1210.6104 [astro-ph.CO] with primaryClass field in PDF output.

Also, there is no need to include url after doi field. doi is printed and hyperlinked in a better way than apsrev case.

\documentclass{article}
\usepackage{natbib}
\usepackage{hyperref}
\hypersetup{colorlinks = true}

\bibliographystyle{apsrev4-1}

\begin{filecontents}{\jobname.bib}
@article{example,
  Author =  {A. Author},
  title =       {The title of this article},
  journal = {JCAP},
  volume =  {1212},
  pages =   {022},
  year =        {2035},
  doi =         {10.1088/1475-7516/2012/12/022},
  archivePrefix =   {arXiv},
  eprint =      {1210.6104},
  primaryClass =        {astro-ph.CO},
}
\end{filecontents}

\begin{document}
This is referring to \cite{example}.
\bibliography{\jobname}
\end{document}

Which prints:

enter image description here

2
  • Is there a way to remove that last whitespace before the period? It leads to weird formatting.
    – Andrea
    Jul 27, 2021 at 9:12
  • Also, is there a way not to show the primaryclass?
    – Andrea
    Jul 27, 2021 at 9:13

You must log in to answer this question.

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