3

Even though I have come across some examples in changing the order of fields in biblatex, for some reason I cannot change the order of the pages and date fields. Now the print is


L. Maclerran: "Theory Summary: Quark Matter 2006". J.Phys. G34 (2007), 538-592. arXiv:hep-ph/0702004 [hep-ph]


What I would like it to be is


L. Maclerran: "Theory Summary: Quark Matter 2006". J.Phys. G34, 538-592 (2007), arXiv:hep-ph/0702004


The extra identifier problem is only for the pre-2007 e-prints, when the form of the identifier changed.

Here is my relevant and not-so-relevant (in case I have poked some bit that should be left un-poked) biblatex-related code so far (including my failed attempt to change the order of the date and pages fields):

\usepackage[style=numeric-comp,
sorting=none,
backend=bibtex,
doi=false,
firstinits=true,
hyperref]{biblatex}


%supress "in" from biblatex
\renewbibmacro{in:}{}
%":" instead of "." after author in biblatex
\renewcommand{\labelnamepunct}{\addcolon\space}
% Collaborations correctly with tag "authortype"
\renewbibmacro*{author}{%
   \ifboolexpr{ test {\ifuseauthor} and not test {\ifnameundef{author}} }
     {\printnames{author}%
     \iffieldundef{authortype}
       {}
       {\setunit{\addspace}%
        \usebibmacro{authorstrg}}}
     {}}
\DeclareFieldFormat{authortype}{\mkbibparens{#1}}
% removes period at the very end of bibliographic record
\renewcommand{\finentrypunct}{}
% "p.101"->"101"
\DeclareFieldFormat{pages}{#1} 

% (year), pages -> pages (year),
\renewbibmacro{date+pages}{%
   \printfield{pages}%
   \setunit*{\space}%
   \usebibmacro{date}%
   \setunit*{\addcomma\space}%
   \newunit}

The example citation used is straight from InspireHEP:

@article{McLerran:2007hz,
      author         = "McLerran, Larry",
      title          = "{Theory Summary: Quark Matter 2006}",
      journal        = "J.Phys.",
      volume         = "G34",
      pages          = "583-592",
      doi            = "10.1088/0954-3899/34/8/S50",
      year           = "2007",
      eprint         = "hep-ph/0702004",
      archivePrefix  = "arXiv",
      primaryClass   = "hep-ph",
      SLACcitation   = "%%CITATION = HEP-PH/0702004;%%",
}

I thank you in advance for your answers :)

Moppe
  • 53
  • 6
  • 1
    Regarding the arXiv problem: Your .bib source should read eprint = "0702004", eprinttype= "arXiv", eprintclass="hep-ph" or if you insist eprint = "0702004", archivePrefix = "arXiv", primaryClass = "hep-ph",. See p. 115 of the biblatex doc. – moewe Jun 10 '15 at 16:27
  • Of course, removing the primaryClass field from the .bib sources dating back to before April 2007 one by one solves the problem. (I still prefer the form to be the correct hep-ph/0702004). I was just wondering, if there is an easier way to deal with these cases. :) – Moppe Jun 10 '15 at 17:49
  • Sorry, yes for pre-2007 you have eprint = {math/0307200v3}, eprinttype = {arxiv}, that is remove the primaryClass. That is the easiest way in that only this will give you a proper .bib file (maybe one cook something up with Biber, but to be honest, I'm not a big fan of ad hoc solutions for blatantly wrong .bib files.). – moewe Jun 10 '15 at 19:19
  • Do you want to change the order of the pages and year fields only for @articles or for everyone? – moewe Jun 10 '15 at 19:21
  • Only for @articles – Moppe Jun 10 '15 at 19:47
  • @moewe I use Mendeley to generate a .bib file, but for arXiv papers older than 2007, it generates a wrong entry, for example, eprint = {0508031}, archivePrefix = {arXiv}, primaryClass = {quant-ph} instead of eprint = {quant-ph/0508031}, archivePrefix = {arXiv} without the primaryClass field. Any ideas on how I could change his behaviour? – Abhinav Feb 01 '17 at 23:57
  • 1
    @Abhinav This seems to be a Mendeley problem. You should complain to the developers about this. There might be a clever Biber sourcemapping solution, but for that you should ask a new question with an MWE. – moewe Feb 02 '17 at 07:59

1 Answers1

2

The easiest way to change the order for @articles is probably to remove the page number from the bib driver (using the xpatch package)

\xpatchbibdriver{article}
  {\newunit
   \usebibmacro{note+pages}}
  {}{}{}

We then insert the pages into the journal+issuetitle macro like so

\newbibmacro*{journal+issuetitle}{%
  \usebibmacro{journal}%
  \setunit*{\addspace}%
  \iffieldundef{series}
    {}
    {\newunit
     \printfield{series}%
     \setunit{\addspace}}%
  \usebibmacro{volume+number+eid}%
  \newunit
  \usebibmacro{note+pages}%
  \setunit{\addspace}%
  \usebibmacro{issue+date}%
  \setunit{\addcolon\space}%
  \usebibmacro{issue}%
  \newunit}

MWE

\documentclass[12pt,a4paper]{article}
\usepackage[style=numeric-comp,firstinits=true,]{biblatex}
\usepackage{xpatch}
\usepackage{hyperref}
\addbibresource{biblatex-examples.bib}

%supress "in" from biblatex
\renewbibmacro{in:}{}
%":" instead of "." after author in biblatex
\renewcommand{\labelnamepunct}{\addcolon\space}
% Collaborations correctly with tag "authortype"
\renewbibmacro*{author}{%
   \ifboolexpr{ test {\ifuseauthor} and not test {\ifnameundef{author}} }
     {\printnames{author}%
     \iffieldundef{authortype}
       {}
       {\setunit{\addspace}%
        \usebibmacro{authorstrg}}}
     {}}
\DeclareFieldFormat{authortype}{\mkbibparens{#1}}
% removes period at the very end of bibliographic record
\renewcommand{\finentrypunct}{}
% "p.101"->"101"
\DeclareFieldFormat{pages}{#1} 

% (year), pages -> pages (year),
\renewbibmacro{date+pages}{%
   \printfield{pages}%
   \setunit*{\space}%
   \usebibmacro{date}%
   \setunit*{\addcomma\space}%
   \newunit}

\xpatchbibdriver{article}
  {\newunit
   \usebibmacro{note+pages}}
  {}{}{}

\newbibmacro*{journal+issuetitle}{%
  \usebibmacro{journal}%
  \setunit*{\addspace}%
  \iffieldundef{series}
    {}
    {\newunit
     \printfield{series}%
     \setunit{\addspace}}%
  \usebibmacro{volume+number+eid}%
  \newunit
  \usebibmacro{note+pages}%
  \setunit{\addspace}%
  \usebibmacro{issue+date}%
  \setunit{\addcolon\space}%
  \usebibmacro{issue}%
  \newunit}

\begin{document}
\cite{baez/article,itzhaki,wassenberg}.

\printbibliography
\end{document}

enter image description here

moewe
  • 175,683