Closed moewew closed 6 years ago
OK. It is much simpler than that.
Consider
\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber, style=authoryear, minxrefs=1]{biblatex}
\begin{filecontents}{\jobname.bib}
@collection{pauly,
note = {foo},
sortkey = {zzzz},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
\nocite{pauly,sigfridsson}
\printbibliography
\end{document}
Due to the sortkey
I would expect pauly
to sort last. But it sorts first. A look at --trace
shows
sortdata => {
pauly => ["mm,,,,,zzzz", ["mm", "", "", "", "", "zzzz"]],
sigfridsson => [
"mm,,Sigfridsson!Emma#Ryde!Ulf,1998,Comparison of methods for deriving atomic charges from the electrostatic potential and moments,19",
[
"mm",
"",
"Sigfridsson!Emma#Ryde!Ulf",
1998,
"Comparison of methods for deriving atomic charges from the electrostatic potential and moments",
19,
],
],
},
While I would have expected something like
pauly => ["mm,,zzzz,zzzz,zzzz,zzzz", ["mm", "", "zzzz", "zzzz", "zzzz", "zzzz"]],
So sortkey
gets in too late if the entry has no fields that would determine sorting.
Interesting edge case. Should be fixed in 3.11 DEV now.
Works brilliantly now. Thank you.
To shoehorn in a feature request here: Would it be possible to use a sourcemap function to add an entry to the .bbl
/'cited' references, i.e. to \nocite
an entry via sourcemaps? In the MWE above it was necessary to add shorthand-of-$1
to the xref
of its parent and set minxrefs=1
to get it to appear in the .bbl
. Could there just be a flag to set in the sourcemap to automatically write that entry to the .bbl
?
Hmm, is this possible with an auto-created related entry instead as that will automatically add it as a dataonly
element which is sort of what this is designed for.
Wouldn't that mean that the parent entry can't have any other related
elements though?
The thing is that with sourcemaps we can create new entries, but we can't really force them to be written out to the .bbl
. And sometimes it is unreasonable to use an xref
, crossref
or related
feature to tie two entries together - and it might also not be possible to \nocite
the entry from the document (not sure if that even works with sourcemap-generated entries). Since Biber already processes these entries it seems at least possible to tell Biber to also write them to the .bbl
file. (Of course it would also be nice to do the same things for all entries in a .bib
file, but I can imagine that that might be even harder.)
Alright, I see your point - please try 3.11/2.11 dev versions now.
If all keys are already included (due to \nocite{*}
in the doc), this is automatic (and always was). There is now entrynocite
which applies to entrynew
and entryclone
steps. This allows you to manually \nocite
any created key:
\DeclareSourcemap{
\maps{
\map{
\step[fieldsource=shorthand, final]
\step[fieldsource=entrykey, match=\regexp{(.*)}]
\step[entrynew=shorthand-of-$1, entrynewtype=book, entrynocite]
\step[fieldsource=shorthand]
\step[fieldset=sortkey, origfieldval, entrytarget=shorthand-of-$1]
\step[fieldset=note, origfieldval, entrytarget=shorthand-of-$1]
}
}
}
Works just as expected. Thank you very much.
Consider the following MWE
Produces
For me. But since the
sortkey
field of the new entry is set to theshorthand
, i.e. 'RE'. I would expect the entries to sort asIn fact the
.bbl
says that the sort initial of the new entry is 'R'.A work-around is to use
sortname
instead ofsortkey
.Tested with 3.10/2.10.