biblatex - 根据数字对引用进行排序(拆分参考书目)

biblatex - 根据数字对引用进行排序(拆分参考书目)

这是biblatex - 分割书目中的一致编号

我的参考书目按类别分为两部分。条目按连续编号,我想对每个部分中的条目进行排序\cite。但是,每个部分中的\cite条目按年份排序(首先),因此参考书目第一部分和第二部分的条目会混淆。

梅威瑟:

\documentclass{article}

\usepackage[
    sorting      = ynt,
    bibstyle     = numeric,
    defernumbers = true,
    sortcites    = true
]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
    @book{a,
        author = "I",
        year = "1973"
    }
    @book{a2,
        author = "I",
        year = "1923"
    }
    @book{b,
        author = "You",
        year = "1959"
    }
\end{filecontents}

\addbibresource{\jobname.bib}

\DeclareBibliographyCategory{own}

\begin{document}

\cite{a,a2,b}

\addtocategory{own}{a,a2}

\printbibliography[category=own,title={A}]
\printbibliography[notcategory=own,title={B}]

\end{document}

引用的内容是[1, 3, 2],但我希望有[1, 2, 3]

有什么好方法可以实现这个目标吗?

答案1

由于我们想要将具有某个属性的条目排在其他条目之前,并且排序是由 Biber 完成的,因此我们必须告诉 Biber 哪个.bib条目具有此属性(有一种方法可以摆脱这个限制,有关更多详细信息,请参阅下文)。

因此,我们不能再使用 bibcategories,而是使用keywords。只需添加keywords = {own}到相关条目即可

@book{a,
  author = "I",
  year = "1973",
  keywords = {own},
}

当然,参考书目已经过滤了keywordnotkeyword现在

\printbibliography[keyword=own,title={A}]
\printbibliography[notkeyword=own,title={B}]

然后我们检查own,如果关键字存在,则用 填充字段presortA否则获取B

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=keywords, match=\regexp{(^|,)own(,|$)}, final]
      \step[fieldset=presort, fieldvalue = {A}]
    }
    \map{
      \step[fieldset=presort, fieldvalue = {B}]
    }
  }
}

平均能量损失

\documentclass{article}

\usepackage[
    sorting      = ynt,
    bibstyle     = numeric,
    defernumbers = true,
    sortcites    = true
]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{a,
  author = "I",
  year = "1973",
  keywords = {own},
}
@book{a2,
  author = "I",
  year = "1923",
  keywords = {own},
}
@book{b,
  author = "You",
  year = "1959",
}
@book{c,
  author = "You",
  year = "1970",
  keywords = {notmine},
}
\end{filecontents*}

\addbibresource{\jobname.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=keywords, match=\regexp{(^|,)own(,|$)}, final]
      \step[fieldset=presort, fieldvalue = {A}]
    }
    \map{
      \step[fieldset=presort, fieldvalue = {B}]
    }
  }
}

\begin{document}
\cite{a,a2,b,c}

\printbibliography[keyword=own,title={A}]
\printbibliography[notkeyword=own,title={B}]
\end{document}

示例输出


要从.tex文件中执行所有操作,请使用

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=entrykey, match=\regexp{^(a|a2)$}, final]
      \step[fieldset=presort, fieldvalue = {A}]
    }
    \map[overwrite=true]{
      \step[fieldsource=entrykey, match=\regexp{^(a|a2)$}, final]
      \step[fieldset=keywords, fieldvalue = {own}, append]
    }
    \map{
      \step[fieldset=presort, fieldvalue = {B}]
    }
  }
}

在上述两个步骤中,您将(a|a2)使用 分隔的“自己的”输入键列表进行替换|

平均能量损失

\documentclass{article}

\usepackage[
    sorting      = ynt,
    bibstyle     = numeric,
    defernumbers = true,
    sortcites    = true
]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{a,
  author = "I",
  year = "1973",
}
@book{a2,
  author = "I",
  year = "1923",
}
@book{b,
  author = "You",
  year = "1959",
}
@book{c,
  author = "You",
  year = "1970",
}
\end{filecontents*}

\addbibresource{\jobname.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=entrykey, match=\regexp{^(a|a2)$}, final]
      \step[fieldset=presort, fieldvalue = {A}]
    }
    \map[overwrite=true]{
      \step[fieldsource=entrykey, match=\regexp{^(a|a2)$}, final]
      \step[fieldset=keywords, fieldvalue = {own}, append]
    }
    \map{
      \step[fieldset=presort, fieldvalue = {B}]
    }
  }
}

\begin{document}
\cite{a,a2,b,c}

\printbibliography[keyword=own,title={A}]
\printbibliography[notkeyword=own,title={B}]
\end{document}

相关内容