4

I’m trying to create a bibliography with biblatex with two different styles. This means author, year citation for papers and books, and for online citations a numeric style. Is it possible?

\documentclass{article}

\usepackage[sorting=nyt,style=authoryear, backend=bibtex8]{biblatex} 
\addbibresource{dummy} 

\DeclareCiteCommand{\parencite}
{\ifentrytype{online}{\bibopenbracket}{\bibopenparen}%
\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}%
\ifentrytype{online}{\bibclosebracket}{\bibcloseparen}}
\begin{document}

\parencite{Rouhiainen.2004}
\parencite{Wikipedia.27.02.2017}

\printbibliography[heading=bibintoc,title={Literature},nottype=online]

\printbibliography[heading=bibintoc,title={ Internet Sources },type=online]


\end{document}

The conteste of the .bib file are:

@online{Wikipedia.27.02.2017,
 author = {Wikipedia, the free encyclopedia},
 year = {2017},
 title = {MALDI-TOF},
 url = {https://de.wikipedia.org/wiki/MALDI-TOF},
 urldate = {02.06.2017}
}
@article{Rouhiainen.2004,
 author = {Rouhiainen, Leo and Vakkilainen, Tanja and Siemer, Berit Lumbye and Buikema, William and Haselkorn, Robert and Sivonen, Kaarina},
 year = {2004},
 title = {Genes coding for hepatotoxic heptapeptides (microcystins) in the cyanobacterium Anabaena strain 90},
 pages = {686--692},
 volume = {70},
 number = {2},
 issn = {0099-2240},
 journal = {Applied and environmental microbiology}
}
3

In general it is not possible to mix or switch between different styles in one document out of the box. That is because some of the relevant options have to be set at loading time and some settings might conflict - which is a definite problem if options have to be passed to Biber.

It is, however, in many special cases possible to cook up a solution that works. As in this case.

MWE

\documentclass{article}

\usepackage[sorting=nyt,style=authoryear, backend=bibtex8, defernumbers]{biblatex} 

\ExecuteBibliographyOptions{labelnumber}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}

% bib environment for numeric citations (@online) from numeric.bbx
\defbibenvironment{onlinebib}
  {\list
     {\printtext[labelnumberwidth]{%
        \printfield{labelprefix}%
        \printfield{labelnumber}}}
     {\setlength{\labelwidth}{\labelnumberwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}%
      \renewcommand*{\makelabel}[1]{\hss##1}}
  {\endlist}
  {\item}

% taken from numeric.cbx
\providebool{bbx:subentry}
\newbibmacro*{cite:num}{%
  \printtext[bibhyperref]{%
    \printfield{labelprefix}%
    \printfield{labelnumber}%
    \ifbool{bbx:subentry}
      {\printfield{entrysetcount}}
      {}}}

% switch citation style based on entry type
\DeclareCiteCommand{\parencite}
  {\ifentrytype{online}{\bibopenbracket}{\bibopenparen}%
   \usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \ifentrytype{online}{\usebibmacro{cite:num}}{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}%
   \ifentrytype{online}{\bibclosebracket}{\bibcloseparen}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{Wikipedia.27.02.2017,
  author  = {Wikipedia, the free encyclopedia},
  year    = {2017},
  title   = {MALDI-TOF},
  url     = {https://de.wikipedia.org/wiki/MALDI-TOF},
  urldate = {2017-06-02},
}
@article{Rouhiainen.2004,
  author  = {Rouhiainen, Leo and Vakkilainen, Tanja and Siemer, Berit Lumbye and Buikema, William and Haselkorn, Robert and Sivonen, Kaarina},
  year    = {2004},
  title   = {Genes coding for hepatotoxic heptapeptides (microcystins) in the cyanobacterium Anabaena strain 90},
  pages   = {686--692},
  volume  = {70},
  number  = {2},
  issn    = {0099-2240},
  journal = {Applied and environmental microbiology},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
\parencite{Rouhiainen.2004} \parencite{Wikipedia.27.02.2017} \parencite{sigfridsson} \parencite{worman} \parencite{ctan} \parencite{baez/online}


\printbibliography[nottype=online, heading=bibintoc, title={Literature}]
\printbibliography[env=onlinebib,  type=online, heading=bibintoc, title={Internet Sources}, resetnumbers]
\end{document}

example output

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.