1

I am trying to adapt recipes for two or more different bibliographies. The bibliography style should essentially be the same, but in the separate case I want to use the initials of the authors' names instead of the spelled out first names. I guess I'm stuck at what to write in defbibenvironment. Here is how far I got:

\documentclass[a4paper,10pt]{article}
\usepackage[pdftex,hidelinks]{hyperref}

\usepackage[lf]{venturis}
\usepackage[condensed]{roboto}
\usepackage[T1]{fontenc}

\usepackage[backend=biber,natbib=true,citestyle=authoryear-ibid,isbn=false,maxnames=20,maxcitenames=3,bibstyle=authoryear,useprefix=true]{biblatex} % citereset=chapter, 
\usepackage{hyperref}

%Append keywords to identify different bibliography entries.
\DeclareSourcemap{
  \maps[datatype=bibtex,overwrite]{
    \map{
      \perdatasource{test1.bib}
      \step[fieldset=KEYWORDS,fieldvalue=primary,append]
    }
    \map{
      \perdatasource{test2.bib}
      \step[fieldset=KEYWORDS,fieldvalue=secondary,append]
    }
  }
}

\defbibenvironment{bib2}
  {\list
     {}
     {\setlength{\leftmargin}{\bibhang}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}

\begin{filecontents}{test1.bib}
@BOOK{key1,
  author    = {Lastfoo, Foo},
  title     = {Some Title},
  address   = {Somewhere},
  publisher = {Some Publisher},
  year      = {2003},
}
@BOOK{key2,
  author    = {Lastfoo, Foo},
  title     = {Other Title},
  address   = {Somewhere},
  publisher = {Some Publisher},
  year      = {2004},
}
\end{filecontents}
\begin{filecontents}{test2.bib}
@BOOK{key3,
  author    = {Lastbar, Bar and Lastbaz,Baz},  
  title     = {Some Title},
  address   = {Somewhere},
  publisher = {Some Publisher},
  year      = {2004},
}
@BOOK{key4,
  author    = {Lastbar, Bar and Lastbaz,Baz},  
  title     = {Other Title},
  address   = {Somewhere},
  publisher = {Some Publisher},
  year      = {2005},
}
\end{filecontents}
\addbibresource{test1.bib}
\addbibresource{test2.bib}

\begin{document}
\noindent
The main citations are \autocite[123]{key1} and \autocite{key2}.\\
The others are implicit. \nocite{key3}\nocite{key4}

\printbibliography[title=Refs1,keyword=primary]

\newrefcontext[sorting=none]
\printbibliography[title=Refs2,keyword=secondary,env=bib2,resetnumbers]

\end{document}

This prints both bibliographies in the same way: enter image description here

But I want "Ref2" to print

Lastbar, B. and B. Lastbaz (2004) ...

Alternatively, APA style

Lastbar, B. & Lastbaz, B. (2004) ...

Like if I would use the giveninits option to biblatex, but only applied to the "Ref2" bibliography.

Emit Taste
  • 4,404

1 Answers1

3

There is no official interface to toggle the value of the giveninits option mid-document, but the implementation of the option is pretty simple. You can just say \toggletrue{abx@bool@giveninits} when you want to get the same results as giveninits=true (and similarly \togglefalse{abx@bool@giveninits} for giveninits=false).

\documentclass[a4paper,10pt]{article}
\usepackage[T1]{fontenc}

\usepackage[backend=biber,
  style=authoryear-ibid,
  maxnames=20, maxcitenames=3,
  useprefix=true,
  isbn=false,
 ]{biblatex}
\usepackage[hidelinks]{hyperref}


\DeclareSourcemap{
  \maps[datatype=bibtex,overwrite]{
    \map{
      \perdatasource{test1.bib}
      \step[fieldset=KEYWORDS,fieldvalue=primary,append]
    }
    \map{
      \perdatasource{test2.bib}
      \step[fieldset=KEYWORDS,fieldvalue=secondary,append]
    }
  }
}

\defbibenvironment{bib2}
  {\list
     {}
     {\setlength{\leftmargin}{\bibhang}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}
  {\item}

\begin{filecontents}{test1.bib}
@BOOK{key1,
  author    = {Lastfoo, Foo},
  title     = {Some Title},
  address   = {Somewhere},
  publisher = {Some Publisher},
  year      = {2003},
}
@BOOK{key2,
  author    = {Lastfoo, Foo},
  title     = {Other Title},
  address   = {Somewhere},
  publisher = {Some Publisher},
  year      = {2004},
}
\end{filecontents}
\begin{filecontents}{test2.bib}
@BOOK{key3,
  author    = {Lastbar, Bar and Lastbaz,Baz},  
  title     = {Some Title},
  address   = {Somewhere},
  publisher = {Some Publisher},
  year      = {2004},
}
@BOOK{key4,
  author    = {Lastbar, Bar and Lastbaz,Baz},  
  title     = {Other Title},
  address   = {Somewhere},
  publisher = {Some Publisher},
  year      = {2005},
}
\end{filecontents}
\addbibresource{test1.bib}
\addbibresource{test2.bib}

\begin{document}
The main citations are \autocite[123]{key1} and \autocite{key2}.

The others are implicit. \nocite{key3}\nocite{key4}

\printbibliography[title=Refs1,keyword=primary]

\newrefcontext[sorting=none]
\toggletrue{abx@bool@giveninits}
\printbibliography[title=Refs2,keyword=secondary,env=bib2,resetnumbers]

\end{document}

Lastfoo, Foo (2003).//Lastbar, B. and B. Lastbaz (2004).


Since it is in general not possible to switch full bibliography styles in a document it would be much, much harder to get full APA style (as implemented by biblatex-apa's style=apa) only for the second bibliography.

moewe
  • 175,683