按电子版排序参考书目

按电子版排序参考书目

我想按电子版对参考书目进行排序,但是不可以:

\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}

\DeclareSortingTemplate{eprint}{
    \sort[direction=descending]{\field{eprint}}
}

\DeclareSortingTemplate{year}{
    \sort[direction=descending]{\field{year}}
}

\begin{filecontents}{references.bib}
@article{A01,
    author = {Author, A.},
    year = {2014},
    title = {Alpha},
    eprint = {1402.1354},
}
@article{B02,
    author = {Buthor, B.},
    year = {2016},
    title = {Bravo},
    eprint = {1602.1354},
}
@article{C03,
    author = {Cuthor, C.},
    year = {2015},
    title = {Charlie},
    eprint = {1504.1354},
}
\end{filecontents}

\addbibresource{references.bib}

\begin{document}
\newrefcontext[sorting=eprint]
\nocite{*}
\printbibliography

\newrefcontext[sorting=year]
\nocite{*}
\printbibliography
\end{document}

这是由于 eprint 字段的 verbatim 类型造成的吗?有没有简单的方法可以解决这个问题?

答案1

根据@moewe的建议,我提交了一个错误报告(https://github.com/plk/biber/issues/263对我来说,将 eprint 字段映射到另一个字段进行排序是可行的:

\documentclass{article}
\usepackage{filecontents}
\usepackage[backend=biber]{biblatex}

\DeclareSortingTemplate{eprint}{
    \sort[direction=descending]{\field{sortkey}}
}

\begin{filecontents}{references.bib}
@article{A01,
    author = {Author, A.},
    year = {2014},
    title = {Alpha},
    eprint = {1402.1354},
}
@article{B02,
    author = {Buthor, B.},
    year = {2016},
    title = {Bravo},
    eprint = {1602.1354},
}
@article{C03,
    author = {Cuthor, C.},
    year = {2015},
    title = {Charlie},
    eprint = {1504.1354},
}
\end{filecontents}

\addbibresource{references.bib}

\DeclareSourcemap{
    \maps[datatype=bibtex]{
        \map{
            \step[fieldsource=eprint]
            \step[fieldset=sortkey,origfieldval]
        }
    }
}

\begin{document}
\newrefcontext[sorting=eprint]
\nocite{*}
\printbibliography
\end{document}

相关内容