7

I'm a little bit stuck in my attempts to change the format of my journal articles in my biblatex biography.

What i have so far:

Smith, A. and Smith, J. (2006). Article title. Journal title 29.2, pp. 1-43.

What is the goal:

Smith, A. and Smith, J. (2006). Article title. Journal title, 29(2): 1-43.

and (if there is no issue defined):

Smith, A. and Smith, J. (2006). Article title. Journal title, 29: 1-43.

Here is my MWE:

\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=authoryear,maxcitenames=2,maxbibnames=50,firstinits=true,uniquelist=false,uniquename=init,isbn=false,doi=false,useprefix=true]{biblatex}
\DeclareNameAlias{sortname}{last-first}
\DeclareFieldFormat[article]{title}{#1} 
\DeclareFieldFormat[article]{journaltitle}{#1} 
\DeclareFieldFormat[book]{title}{#1} 
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Article{initials,
  author = {Doe, J. P. and Jones, J.},
  title = {An article coauthored by John-Paul Doe},
  journal = {Journal title},
  volume = {29},
  pages = {825--833},
  year = {2008}}
@Article{smitha,
  author = {Smith, Anne and Smith, Joe},
  title = {Article title},
  journal = {Journal title},
  volume = {29},
  number = {2},
  pages = {1--43},
  year = {2006}}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\cite{initials,smitha}
\printbibliography
\end{document}

Any idea? Thanks in advance.

8

This code should do what you want (with a suggestion of @Moewe):

\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=authoryear,maxcitenames=2,maxbibnames=50,firstinits=true,uniquelist=false,uniquename=init,isbn=false,doi=false,useprefix=true]{biblatex}
\DeclareNameAlias{sortname}{last-first}
\DeclareFieldFormat[article]{title}{#1}
\DeclareFieldFormat[article]{journaltitle}{#1}
\DeclareFieldFormat[book]{title}{#1}
\DeclareFieldFormat[article]{pages}{#1}
\renewbibmacro{in:}{%
 \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}

\usepackage{xpatch}
\xpatchbibmacro{journal+issuetitle}{%
  \setunit*{\addspace}%
  \iffieldundef{series}}
  {%
  \setunit*{\addcomma\space}%
  \iffieldundef{series}}{}{}


\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Article{initials,
  author = {Doe, J. P. and Jones, J.},
  title = {An article coauthored by John-Paul Doe},
  journal = {Journal title},
  volume = {29},
  pages = {825--833},
  year = {2008}}
@Article{smitha,
  author = {Smith, Anne and Smith, Joe},
  title = {Article title},
  journal = {Journal title},
  volume = {29},
  number = {2},
  pages = {1--43},
  year = {2006}}
\end{filecontents}

\addbibresource{\jobname.bib}
\renewcommand\bibpagespunct{\ifentrytype{article}{\addcolon}{\addcomma}\space}
\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}
  \printfield[parens]{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}

\begin{document}
\cite{initials,smitha}
\printbibliography
\end{document} 

enter image description here

  • I think redefining the bibstrings for pages to be empty (or a space) is less than ideal, a change like \DeclareFieldFormat{pages}{#1} or \DeclareFieldFormat{pages}{\ifentrytype{article}{#1}{\mkpageprefix[bookpagination]{#1}}} seems much more elegant. You might also want to make the change of \bibpagespunct type-dependant. – moewe Apr 12 '15 at 12:10
  • @Moewe: I thought the treatment should be global, for the sake of coherence. But maybe I wasn't able to imagine situations for which there should be another formatting… You're right, your suggestion is much mmore elegant, I'll retain it. – Bernard Apr 12 '15 at 12:18
  • Yes, the type-dependency might have an element of inconsistency, but seems to be widely accepted (CMS & MLA handle @articles differently, I think). Since the OP seems to have embraced \ifentrytype{article} already in their MWE and the question mentioned only @articles I found it natural to change only those. – moewe Apr 12 '15 at 12:24
  • @Moewe: OK, you've convinced me. Answer modified. – Bernard Apr 12 '15 at 12:28
  • 1
    That feature was added. One must use the xpatch package for that. See my updated answer. – Bernard Apr 12 '15 at 17:29

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.