5

I am writing a custom citation style, and am attempting to write the sorting rules. I want the names in the bibliography to be sorted by last name only, ignoring all first names and initials. However, I also want the initials to be printed in the actual bibliography list. Here is a minimal working example:

\documentclass[10pt]{article}

\usepackage[style=authoryear,backend=biber,sorting=last]{biblatex}

\DeclareNameFormat{lastname}{#1\addspace}
\DeclareNameFormat{last-init}{#1 #4\addspace}

\DeclareNameAlias{sortname}{lastname}
\DeclareNameAlias{default}{lastname}
\DeclareNameAlias{author}{last-init}

\DeclareSortingScheme{last}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{author}
  }
  \sort{
    \field{title}
    \field{year}
  }
}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@book{first,
  author = {John Doe and Mary Jane},
  title = {Lorem Ipsum},
  publisher = {Oxford University Press},
  location = {Oxford},
}

@book{second,
  author = {Apple Doe and Mary Sue},
  title = {Another},
  publisher = {Cambridge},
  location = {Cambridge},
  date = {1917},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}

\nocite{*}

\printbibliography

\end{document} 

This prints out citations:

Doe A. Sue M. (1917). Another. Cambridge: Cambridge.
Doe J. Jane M. Lorem Ipsum. Oxford: Oxford University Press.

But this uses the first initial to disambiguate having the same first last names, rather than using the second last name. The result should be:

Doe J. Jane M. Lorem Ipsum. Oxford: Oxford University Press.
Doe A. Sue M. (1917). Another. Cambridge: Cambridge.
  • 1
    Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. – jub0bs May 1 '14 at 22:07
  • Hi, can you tell us, what you want to achieve with this? Should the firstnames be sorted in the order of their appearance in cites, or in the order of their appearance in your bib-file? Or just random – which wouldn't make much sense at all. – musicman May 2 '14 at 5:10
  • 1
    I don't think that there is "official" way to do this. One probably could use bibers nosort with some clever regex but one would have to find out first how name parts are formated during the sorting. I don't think that it is really worth the time. The sorting seems quite curious. Why do you want to confuse the readers by using it? – Ulrike Fischer May 2 '14 at 8:42
  • 1
    This will inadvertently sort "Doe, John: B Title" between "Doe, Jane: A Title" and "Doe, Jane: C Title". So Mrs Doe's works will be split with Mr Doe's "B Title" in between them. That will be quite confusing to your reader. – moewe May 2 '14 at 17:40
  • I am doing this in an attempt to replicate an existing citation style, rather than to design one myself. – Roma Klapaukh May 4 '14 at 21:08
1

This can be achieved by combining idea from the alphabetic style (and its sorting schema).

First of all you load the labelalpha option. Then you include labelname in the sorting schema.

So, you need

\usepackage[style=authoryear,backend=biber,sorting=last,labelalpha]
{biblatex}

and the definition of the sorting schema looks like:

\DeclareSortingScheme{last}{
  \sort{
    \field{presort}
  }
  \sort{
    \field{labelalpha}
  }
  \sort{
    \field{author}
  }
  \sort{
    \field{title}
    \field{year}
  }
}

enter image description here

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.