34

I have written my own biblatex style for citing jurisdiction. I realized that the sorting in the bibliography is not chronological within the years. I addressed the date field to each bibliography item and it seems as if only the year is considered. Consulting the manual made me believe that there is presently no way to use the date field for sorting.

My question is if anyone has a suggestion for how to use the other sort fields to get the jurisdictions sorted in the correct order by hand?

I know that this is far away from a smart solution but I my thesis is due on monday in a week.

So I appreciate an suggestions.

Minimal example:

\listfiles   
\documentclass[a4paper,11pt]{article} 

\usepackage[utf8]{inputenc}   
\usepackage[ngerman]{babel}   
\usepackage{textcomp} % Zusätzliche Symbole   
\usepackage{filecontents}

\usepackage[babel,german=quotes]{csquotes} %  
\usepackage[style=authortitle,backend=biber,sorting=nyt,date=short,]{biblatex} 


\DeclareFieldFormat[jurisdiction]{number}{\RN{#1}}  
\DeclareFieldFormat{institution}{#1}  
\DeclareFieldFormat{origdate}{#1}  
\newbibmacro*{usera}{  
  \iffieldundef{usera}  
    {}  
    {\printfield{usera}}}  

\newbibmacro*{institution}{%  
  \printlist{institution}%  
  \setunit*{\addspace}%  
  }

\newbibmacro*{number}{%  
  \iffieldundef{number}  
    {}%  
    {\printfield{number}}}  

\newbibmacro*{vom}{
   \printtext{v.}%
   \setunit*{\addspace}%
   }

\newbibmacro*{journaltitle}{  
 \iffieldundef{shortjournal}%  
    {\printfield{journaltitle}}%  
    {\printfield{shortjournal}}%  
  }

\newbibmacro*{note+pages}{%  
  \printfield{note}%  
  \setunit{\bibpagespunct}%  
  \printfield{pages}%  
  \newunit  
}

\newbibmacro*{origdate}{\printorigdate}

\DeclareBibliographyDriver{jurisdiction}{%  
  \usebibmacro{bibindex}%  
  \usebibmacro{begentry}%  
  \usebibmacro{institution}%  
  \usebibmacro{vom}%  
  \usebibmacro{date}%  
  \setunit{\labelnamepunct}\newblock  
  \usebibmacro{usera}  
  \newunit  
  \usebibmacro{journaltitle}  
  \setunit*{\addspace}  
  \usebibmacro{number}  
  \setunit{\addspace}  
  \usebibmacro{origdate}  
  \newunit  
  \usebibmacro{note+pages}  
  \setunit{\bibpagerefpunct}\newblock  
  \usebibmacro{pageref}%  
  \usebibmacro{finentry}}  




\bibliography{Literatur} % Einbinden der bibliographischen Daten. 

\begin{filecontents}{Literatur.bib}  
@jurisdiction{bmf1998,  
  institution = {BMF-Schr.},  
  date = {1998-03-25},  
  shortjournal = {BStBl.},  
  origdate = {1998},  
  number = {1},  
  usera = {},  
  pages = {268--344}  
}  

@jurisdiction{bmf2000a,
  institution = {BMF-Schr.},
  date = {2000-03-29},
  shortjournal = {BStBl.},
  origdate = {2000},
  number = {1},
  usera = {},
  pages = {462--463}
}

@jurisdiction{bmf2000b,
  institution = {BMF-Schr.},
  date = {2000-10-05},
  shortjournal = {BStBl.},
  origdate = {2000},
  number = {1},
  usera = {},
  pages = {1383--1390}
}

@jurisdiction{bmf2000c,
  institution = {BMF-Schr.},
  date = {2000-07-18},
  shortjournal = {BStBl.},
  origdate = {2000},
  number = {1},
  usera = {},
  pages = {1198}
}

@jurisdiction{bmf2000d,
  institution = {BMF-Schr.},
  date = {2000-02-25},
  shortjournal = {BStBl.},
  origdate = {2000},
  number = {1},
  usera = {},
  pages = {372--375}
}

@jurisdiction{bmf2001,
  institution = {BMF-Schr.},
  date = {2001-06-07},
  shortjournal = {BStBl.},
  origdate = {2001},
  number = {1},
  usera = {},
  pages = {367}
}

@jurisdiction{bmf2004,
  institution = {BMF-Schr.},
  date = {2004-11-26},
  shortjournal = {BStBl.},
  origdate = {2004},
  number = {1},
  usera = {},
  pages = {1190--1191}
}

@jurisdiction{bmf2004a,
  institution = {BMF-Schr.},
  date = {2004-03-26},
  shortjournal = {BStBl.},
  origdate = {2004},
  number = {1},
  usera = {},
  pages = {434--441}
}

@jurisdiction{bmf2008,
  institution = {BMF-Schr.},
  date = {2008-07-04},
  shortjournal = {BStBl.},
  origdate = {2008},
  number = {1},
  usera = {},
  pages = {718--729}
}

@jurisdiction{bmf2008,
  institution = {BMF-Schr.},
  date = {2008-08-11},
  shortjournal = {BStBl.},
  origdate = {2008},
  number = {1},
  usera = {},
  pages = {838--845}
}

@jurisdiction{bmf2009,
  institution = {BMF-Schr.},
  date = {2009-05-20},
  shortjournal = {BStBl.},
  origdate = {2009},
  number = {1},
  usera = {},
  pages = {671--672}
}

@jurisdiction{bmf2009a,
  institution = {BMF-Schr.},
  date = {2009-03-26},
  shortjournal = {BStBl.},
  origdate = {2009},
  number = {1},
  usera = {},
  pages = {514}
}

@jurisdiction{bmf2009b,
  institution = {BMF-Schr.},
  date = {2009-02-24},
  shortjournal = {BStBl.},
  origdate = {2009},
  number = {1},
  usera = {},
  pages = {440--444}
}

@jurisdiction{bmf2010,
  institution = {BMF-Schr.},
  date = {2010-04-16},
  shortjournal = {BStBl.},
  origdate = {2010},
  number = {1},
  usera = {},
  pages = {354--367}
}

@jurisdiction{bmf2011,
  institution = {BMF-Schr.},
  date = {2011-07-11},
  shortjournal = {BStBl.},
  origdate = {2011},
  number = {1},
  usera = {},
  pages = {713--715}
}

@jurisdiction{bmf2011a,
  institution = {BMF-Schr.},
  date = {2011-11-11},
  shortjournal = {BStBl.},
  origdate = {2011},
  number = {1},
  usera = {},
  pages = {1314--1415},
}

@jurisdiction{bmf2011b,
  institution = {BMF-Schr.},
  date = {2011-12-08},
  shortjournal = {BStBl.},
  origdate = {2011},
  number = {1},
  usera = {},
  pages = {1279--1286}
}
\end{filecontents}

% ================================================================================================== 
% Beginn des eigentlichen Dokuments. 
\begin{document} 

\nocite{*}


\printbibliography

\end{document}
6
  • 2
    Welcome to TeX.SX! Could you add some examples, with a minimal preamble, of what you have? How you're calling biblatex and a handful of bibliography items.
    – egreg
    Commented Mar 5, 2012 at 14:00
  • That makes little sence. Because I use a biblatex style that has been completely coded by myself. I just need to understand how I can use the sort*-fields to sort certain bib entrys by hand. My idea is to address each of those jurisdiction items a number in the bib file via one of the sorting fields. And biblatex should sort these items in order of the numbers addressed. And please excuse my poor english. And I call biblatex with biber and the sorting option nyt but I need this sorting for my articles and books. Commented Mar 5, 2012 at 14:13
  • It seems that addressing a number to the presort field can be used to sort the items in the appropriate order. But of course this is everything but not smart. Commented Mar 5, 2012 at 14:23
  • 3
    Maybe you could find a way to work it if you follow the instructions on p. 139 s. of the biblatex documentation. There is an example of a new sorting scheme on p. 141 – maybe you could use the date field there. Note that you need biber as a backend. Let me know how it goes.
    – ienissei
    Commented Mar 5, 2012 at 14:44
  • 2
    Somebody implemented sorting by months in this answer: tex.stackexchange.com/a/33332/10434 Maybe that helps you? I'd suggest you set up a minimal working example, because it's a lot of guessing otherwise.
    – dhst
    Commented Mar 5, 2012 at 15:08

1 Answer 1

40

Edited by moewe (2018-07-14) to conform with the new names and sorting template definitions of biblatex >= v3.8. See the edit history for older versions.

Under any of the predefined sorting schemes, you can override the order of the bibliography using the presort and sortkey fields. The presort field is intended to group entries together in the bibliography. The sortkey field serves as a master sort key.

From the appendix the biblatex manual, you can see that the predefined sorting schemes establish chronology only with the year and volume fields. With biber as the backend you can use \DeclareSortingTemplate to also consider month and day. When data are not available, fallback values can be specified with \literal{<value>}. Otherwise "small" fallback values are used.

Here I've defined a new sorting scheme based on nyt from biblatex.def.

\documentclass{article}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[backend=biber,sorting=nymdt]{biblatex}

\DeclareSortingTemplate{nymdt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field[padside=left,padwidth=2,padchar=0]{month}
    \literal{00}
  }
  \sort{
    \field[padside=left,padwidth=2,padchar=0]{day}
    \literal{00}
  }
  \sort{
    \field{sorttitle}
  }
  \sort{
    \field[padside=left,padwidth=4,padchar=0]{volume}
    \literal{0000}
  }
}

\begin{filecontents}{\jobname.bib}
@Article{ref1,
  author = {Lastname, Firstname},
  title = {Article entry with presort field},
  journaltitle = {Journal},
  volume = {12},
  date = {2001-01/2001-02},
  pages = {92--122},
  presort = {A}}
@Book{ref2,
  author = {Lastname, Firstname},
  title = {A book entry with presort field},
  year = {2001},
  month = feb,
  day = {11},
  presort = {A}}
@Book{ref3,
  author = {Lastname, Firstname},
  title  = {A book entry with sortkey field},
  date = {2000-01-01},
  sortkey = {1}}
@article{itzhaki:phys,
  author = {Itzhaki, Nissan},
  volume = {54},
  number = {2},
  journal = {Phys. Rev. D},
  doi = {10.1103/PhysRevD.54.1557},
  year = {1996},
  month = {7},
  day = {15},
  title = {Black hole information versus locality},
  pages = {1557--1563}}
\end{filecontents}

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

\begin{document}
\nocite{ref1,ref2,ref3}
\nocite{knuth:ct,knuth:ct:a,knuth:ct:b,itzhaki,itzhaki:phys}
\printbibliography
\end{document}

enter image description here

Note the various ways dates are specified in the example. The date field follows the yyyy-mm-dd format, but you can omit -mm-dd or -dd. This field also takes date ranges separated by / (e.g. yyyy/yyyy, yyyy-mm-dd/yyyy-mm-dd, yyyy/). By default the beginning of ranges are used for sorting. You can also specify dates with the year, month and day fields. String values for month are accepted, but only in 3-letter abbreviations (jan, feb, mar, ...). These must be given without quotes or braces (e.g. month = jul).

You can override the chronological order somewhat with the sortyear field. In biblatex-examples.bib, the knuth:ct, knuth:ct:a and knuth:ct:b entries are given the sortyear values 1984-0, 1984-1 and 1986-1, respectively.

For descending dates, use the direction=descending option setting for \sort.

\DeclareSortingTemplate{ndymdt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort[direction=descending]{
    \field{sortyear}
    \field{year}
    \literal{9999}
  }
  \sort[direction=descending]{
    \field[padside=left,padwidth=2,padchar=0]{month}
    \literal{99}
  }
  \sort[direction=descending]{
    \field[padside=left,padwidth=2,padchar=0]{day}
    \literal{99}
  }
  \sort{
    \field{sorttitle}
  }
  \sort[direction=descending]{
    \field[padside=left,padwidth=4,padchar=0]{volume}
    \literal{9999}
  }
}

enter image description here

Further details on \DeclareSortingTemplate can be found in the biblatex manual.

4
  • 2
    Thank you very much. I tried your adaptions in my minimal example but the first 5 entries are still sorted wrong. :( Commented Mar 5, 2012 at 16:31
  • And do you know if it makes a difference to add year/month/day separate in the bib entries or is the date field equivalent? Commented Mar 5, 2012 at 16:41
  • Whoops. Sorry about that. Additional fields in each \sort group are intended to break ties. I'll make a correction in a minute. You can specify dates any valid way you like - biber will parse the data into the various date fields.
    – Audrey
    Commented Mar 5, 2012 at 16:52
  • 8
    Audrey is quickly becoming the authoritative source for the Biber-only biblatex features ...
    – PLK
    Commented Mar 6, 2012 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .