Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to create two separate lists of references using biblatex. The first one should contain literature references, the second one online references. My criterion is that any entry with both a Url and a Urldate in the BibTeX file should be an online source. So I defined a “bibcheck” like so:

\documentclass{article}

\usepackage[style=verbose]{biblatex}

\defbibcheck{online}{%
  \ifboolexpr{ 
    not test {\iffieldundef{Url}} and not test {\iffieldundef{Urldate}}
  }{% Entry has both url and urldate -> it's a web source  
  }{%
    \skipentry
  }
}

\defbibcheck{hasurl}{%
  \iffieldundef{Url}{\skipentry}{}%
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
  url = {http://www.google.com/},
  urldate = {2012-06-21}
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
  url = {http://www.google.com/}
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2001},
  title = {Charlie},
  urldate = {2012-06-21}
}
@misc{D04,
  author = {Duthor, D.},
  year = {2001},
  title = {Delta}
}
\end{filecontents}

\addbibresource{\jobname.bib}

\nocite{*}

\begin{document}

\printbibliography[check=online]
\printbibliography[check=hasurl]

\end{document}

This does not work, however, because it seems that in the bibcheck “routine” neither Url nor Urldate are set – even though they are printed correctly in the list of references. I tried outputting the value of the Url field using \thefield{url} and it only returns an empty string.

How can I filter based on Url and Urldate?

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

The problem with your example is that "URLDATE" is not a field. If you check the manual, all the "*DATE" fields are split into their components by the backend and so if you change "urldate" to to "urlyear" then it works.

An alternative is to use the sourcemapping feature with biber:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=url]
      \step[fieldsource=urldate]
      \step[fieldset=keywords, fieldvalue={online}]
    }
  }
}

This will give everything with both URL and URLDATE the keyword "online" which you can then use for bib filtering. Since URLDATE is part of the backend datamodel, you can use it there.

share|improve this answer
    
Thanks for the hint. This works infact for the urldate field. But I still do not know how to test against the url field. –  ilpssun Jun 21 '12 at 11:35
    
I think you're getting confused by the fact that your example has the field names in mixed case. "Url" won't work but "url" will. The URL field can be tested against but URLDATE can't as it doesn't exist as a .bbl field. –  PLK Jun 21 '12 at 11:52
    
@PLK: urldate is defined via DeclareFieldFormat in biblatex.def –  Herbert Jun 21 '12 at 12:09
    
Yes, as a format but not as a field. If you look in the .bbl for this example, you'll see that there is no urldate. It's been split into urlyear, urlmonth and urlday. See the section 4.2.4.3 of the manual. –  PLK Jun 21 '12 at 12:15
    
@PLK: thats correct, but the problem is that biblatex uses only the fields defined in the bbl and not the ones defined by itself. –  Herbert Jun 21 '12 at 12:56
show 4 more comments

The test on the field urldate, because biblatex uses only the fields defined in the .bblfile. However, why don't you define such entries not as an online type? Then you can test for \ifentrytype (I used biber in my example):

\documentclass{article}

\usepackage[style=verbose,backend=biber]{biblatex}

\defbibcheck{online}{\ifentrytype{online}{}{\skipentry}}
\defbibcheck{hasurl}{\iffieldundef{url}{\skipentry}{}}
\defbibcheck{hasurldate}{\iffieldundef{urlyear}{\skipentry}{}}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@online{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
  urldate = {2012-06-21},
  url = {http://www.google.com/},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
  url = {http://www.google.com/}
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2001},
  title = {Charlie},
  urldate = {2012-06-21},
}
@misc{D04,
  author = {Duthor, D.},
  year = {2001},
  title = {Delta},
}
\end{filecontents*}

\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}

\printbibliography[check=online]
\printbibliography[check=hasurl]
\printbibliography[check=hasurldate]
\printbibliography

\end{document}

enter image description here

share|improve this answer
    
I would like to format some online sources as, e.g., technical reports setting the type to @techreport while still including a URL and a URL date. Also, my bibtex-file is rather comprehensive and it would be tedious to manually check all entries whether they should be @online. –  ilpssun Jun 21 '12 at 11:37
    
@ilpssun: ok, the "field" urldate is internally divided into the separate fields urlday, urlmonth, and urlyear. If you run the test with urlyear instead of urldate then it should work. The problem is that biblatex defines the field urldate but uses for the check only the fields which are definied by biber –  Herbert Jun 21 '12 at 12:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.