7

I know I can group bibliographyes by keyword. But this is not a case, becouse if i dont use alphabetical sorting and numeric style I can split bibliography by keywords. But if I want sorted bibliography and numeric numbering and will try to split it I will break numbering. What I need is to have bib items of some language before than another language items. Example:

\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage[english,greek,russian]{babel} % English please
\setmainfont[
BoldFont={DeJavu Serif Bold},
ItalicFont={DeJavu Serif Italic},
BoldItalicFont={DeJavu Serif BoldItalic}
]{DeJavu Serif}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Book{AlKarapan,
author = {Καραπαναγοπούλου, Αλέξανδρος Κ.},
title = {Η Μεγάλη Σύνοδος της Ορθοδόξου Ανατολικής Εκκλησίας},
publisher = {auto-édition},
date = {1990/1998},
volumes = {6},
address = {Αθήνα},
langid={greek},
}
@Inbook{CypinIstorijaRPC,
author = {Владислав Цыпин},
title = {История Русской Церкви 1917--1997},
chapter = {VIII},
publisher = {Издательство Спасо-Преображенского Валаамского монастыря},
address = {Москва},
date = {1997},
urldate = {2010-10-25},
url = {http://old.pravoslavie.by/podpod.asp?id=135&Session=10},
langid={russian},
}
@Inbook{authorrus,
    author = {Другой Автор},
    title = {Название},
    chapter = {VIII},
    publisher = {Издательство},
    address = {Москва},
    date = {1997},
    urldate = {2010-10-25},
    langid={russian},
}
@article{baez/article,
    author       = {Baez, John C. and Lauda, Aaron D.},
    title        = {Higher-Dimensional Algebra {V}: 2-Groups},
    journaltitle = {Theory and Applications of Categories},
    date         = 2004,
    volume       = 12,
    pages        = {423-491},
    version      = 3,
    eprint       = {math/0307200v3},
    eprinttype   = {arxiv},
    langid       = {english},
    langidopts   = {variant=american},
    annotation   = {An \texttt{article} with \texttt{eprint} and
        \texttt{eprinttype} fields. Note that the arXiv reference is
        transformed into a clickable link if \texttt{hyperref} support
        has been enabled.  Compare \texttt{baez\slash online}, which
        is the same item given as an \texttt{online} entry},
    hyphenation={english},
}
@article{another,
    author       = {Another,Author and One more, Author},
    title        = {Title},
    journaltitle = {Journal},
    date         = 2004,
    volume       = 12,
    pages        = {423-491},
    version      = 3,
    eprint       = {math/0307200v3},
    eprinttype   = {arxiv},
    langid       = {english},
    langidopts   = {variant=american},
    hyphenation={english},
}
\end{filecontents*}

\usepackage[russian,greek,english]{babel}
\usepackage[natbib=true,
style=numeric,
isbn=true,
url=true,
defernumbers=false,
sorting=nyt, 
firstinits=true,
backend=biber,
language=auto,  
autolang=other]{biblatex}

\addbibresource{\jobname.bib}

\begin{document}
\cite{AlKarapan,CypinIstorijaRPC,baez/article}
\nocite{*}
\printbibliography
\end{document}

output will be: items in english, than in Greek and in Russian. If I edit bbl file, just moving Russian entries in begining , then Greek entries and last English entry and dont run biber just cite entries and run lualatex or xelatex everything will be fine.

Biblatex/Biber sorts bibliography, and i manually move entries for given language in bbl file. I get entries sorted for a given language and language ordering i want.

Question: can I do this kind of ordering without editing bbl file

this is what i'm trying to get bibliography after moving entries

I can not use multiple bibs becouse i need continious numbering

7

Of course one can just put a \sort{\field{langid}} into the sorting procedure, but that will sort the languages lexicographically, so English will appear first, then Greek and then Russian, not exactly what you want.

But incidentally, if we sort descending lexicographically we get the order you want in the MWE.

\DeclareSortingScheme{lnyt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort[direction=descending]{\field{langid}}
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field[padside=left,padwidth=4,padchar=0]{volume}
    \literal{0000}
  }
}

That is of course only because the sorting order you want coincides with the reverse lexicographic order of the language names.

Use sorting=lnyt now.


A more customisable but slightly more complicated solution uses the presort field and Biber's sourcemapping feature.

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=langid, match=\regexp{\Arussian\Z}, final]
      \step[fieldset=presort, fieldvalue=1]
    }
    \map{
      \step[fieldsource=langid, match=\regexp{\Agreek\Z}, final]
      \step[fieldset=presort, fieldvalue=2]
    }
    \map{
      \step[fieldsource=langid, match=\regexp{\Aenglish\Z}, final]
      \step[fieldset=presort, fieldvalue=3]
    }
  }
}

Each language is simply mapped to a number that is written to the presort field. The presort field is considered before the other sort fields.

