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've got a problem with my bibliography. I have to split it up into different parts (books / articles). The problem is, I`ve got articles AND books of the same author, published in the same year. Using biblatex and "authoryear", they are sorted alphabetically by title.

 \documentclass{article}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{references.bib}

@article{Anonymous:2012b,
Author = {Anonymous, Arthur},
Journal = {Somewhere},
Pages = {46-54},
Title = {Arthur's article},
Volume = {25 (2012)},
Year = {2012}}

@article{Anonymous:2012c,

Author = {Anonymous, Arthur},
Journal = {Somewhere else},
Pages = {6-12},
Title = {Last words},
Volume = {43 (2012)},
Year = {2012}}

@book{Anonymous:2012a,
Address = {Someplace},
Author = {Anonymous, Arthur},
Publisher = {Nobody},
Title = {Book by Arthur},
Year = {2012}}

\end{filecontents}

\bibliography{references.bib}


\begin{document}
\nocite{*}

\printbibliography[title={Books}, type=book]

\printbibliography[title={Articles},type=article]

\end{document}

I am not allowed to post a picture of the results, but the main result is: "Book by Arthur" gets the label "2012b". The problem is: I need to have an automatical sorting that labels the book 2012a - as it is the first reference given in the bibliography - and the first article 2012b.

I cannot find a solution. Maybe someone's got an idea?

Thank you very much!


O.k., I'm trying to specify what I have to achieve and I will provide a simple example without code (as I am not at home right now; I´ll try to add an example based on code later).

My PhD thesis contains a bibliography of ALL publications of two authors in a specific period of time. Therefore, the problem is not just a local one, but more ore less all over the place. The bibliography will probably contain at least 500 , much more likely nearly 1000 publications over the space of 30 years, of all kinds of types. Aside from splitting these bibliographies in different sections (that would be easy if the main problem is solved), the general sorting I need is as follows:

Name, Year, and (!) within every single year: "books" first, then "incollection", then "articles"

This would read as follows:

Anonymous 2001a: article (title: "a")

Anonymous 2001b: article (title: "x")

Anonymous 2002a: book (title: "e")

Anonymous 2002b: book (title: "m")

Anonymous 2002c: book (title: "z")

Anonymous 2002d: article (title: "b")

Anonymous 2003a: book (title: "g")

Anonymous 2003b: article (title: "d")

Anonymous 2003c: article (title: "h")

Anonymous 2004a: book (title: "n")

Anonymous 2004b: incollection (title: "j")

Anonymous 2005a: incollection (title: "y")

Anonymous 2005b: article (title: "k")

Anonymous 2012a: book (title: "n")

Anonymous 2012b: article (title: "l")

Anonymous 2012c: article (title: "s")

share|improve this question
add comment

3 Answers

Using biblatex 2.0 and biber 1.0. You have to redefine the nyt sorting scheme and add a custom field, example below. In general, this is easy, just add a custom field with an ordering value based on the entrytype of the entry, then sort on this after the year:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pertype{book}
      \step[fieldset=usera, fieldvalue=1]
    }
    \map{
      \pertype{article}
      \step[fieldset=usera, fieldvalue=2]
    }
  }
}

\DeclareSortingScheme{nyt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \name{sortname}
    \name{author}
    \name{editor}
    \name{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{usera}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field[padside=left,padwidth=4,padchar=0]{volume}
    \literal{0000}
  }
}
share|improve this answer
    
Amazing what is possible with biblatex. It's also amazing though, that the cite position in the document does not seem to be accessible unless you go all the way and disable sorting. –  Christian Jun 28 '12 at 22:34
    
@Christian Actually, this isn't quite true ... see p. 183 of the biblatex 2.0 manual. You can use the \citeorder special sorting directive anywhere in a sorting specification. sorting=none is just a special case which only uses this. –  PLK Jun 29 '12 at 10:39
    
Well, isn't that then exactly what would help @slartibartfast? –  Christian Jun 29 '12 at 17:14
    
Hmm, I'm not sure as he doesn't want the citation order, he just wants to make sure that name/year disambiguation also puts books before articles. –  PLK Jun 30 '12 at 18:15
add comment

I think you can do this by adding a "presort" field to your books. So, for instance, add Presort = {1} to the book entry. There doesn't seem to be any need to add it to the other entries, and the ones with the presort field set get sorted first.

If you were using Biber, you could do this automatically by putting in your biber.conf

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <sourcemap>
    <maps datatype="bibtex">
    <map map_overwrite="1">
    <per_type>BOOK</per_type>
    <map_step map_field_set="presort"
              map_field_value="1"/>
    </map>
    <map map_overwrite="1">
    <per_type>INCOLLECTION</per_type>
    <map_step map_field_set="presort"
              map_field_value="2"/>
    </map>
    <map map_overwrite="1">
    <per_type>ARTICLE</per_type>
    <map_step map_field_set="presort"
              map_field_value="3"/>
    </map>
  </maps>
  </sourcemap>
