4

I'm using biber and biblatex and I wanna print all thesis prior to 2013. When I use

year = {2010}

entry in the .bib file, every think works fine. However, if I use

date = {2010-11-25}

instead of year, my entry is ignored. I'm respecting the date format, right? So what is wrong? Here is a MWE.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@THESIS{a,
  AUTHOR =  {Myself},
  TITLE = {Me, myself and I},
  Institution = {My University},
  type = {Ph.D. thesis},
  year = {2010} 

} %  date = {2010-11-25}
\end{filecontents*}
\usepackage[backend=biber,defernumbers=true,sorting=ydnt]{biblatex}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
  \maps[datatype=bibtex]{
         \map[overwrite=true]{
            \step[fieldsource=year,  match=\regexp{199([7-9])|200([0-9])|201([0-2])},final]
            \step[fieldset=keywords, fieldvalue={,}, append]
        \step[fieldset=keywords, fieldvalue={before2013}, append]
}}}

\begin{document}
Hello world.
    \nocite{*}
    \printbibliography[type=thesis,keyword=before2013,title=Thesis,resetnumbers=true]
\end{document}
0
3

Instead of Biber's sourcemapping you can compare the year field with biblatex in the document. (We can use year here regardless of whether you used year or date since a date field is always split up into its components when it is written to the .bbl.)

We define a bibcheck

\defbibcheck{before2013}{%
  \iffieldint{year}
    {\ifnumless{\thefield{year}}{2013}
       {}
       {\skipentry}}
    {\skipentry}}

and use that check instead of the keyword

\printbibliography[type=thesis,check=before2013,title=Thesis,resetnumbers=true]
2
  • I just realised that I suggested something like this before in biblatex, biber, is it possible to \printbibliography between two years? - and so did Guido. – moewe Jan 27 '17 at 11:29
  • Right @moewe. Two solutions were proposed in that post and I took the other one (with the mapping) which has the drawback (that I'm discovering right now) that the date splitting is done after mapping. So now I'm adopting your suggestion. Thx again for helping. – rasha Jan 27 '17 at 12:59
5

Your \maps only sets keyword=before2013 if year is 1997 up to 2012 but not if date is 1997-01-01 up to 2012-12-31. The index is only printed if keyword=before2013. So the entry would not be printed, if date instead of year is used.

You can add a similar map for date like you have for year:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@THESIS{a,
  AUTHOR =  {Myself},
  TITLE = {Me, myself and I},
  Institution = {My University},
  type = {Ph.D. thesis},
  year = {2010} 
}
@THESIS{b,
  AUTHOR =  {Another},
  TITLE = {Another, one and nobody},
  Institution = {My University},
  type = {Ph.D. thesis},
  date = {2010-11-25} 
}
@THESIS{c,
  AUTHOR= {Never},
  TITLE = {I'm to late},
  Institution = {My University},
  type = {Ph.D. thesis},
  date = {2017-01-01}
}
\end{filecontents*}
\usepackage[backend=biber,defernumbers=true,sorting=ydnt]{biblatex}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
      \step[fieldsource=year,  match=\regexp{199([7-9])|200([0-9])|201([0-2])},final]
      \step[fieldset=keywords, fieldvalue={,}, append]
      \step[fieldset=keywords, fieldvalue={before2013}, append]
    }
    \map[overwrite=true]{
      \step[fieldsource=date,  match=\regexp{199([7-9])|200([0-9])|201([0-2])},final]
      \step[fieldset=keywords, fieldvalue={,}, append]
      \step[fieldset=keywords, fieldvalue={before2013}, append]
    }
  }
}

\begin{document}
Hello world.
    \nocite{*}
    \printbibliography[type=thesis,keyword=before2013,title=Thesis,resetnumbers=true]
\end{document}

enter image description here

Another solution would be to use a check, because checks are done, when the date already has been splitted:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@THESIS{a,
  AUTHOR =  {Myself},
  TITLE = {Me, myself and I},
  Institution = {My University},
  type = {Ph.D. thesis},
  year = {2010} 
}
@THESIS{b,
  AUTHOR =  {Another},
  TITLE = {Another, one and nobody},
  Institution = {My University},
  type = {Ph.D. thesis},
  date = {2010-11-25} 
}
@THESIS{c,
  AUTHOR= {Never},
  TITLE = {I'm to late},
  Institution = {My University},
  type = {Ph.D. thesis},
  date = {2017-01-01}
}
\end{filecontents*}
\usepackage[backend=biber,defernumbers=true,sorting=ydnt]{biblatex}
\addbibresource{\jobname.bib}
\defbibcheck{before2013}{%
  \iffieldint{year}% If an interger field year exists
  {
    \ifnumless{\thefield{year}}{2013}% and the field value is less than 2013
    {}% do nothing
    {\skipentry}% otherwise skip the entry
  }
  {\skipentry}% skip the entrie also if there isn't an integer field year
}

\begin{document}
Hello world.
    \nocite{*}
    \printbibliography[type=thesis,check=before2013,title=Thesis,resetnumbers=true]
\end{document}

The result is the same.

5
  • Thank you very much @Schweinebacke. I thought however, when date is used, that the "Date Component Field"-year was correctly filled. All "Date Component Fileds" are described in p.150 of biblatex.pdf file: ctan.mines-albi.fr/macros/latex/contrib/biblatex/doc/… Why is not it the case? – rasha Jan 27 '17 at 10:21
  • 1
    @rasha AFAIK automatic date splitting is done after mapping, before printing the entry and long after selecting the entries for the bibliography. If you think, this is a bug, make a bug report. I can only show you how to solve the problem with the current state of work. – Schweinebacke Jan 27 '17 at 11:11
  • 1
    @rasha Sourcemapping is one of the first steps when processing the bib file, before the date field is split into its components. This is desirable in most situations because then one can modify the raw input and does not have to worry about how Biber processes certain fields. – moewe Jan 27 '17 at 11:22
  • @rasha I've added an alternative using a check instead of source mapping. – Schweinebacke Jan 27 '17 at 11:32
  • Thanks a lot @Schweinebacke. I frankly prefer the latter solution, because I have hundreds of entries of different types to manage, with some of them having a "date" and some others "year" entries and not all the fields are rigorously entered (as usual :-)). – rasha Jan 27 '17 at 12:39

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.