This allows for sort orders that don't follow any lexicographic order.

MWE

\documentclass[a4paper]{article}
\usepackage{fontspec}
\usepackage[english,greek,russian]{babel} % English please
\setmainfont[
BoldFont={DeJavu Serif Bold},
ItalicFont={DeJavu Serif Italic},
BoldItalicFont={DeJavu Serif BoldItalic}
]{DeJavu Serif}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Book{AlKarapan,
author = {Καραπαναγοπούλου, Αλέξανδρος Κ.},
title = {Η Μεγάλη Σύνοδος της Ορθοδόξου Ανατολικής Εκκλησίας},
publisher = {auto-édition},
date = {1990/1998},
volumes = {6},
address = {Αθήνα},
langid={greek},
}
@Inbook{CypinIstorijaRPC,
author = {Владислав Цыпин},
title = {История Русской Церкви 1917--1997},
chapter = {VIII},
publisher = {Издательство Спасо-Преображенского Валаамского монастыря},
address = {Москва},
date = {1997},
urldate = {2010-10-25},
url = {http://old.pravoslavie.by/podpod.asp?id=135&Session=10},
langid={russian},
}
@Inbook{authorrus,
    author = {Другой Автор},
    title = {Название},
    chapter = {VIII},
    publisher = {Издательство},
    address = {Москва},
    date = {1997},
    urldate = {2010-10-25},
    langid={russian},
}
@article{baez/article,
    author       = {Baez, John C. and Lauda, Aaron D.},
    title        = {Higher-Dimensional Algebra {V}: 2-Groups},
    journaltitle = {Theory and Applications of Categories},
    date         = 2004,
    volume       = 12,
    pages        = {423-491},
    version      = 3,
    eprint       = {math/0307200v3},
    eprinttype   = {arxiv},
    langid       = {english},
    langidopts   = {variant=american},
    annotation   = {An \texttt{article} with \texttt{eprint} and
        \texttt{eprinttype} fields. Note that the arXiv reference is
        transformed into a clickable link if \texttt{hyperref} support
        has been enabled.  Compare \texttt{baez\slash online}, which
        is the same item given as an \texttt{online} entry},
    hyphenation={english},
}
@article{another,
    author       = {Another,Author and One more, Author},
    title        = {Title},
    journaltitle = {Journal},
    date         = 2004,
    volume       = 12,
    pages        = {423-491},
    version      = 3,
    eprint       = {math/0307200v3},
    eprinttype   = {arxiv},
    langid       = {english},
    langidopts   = {variant=american},
    hyphenation={english},
}
\end{filecontents*}

\usepackage[russian,greek,english]{babel}
\usepackage[natbib=true,
style=numeric,
isbn=true,
url=true,
defernumbers=false,
sorting=nyt, 
firstinits=true,
backend=biber,
language=auto,  
autolang=other]{biblatex}

\addbibresource{\jobname.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=langid, match=\regexp{\Arussian\Z}, final]
      \step[fieldset=presort, fieldvalue=1]
    }
    \map{
      \step[fieldsource=langid, match=\regexp{\Agreek\Z}, final]
      \step[fieldset=presort, fieldvalue=2]
    }
    \map{
      \step[fieldsource=langid, match=\regexp{\Aenglish\Z}, final]
      \step[fieldset=presort, fieldvalue=3]
    }
  }
}

\begin{document}
\cite{AlKarapan,CypinIstorijaRPC,baez/article}
\nocite{*}
\printbibliography
\end{document}

enter image description here

  • Incidentally, the second solution is more or less what PLK suggested in the question you linked to. – moewe Sep 19 '15 at 16:44
  • "But if we sort descending alphabetically you get exactly what you want." In this case yes, but not in case i need. I actually have one more language-georgian. It is set as a main language. So I want georgian bibliography in the first place than english,russian,greek . "one can just put a \sort{\field{langid}} into the sorting procedure, but that will sort the languages alphabetically, so English will appear first, then Greek and then Russian" this is not necessary, i guess biber(??) sorts by Unicode values. So it will work. Your Solution works fine...thank you very much. It is accepted – Levan Shoshiashvili Sep 19 '15 at 19:05
  • In other words, if i use your first solution (automatic sort by langid ascending or descending sorting) do not get desired result. Second general solution using 'presort' field does the job :) . Thank you. – Levan Shoshiashvili Sep 19 '15 at 19:17
  • @LevanShoshiashvili Yes think this is what I said: The first solution can only sort the languages lexicographically or possibly reverse-lexicographically. I don't understand your comment about Unicode sorting here, that should not matter, the langid field should only contain ASCII chars. In your MWE this solution worked out, since you wanted Russian, Greek, English. But for more complex sorting that does not coincide with any lexicographic order we need the second solution. – moewe Sep 20 '15 at 5:01

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.