</config>

This will automatically add the presort field to all book, article and incollection entries with appropriate values. Of course this assumes you are not using the presort field already.

Update

Of course, this works on the assumption (as appeared in the original post) that there were just two relevant categories of bibliography: book and articles, with no overlap. Then the presort trick works, because it doesn't matter that all books end up being sorted before all articles. The trick is extensible in cases where there are three categories or more, provided there is no overlap between the categories (i.e. that each bibliography that ends up being printed is self-contained): one would simply have to extend the mapping so that it selected based on whatever determined the category and added an appropriate presort.

If the categories overlap, then this cannot, work as it stands. In that case, one would need a more nuanced approach. I think it would run something like this.

(A) First proceed as before, setting a presort field for books (assuming you want those to come first). Since you have a hierarchy you set different presort fields for each, and using either biber.conf (as set out above) or the new facilities of the imminently-to-be-released version of biblatex you could do it from the .tex file itself.

(B) Now revise the sorting scheme, so that the presort field is used after the year but before the title. Now it will only apply in cases where there is more than one work that has already passed through the author and year sorts. This will require biber.

\DeclareSortingScheme{custom}{%
   \sort{\name{sortname}
         \name{author}
         \name{editor}
         \name{translator}}
   \sort{\field{year}}
   \sort{\field{presort}}
   \sort{\field{sorttitle}
         \field{title}}}

Now load biblatex with the option to use this sorting scheme [...backend=biber,sorting=custom].

Of course if you were already using presort for some purpose, this could be problematic (though not very: one would just use usera or some such); but assuming you are not, this in effect allows you to use it with more discrimination: you won't get ALL books before ALL articles, just books with the same author before articles by that author.

share|improve this answer
    
With biblatex 2.0/biber 1.0, you can also do this source mapping in your document using \DeclareSourcemap –  PLK Jun 28 '12 at 11:22
    
Why do you want to restructure the sorting scheme instead of using sorttitle which already is at the position where you want to put presort? –  Christian Jun 28 '12 at 22:36
    
@Christian because sorttitle might still be needed for its proper purpose as well. The same could be said of presort of course! Which is why a custom field would be better. –  Paul Stanley Jun 29 '12 at 8:26
add comment

The problem with presort is that it is indeed the first key to be used when sorting. You might be better off with sorttitle in the bib entry which is a special field that is only used for sorting. Similarly, there is also sortyear and so on. Section 3.4 in the BibLaTeX documentation explains in great detail how sorting works and how to fine-tune it.

For example

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{references.bib}

@article{Anonymous:2012b,
Author = {Anonymous, Arthur},
Journal = {Somewhere},
Pages = {46-54},
Title = {Arthur's article},
Volume = {25 (2012)},
Year = {2012},
sorttitle = {b}}

@article{Anonymous:2012c,

Author = {Anonymous, Arthur},
Journal = {Somewhere else},
Pages = {6-12},
Title = {Last words},
Volume = {43 (2012)},
Year = {2012},
sorttitle = {c}}

@book{Anonymous:2012a,
Address = {Someplace},
Author = {Anonymous, Arthur},
Publisher = {Nobody},
Title = {Book by Arthur},
Year = {2012},
sorttitle = {a}}

\end{filecontents}

\bibliography{references.bib}


\begin{document}
\nocite{*}

\printbibliography[title={Books}, type=book]

\printbibliography[title={Articles},type=article]

\end{document}

gives you this:

result

In this case you might as well have used presort to be sure. But I assume overall you have more than three citations in your actual document.

share|improve this answer
    
I've already worked my way through the Biblatex documentation, but the solutions provided don't seem to fit my needs. I've got three different sections (Author1, Author2, Other references) and of both author sections one has about 150 entries, the other about 500 entries. The case for which I provided a simple example is very usual in connection with these entries. Using "Presort" would give me all the books first, colliding with the splitting in author1, author2, others - at least as far as I can understand the documentation. –  slartibartfast Jun 28 '12 at 10:40
    
@slartibartfast, with presort you can do a completely manual sorting, however you like. You shouldn't have any problems to achieve what you want in principle. The question is whether you can take the sorting you already have and slightly modify it to get exactly what you want. I have to say I didn't completely understand what order you want exactly, though. –  Christian Jun 28 '12 at 10:50
    
I added an example. Is this the result you wanted? –  Christian Jun 28 '12 at 11:01
    
yes, this would be the result I want in the case given. I have to think about the question if it is of any help in my actual PhD-dissertation, as the bibliography there is far more complex. And my main goal is to AVOID manual sorting (that's what I did in MS Word to come to grips with my problems, and it was HELL!) –  slartibartfast Jun 28 '12 at 11:23
    
I forgot: THANK YOU! –  slartibartfast Jun 28 '12 at 11:32
show 1 more 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.