3

My MWE is the following:

\documentclass[letterpaper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[style=phys,articletitle=true,biblabel=brackets,%
chaptertitle=false,pageranges=false,eprint=true,backend=biber,%
natbib=true,maxbibnames=10,giveninits=true,sorting=none]{biblatex}
\DeclareFieldFormat[article]{journaltitle}{\textit{#1\isdot}}
\renewcommand*{\finalnamedelim}{\addcomma\space}
\urlstyle{same}
\addbibresource{References.bib}


\begin{document}


This is a test.


\nocite{*}
\printbibliography
\end{document}

My References.bib file is instead

@article{rs11999,
   Archiveprefix = {arXiv},
   Author = {Randall, Lisa and Sundrum, Raman},
   Doi = {10.1103/PhysRevLett.83.3370},
   Eprint = {hep-ph/9905221},
   Journal = {Phys. Rev. Lett.},
   Pages = {3370},
   Title = {{A Large Mass Hierarchy from a Small Extra Dimension}},
   Volume = {83},
   Year = {1999},
   Bdsk-Url-1 = {http://dx.doi.org/10.1103/PhysRevLett.83.3370}}

In the output the bibliography looks like

enter image description here

I would like to remove the last comma and surround the arXiv identifier with square brackets. Can anybody help me here? Thanks.

EDIT
Adding the following article to the References.bib file presents both the problems I mentioned in the comments:

@article{bhj2017,
   Archiveprefix = {arXiv},
   Author = {Bunk, Don and Hubisz, Jay and Jain, Bithika},
   Eprint = {1705.00001},
   Primaryclass = {hep-ph},
   Title = {{A Perturbative RS I Cosmological Phase Transition}}}
  • What do you want to happen to the primaryclass? Should it disappear? Be in no brackets, or square brackets within square brackets? – moewe Oct 15 '17 at 17:25
  • @moewe Square brackets within square brackets if possible. – gabo_18 Oct 15 '17 at 19:00
  • I have changed my code to give square brackets within square brackets. – moewe Oct 16 '17 at 13:23
  • The problem with bhj2017 is that @article is not the appropriate entry type. @article is only appropriate if the paper was actually published in a journal, i.e. only if the journal field is non-empty. in this case you should use @online instead. Cf. baez/online and baez/article in biblatex-examples.bib. – moewe Oct 16 '17 at 13:24
  • @moewe With the @online entry type I get [20] D. Bunk, J. Hubisz, B. Jain, A Perturbative RS I Cosmological Phase Transition, [arXiv:1705.00001 [hep-ph]]. The only difference is that the title is in italic. Shouldn't there be no comma between the title and the arXiv identifier? – gabo_18 Oct 16 '17 at 15:48
4

Assuming you want the eprint field in brackets only for arXiv you need

\documentclass[letterpaper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[style=phys, articletitle=true, biblabel=brackets,%
  chaptertitle=false, pageranges=false, eprint=true, backend=biber,%
  natbib=true, maxbibnames=10, giveninits=true, sorting=none]{biblatex}

\DeclareFieldFormat[article]{journaltitle}{\mkbibitalic{#1\isdot}}% I'd even use \mkbibemph
\renewcommand*{\finalnamedelim}{\addcomma\space}
\urlstyle{same}

\makeatletter
\newrobustcmd{\mkbibfixedbrackets}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  \bibleftbracket#1\bibrightbracket
  \endgroup}

\renewbibmacro*{doi+eprint+url}{%
  \iftoggle{bbx:doi}
    {\printfield{doi}}
    {}%
  \ifboolexpr{test {\iffieldequalstr{eprinttype}{arxiv}} or test {\iffieldequalstr{eprinttype}{arXiv}}}
    {\setunit{\addspace}\newblock}
    {\newunit\newblock}%
  \iftoggle{bbx:eprint}
    {\usebibmacro{eprint}}
    {}%
  \newunit\newblock
  \iftoggle{bbx:url}
    {\usebibmacro{url+urldate}}
    {}}

\usepackage{xpatch}
\xpatchbibdriver{online}
  {\newunit\newblock
   \iftoggle{bbx:eprint}
     {\usebibmacro{eprint}}
     {}}
  {\ifboolexpr{test {\iffieldequalstr{eprinttype}{arxiv}} or test {\iffieldequalstr{eprinttype}{arXiv}}}
     {\setunit{\addspace}\newblock}
     {\newunit\newblock}%
   \iftoggle{bbx:eprint}
     {\usebibmacro{eprint}}
     {}}
  {}{}

\DeclareFieldFormat{eprint:arxiv}{%
  \mkbibbrackets{%
    \ifhyperref
      {\href{http://arxiv.org/\abx@arxivpath/#1}{%
          arXiv\addcolon
          \nolinkurl{#1}%
          \iffieldundef{eprintclass}
       {}
       {\addspace\UrlFont{\mkbibfixedbrackets{\thefield{eprintclass}}}}}}
      {arXiv\addcolon
        \nolinkurl{#1}%
        \iffieldundef{eprintclass}
          {}
          {\addspace\UrlFont{\mkbibfixedbrackets{\thefield{eprintclass}}}}}}}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{itzhaki,baez/article}
\printbibliography
\end{document}

N. Itzhaki, Some remarks on ’t Hooft’s S-matrix for black holes, version 1, (Mar. 11, 1996) [arXiv:hep-th/9603067].

J. C. Baez, A. D. Lauda, “Higher-dimensional algebra V: 2-groups”, version 3, Theory and Applications of Categories 12, 423 (2004) [arXiv:math/0307200v3].


If you want all eprints in brackets, you'd only need

\renewbibmacro*{doi+eprint+url}{%
  \iftoggle{bbx:doi}
    {\printfield{doi}}
    {}%
  \setunit{\addspace}\newblock
  \iftoggle{bbx:eprint}
    {\usebibmacro{eprint}}
    {}%
  \newunit\newblock
  \iftoggle{bbx:url}
    {\usebibmacro{url+urldate}}
    {}}

\renewbibmacro*{eprint}{%
  \iffieldundef{eprint}
    {}
    {\printtext[brackets]{%
       \iffieldundef{eprinttype}
         {\printfield{eprint}}
         {\printfield[eprint:\strfield{eprinttype}]{eprint}}}}}

But there is currently a small bug in biblatex and biblatex-phys that causes an unwanted space here. Both issues have been addressed (plk/biblatex@36a0833 and josephwright/biblatex-phys@e8a8410), the fixes will be included in the upcoming versions of the two packages.

  • Thanks a lot! I will go with your second solution. However, with the new arXiv identifier scheme the eprintclass is surrounded by parenthesis instead of brackets. Moreover, for articles in which I specify only authors and title (since they have not been published in a journal) there is still a comma between the title and the arXiv identifier. – gabo_18 Oct 15 '17 at 15:52
  • @gabo_18 Can you modify your MWE to include examples of the two problems? I will have a look at them then. – moewe Oct 15 '17 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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