12

Can you please help me to process biblatex entries. I want to...

  1. Print separate bibliographies for online and offline entries
  2. Both @online entries and @misc entries with a url-field should go into the 'online' category. All other entries should go into the 'offline' category.
  3. I want don't want to display the url and urldate of offline entries.

I have tried combining answers from the following webpages:

When should I use \AtEveryCitekey and when should I use \AtEveryBibitem? Can I issue multiple \AtEvery*** commands, or will one command replace the other?

Here is my minimal (not fully) working example. I can always either get the categorization or the clearing of fields to work, but not both:

\documentclass{article}
\usepackage{biblatex}

\DeclareBibliographyCategory{online}
\DeclareBibliographyCategory{offline}
\AtEveryCitekey{%
    \ifboolexpr{% 
        test {\ifentrytype{online}}
        or
        ( test {\ifentrytype{misc}}
          and not test {\iffieldundef{url}}
        )
    }
    { \addtocategory{online}{\thefield{entrykey}}\clearfield{url}\clearfield{urldate} }
    { \addtocategory{offline}{\thefield{entrykey}} }
}


\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{c1,
      author         = "Authors1",
      title          = "{Title of article}",
      collaboration  = "Collaboration",
      year           = "2012",
      url            = "http://www.sciencedirect.com/",
      urldate        = "2012-07-12",
}
@online{c2,
      author         = "Authors2",
      title          = "{Title of website}",
      year           = "2011",
      url            = "http://www.gmx.at/",
      urldate        = "2012-06-10",
}
@misc{c3,
      author         = "Authors3",
      title          = "{Title of video}",
      year           = "2012",
      howpublished   = "Youtube video",
      url            = "http://youtube.com/watch/123",
      urldate        = "2012-06-06",      
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\cite{c1,c2,c3}

\printbibliography[category=offline,title={Offline Articles}]

\printbibliography[category=online,title={Online Articles}]

\end{document}
14

This is best done using biber's sequential source mapping feature which allows you to modify the data as a stream as it's processed, without actually changing the source files:

\documentclass{article}
\usepackage{biblatex}
\addbibresource{test.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite=true]{
    \map{
      \step[fieldset=keywords, fieldvalue=offline]
    }
    \map{
      \pertype{online}
      \step[fieldset=keywords, fieldvalue=online]
    }
    \map{
      \pertype{misc}
      \step[fieldsource=url, final]
      \step[fieldset=keywords, fieldvalue=online]
    }
    \map{
      \step[fieldsource=keywords, match=offline, final]
      \step[fieldset=url, null]
    }
  }
}

\begin{document}
\cite{c1,c2,c3}
\printbibliography[keyword=offline,title={Offline Articles}]
\printbibliography[keyword=online,title={Online Articles}]
\end{document}
  • First set a default keyword of "offline" for an entry
  • Then overwrite this with "online" if the entry is @online or @misc with URL field
  • Then delete the URL field if the keywords field is still "offline"
  • print two bibliographies conditionalised on the keywords

Split bib

  • Thank you! I added one line \step[fieldset=urldate, null] as last command within the last map block so to also reset the urldate . It works perfectly fine, thanks! – Johannes Jul 30 '12 at 14:31

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.