我正在尝试进行自定义排序:引用顺序 -> 年/月 -> 作者 -> 标题
我认为我按照以下代码中的样式得到了它。但是,当我运行它时:pdflatex -> biber -> pdflatex -> pdflatex。数字一直在变化。首先,我在引文中得到了压缩行为,很好地 [1]-[5],但参考书目编号没有按顺序排列。因此,如果我再次运行 pdflatex,现在参考书目已排序,但引文似乎未排序。
我做错了什么? 我应该打开什么选项吗? 或者我的排序有问题?
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{ref2.bib}
@INPROCEEDINGS{C2009,
author = {C H.},
title = {M},
booktitle = {C},
year = {2009},
month = oct
}
@INPROCEEDINGS{J2010,
author = {J O.},
title = {L},
booktitle = {P},
year = {2010}
}
@ARTICLE{T2010,
author = {X B.},
title = {E},
year = {2010},
month = jun,
journal = {I}
}
@ARTICLE{Z2010,
author = {B},
title = {L},
year = {2010},
volume = {19},
month = feb,
journal = {I}
}
@ARTICLE{Z2007,
author = {B},
title = {H},
year = {2007},
month = jan,
journal = {I}
}
\end{filecontents}
\usepackage[backend=biber,style=ieee,bibencoding=utf8,defernumbers=true]{biblatex}
% sort in citation order and then by year/month, and author and title
\DeclareSortingScheme{cymat}{
\sort{\citeorder}
\sort{
\field{sortyear}
\field{year}
\literal{0}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{0}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{99}
}
\sort{
\name{sortname}
\name{author}
\name{editor}
\name{translator}
\field{sorttitle}
\field{title}
}
}
\bibliography{ref2}
\pagestyle{empty}
\begin{document}
\cite{J2010, Z2010, Z2007, C2009, T2010}
\printbibliography[sorting=cymat]
\end{document}
答案1
您应该删除该defernumbers
选项,因为它会延迟数字的分配并使列表的压缩等出现问题。此外,该sorting
选项应该传递给包,而不是\printbibliography
命令。
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{ref2.bib}
@INPROCEEDINGS{C2009,
author = {C H.},
title = {M},
booktitle = {C},
year = {2009},
month = oct
}
@INPROCEEDINGS{J2010,
author = {J O.},
title = {L},
booktitle = {P},
year = {2010}
}
@ARTICLE{T2010,
author = {X B.},
title = {E},
year = {2010},
month = jun,
journal = {I}
}
@ARTICLE{Z2010,
author = {B},
title = {L},
year = {2010},
volume = {19},
month = feb,
journal = {I}
}
@ARTICLE{Z2007,
author = {B},
title = {H},
year = {2007},
month = jan,
journal = {I}
}
\end{filecontents}
\usepackage[backend=biber,style=ieee,bibencoding=utf8,sorting=cymat]{biblatex}
% sort in citation order and then by year/month, and author and title
\DeclareSortingScheme{cymat}{
\sort{\citeorder}
\sort{
\field{sortyear}
\field{year}
\literal{0}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{0}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{99}
}
\sort{
\name{sortname}
\name{author}
\name{editor}
\name{translator}
\field{sorttitle}
\field{title}
}
}
\bibliography{ref2}
\pagestyle{empty}
\begin{document}
\cite{J2010, Z2010, Z2007, C2009, T2010}
\printbibliography
\end{document}
答案2
评论。 感谢 Andrew 和 Audrey 的评论,我设法解决了这个问题。但是,为了完整起见,我想在这里提供整个解决方案。问题是 MWE 没有包含额外的参考书目,因为它不是重现问题所必需的。但是,它受到了所提解决方案的影响。因此,我在这里提出了一个完整的解决方案,当存在额外参考书目时,它也能解决该问题。
完整解决方案
sorting=cymat
虽然 Andrew 的解决方案通过将移动到包加载选项而不是与宏一起使用来解决问题\printbibliography
,但它并没有解决使用其他书目时修复数字的问题。
但是,我注意到该defernumbers=true
选项允许正确排序这些数字。因此,完整的解决方案是将该sorting
选项移至加载选项并打开defernumbers
。
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{ref2.bib}
@INPROCEEDINGS{C2009,
author = {C H.},
title = {M},
booktitle = {C},
year = {2009},
month = oct
}
@INPROCEEDINGS{J2010,
author = {J O.},
title = {L},
booktitle = {P},
year = {2010}
}
@ARTICLE{T2010,
author = {X B.},
title = {E},
year = {2010},
month = jun,
journal = {I}
}
@ARTICLE{Z2010,
author = {B},
title = {L},
year = {2010},
volume = {19},
month = feb,
journal = {I}
}
@ARTICLE{Z2007,
author = {B},
title = {H},
year = {2007},
month = jan,
journal = {I}
}
@ARTICLE{K2013,
author = {K O.},
title = {B},
year = {2013},
month = feb,
journal = {I},
keywords = {publication}
}
@INPROCEEDINGS{K2012,
author = {K O.},
title = {S},
booktitle = {I},
year = {2012},
month = jul,
keywords = {publication}
}
@ARTICLE{M2011,
author = {M O.},
title = {M},
year = {2011},
month = jun,
journal = {L},
keywords = {publication}
}
@INPROCEEDINGS{M2010,
author = {M O.},
title = {S},
booktitle = {A},
year = {2010},
month = aug,
keywords = {publication}
}
@ARTICLE{M2012,
author = {M O.},
title = {S},
year = {2012},
month = jul,
journal = {I},
keywords = {publication}
}
\end{filecontents}
\usepackage[backend=biber,style=ieee,bibencoding=utf8,sorting=cymat,defernumbers=true]{biblatex}
\DeclareSortingScheme{ymdtn}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort[direction=descending]{
\field{sortyear}
\field{year}
\literal{9999}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{99}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{99}
}
\sort{
\field{sorttitle}
}
\sort[direction=descending]{
\field[padside=left,padwidth=4,padchar=0]{volume}
\literal{9999}
}
\sort{
\name{sortname}
\name{author}
\name{editor}
\name{translator}
\field{sorttitle}
\field{title}
}
}
% sort in citation order and then by year/month, and author and title
\DeclareSortingScheme{cymat}{
\sort{\citeorder}
\sort{
\field{sortyear}
\field{year}
\literal{0}
}
\sort{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{0}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{99}
}
\sort{
\name{sortname}
\name{author}
\name{editor}
\name{translator}
\field{sorttitle}
\field{title}
}
}
\bibliography{ref2}
\pagestyle{empty}
\begin{document}
\cite{J2010, Z2010, Z2007, C2009, T2010}
\printbibliography%[sorting=cymat] % removed the sorting from here to the package
\newrefsection
\nocite{*}
\printbibliography[resetnumbers=true,keyword=publication,type=article,heading=subbibliography,title={Journals},sorting=ymdtn]
\printbibliography[keyword=publication,type=inproceedings,heading=subbibliography,title={Conferences},sorting=ymdtn]
\end{document}
未决问题
但是,我并不清楚为什么会发生这种情况。为什么在第二个参考书目中该sorting
选项有效,而\printbibliography
在主参考书目中却无效?也许这应该是另一个问题,或者更有知识的人可以在这方面进行扩展。